Download MetaTrader 5

Adding Indicators to the mini charts in MT5

To add comments, please log in or register
Sign up for MQL5.community to leave your comments!
Bryan McAfee
970
Bryan McAfee 2013.12.01 16:04 

I was wondering if it is possible to add indicators to the mini charts that are available in MT5.  I Googled it and came up blank.  

 Pic below.

http://i.imgur.com/V8nKd5r.png

Alain Verleyen
Moderator
30707
Alain Verleyen 2013.12.01 17:26  
Yes it's possible but only by programming.
Alain Verleyen
Moderator
30707
Alain Verleyen 2013.12.01 17:41  

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

MetaTrader Trading Platform Screenshots

GBPCHF, D1, 2013.12.01

MetaQuotes Software Corp., MetaTrader 5, Demo

Example of a mini chart (object) with an indicator added

GBPCHF, D1, 2013.12.01, MetaQuotes Software Corp., MetaTrader 5, Demo

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.
Bryan McAfee
970
Bryan McAfee 2013.12.01 18:23  
Thank you so much !!!
Innate
11
Innate 2014.10.16 04:34  

Sorry for such a noob question but how do you execute the above code? 

I can add a new mini chart via the drop down menu's (Insert/Objects/Graphical/Chart)

But I dont understand how to run the code to get the indicator appear.

 

Thank you.  

Alain Verleyen
Moderator
30707
Alain Verleyen 2014.10.16 08:57  
Innate:

Sorry for such a noob question but how do you execute the above code? 

I can add a new mini chart via the drop down menu's (Insert/Objects/Graphical/Chart)

But I dont understand how to run the code to get the indicator appear.

 

Thank you.  

Create a new script for example and copy and paste this code inside OnStart() function.
Innate
11
Innate 2014.10.17 00:24  
angevoyageur:
Create a new script for example and copy and paste this code inside OnStart() function.
Thank you for such a speedy reply. I should be able to get that sorted. Much appreciated!! 
To add comments, please log in or register