Can we apply template to Added Chart Object (OBJ_CHART)

 

Hi all,

Can we apply template to Added Chart Object (OBJ_CHART)

 

Yes.

Forum on trading, automated trading systems and testing trading strategies

Adding Indicators to the mini charts in MT5

Alain Verleyen, 2013.12.01 17:41

I made an example to demonstrate this, see this chart :

I added a chart object named "MiniChart", then I run the following code :

   //--- Get mini chart ID
   long miniChartID=ObjectGetInteger(0,"MiniChart",OBJPROP_CHART_ID);
   //--- Get inficator handle
   int maHandle=iMA("EURCHF",PERIOD_H1,12,0,MODE_SMA,PRICE_CLOSE);   
   //--- Add indicator ro mini chart
   if(miniChartID>0 && maHandle!=INVALID_HANDLE)
      ChartIndicatorAdd(miniChartID,0,maHandle);
Of course, the chart object can also be added by code if needed.

Instead of ChartIndicatorAdd(), use ChartApplyTemplate().
 
Cool I will try it.
 
Yeey, it worked.