find Chart ID

 

I use two time frame in Strategy Tester.



with function ChartID() i can find first chart id . who can i find second time frame (in this screenshot M30) Chart ID ?

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 
tinivini: I use two time frame in Strategy Tester. with function ChartID() i can find first chart id . who can i find second time frame (in this screenshot M30) Chart ID ?

By looping through all open charts with ChartNext and filtering to only the charts you want.

Documentation on MQL5: Chart Operations / ChartNext
Documentation on MQL5: Chart Operations / ChartNext
  • www.mql5.com
ChartNext - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

By looping through all open charts with ChartNext and filtering to only the charts you want.

i test with simple code :

long chartID=ChartFirst();
while(chartID >= 0)
  {
   Print(chartID);
   chartID = ChartNext(chartID);
  }

this code work in real time , but in ST output is only : 12345 (this is for first chart ID) .

 

I think the second chart in ST is an indicator with a different time frame than the main chart. In this case you should have the values already in your EA.

But you can start the EA on the timeframe of the indicator or you can change the indicator to m5 but showing the values of M30 - search for multi timeframe.

 
tinivini #:

i test with simple code :

this code work in real time , but in ST output is only : 12345 (this is for first chart ID) .

Hello, did you find a solution for this?
Reason: