Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

Displaying Weather Dashboard in your Amibroker

1 min read

Thought of brining weather data into Amibroker. Googled for free weather api data. OpenWeathermap came to my notice. Using Openweathermap one can get weather data for any location on the globe immediately.

Sample Weather Output

{"coord":{"lon":77.6,"lat":12.98},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"base":"stations","main":
{"temp":294.15,"feels_like":297.36,"temp_min":294.15,"temp_max":294.15,"pressure":1012,"humidity":100},"visibility":6000,"wind":
{"speed":1.39,"deg":288},"clouds":{"all":75},"dt":1602971629,"sys":
{"type":1,"id":9208,"country":"IN","sunrise":1602981608,"sunset":1603024139},"timezone":19800,"id":1277333,"name":"Bengaluru","cod":200}

Amibroker AFL Code to get the Weather Dashboard

Code requires Amibroker 6.17 as some of the new AFL functions like InternetClose( handle ) , InternetOpenURL( “url” ) , InternetReadString( handle ) – which is essecial to read from internet resource/http api is available from v6.17 or higher version.

// Coder - Rajandran R
// Founder - Marketcalls.in & Co-Founder - Algomojo.com
// Algomojo Provides Free API + Free Trading Bridge for API Based Automated Trading
// Creation Date : 15th Oct 2020
// Weather Display Dashboard




_SECTION_BEGIN("Weather Display Dashboard");
Version(6.17);  //Code is Compatible with 6.17 and Higher
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorDefault, styleNoTitle | styleCandle | GetPriceStyle() ); 

city = ParamStr("City","Bangalore");

ih = InternetOpenURL( "http://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=1f082c296a4b6013f8976bdf820147c2" );

if( ih )
{
     while( ( str = InternetReadString( ih ) ) != "" )
     {
         //printf( "%s", str );
          for( item = -1; ( sym = StrExtract( str, item,'{' )) != ""; item-- )
	 {
	 
	 if(item == -4)
	 {
	 //printf( "%s", sym );
	 
	 for( jitem = -1; ( temp = StrExtract( sym, jitem,',' )) != ""; jitem-- )
	 {
	 printf( "\n%s", temp );
	 if(Strfind(temp,"temp"))
	 {
     temp1 = StrExtract(temp,1,':');
     temp1 = StrTrim(temp1,"\"");
    //_TRACE("\nTemperature : "+NumToStr(StrToNum(temp1)-273.15) +" Degree Celsious");
	 }
	 
	 if(Strfind(temp,"feels_like"))
	 {
     fl = StrExtract(temp,1,':');
     fl = StrTrim(fl,"\"");
    //_TRACE("\nFeels Like : "+NumToStr(StrToNum(fl)-273.15)+" Degree Celsious");
	 }
	 
	 
	 if(Strfind(temp,"humidity"))
	 {
     hm = StrExtract(temp,1,':');
     hm = StrTrim(hm,"\"");
     hm = StrTrim(hm,"}");
    //_TRACE("\nHumidity : "+hm);
	 }
	 
	  if(Strfind(temp,"pressure"))
	 {
     pr = StrExtract(temp,1,':');
     pr = StrTrim(pr,"\"");

    //_TRACE("\nPressure : "+pr);
	 }
	 
	 
	 }
	 
     
     }
	 }

     }
     InternetClose( ih );
      
}

//Display Weather Dashboard

GfxSetBkMode( 0 );
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetTextColor( colorWhite );


GfxSelectPen( colorGreen, 2 ); 
GfxSelectSolidBrush( colorgreen ); 
GfxRectangle( 10, 20, 250, 180 );

GfxTextOut( "City : "+city,23,23); 
GfxTextOut( "Temperature : " +NumToStr(StrToNum(temp1)-273.15) +" °C" ,23,48); 
GfxTextOut( "Feels Like : " +NumToStr(StrToNum(fl)-273.15) +" °C",23,73);
GfxTextOut( "Humidity : " + hm+"%",23,98); 
GfxTextOut( "Pressure : " + pr+"hPa",23,123);
   
    

_SECTION_END();

Now I nevermind to short Nifty Futures if Bangalore weather is crossing 30 degree Celsius!

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in and Co-Creator of Algomojo (Algorithmic Trading Platform for DIY Traders)

Stoploss, Multi Target, and Trailing Stoploss Module – Amibroker…

After Intraday V2.0 Amibroker Module - a readymade drag and drop module to convert any trading strategy into the intraday trading system with alerts,...
Rajandran R
6 min read

Line Trading – Algomojo Automation Module for Amibroker Users

The line Trading Automation tool is designed for Manual traders who want to perform level-based trade execution faster and also bring some advanced trade...
Rajandran R
58 sec read

Plotting Day Wise Equity Curve using Amibroker

We know that Amibroker provides an equity curve for the whole strategy. Is there a way where we can build a simple Day Wise...
Rajandran R
1 min read

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More