Perhaps you should read the manual, expecially the examples: ChartNext - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
Arpit T :
I have 100 symbols in market watch , I want to check which chart is currently active on tab or opened
What function i can look for
thanks
You need to create two arrays: one will contain the names of all symbols, the second - the names of the charts.
Then it remains to go through the arrays and perform the comparison.
Example:
//+------------------------------------------------------------------+ //| ChartNext and SymbolsTotal.mq5 | //| Copyright © 2022, Vladimir Karputov | //| https://www.mql5.com/en/users/barabashkakvn | //+------------------------------------------------------------------+ #property copyright "Copyright © 2022, Vladimir Karputov" #property link "https://www.mql5.com/en/users/barabashkakvn" #property version "1.000" #property description "" #property script_show_inputs //--- input parameters input bool InpPrint = true; // Print result //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- string symbols[],charts[]; //--- long currChart,prevChart=ChartFirst(); int i=0,limit=100; while(i<limit) // we have certainly not more than 100 open charts { currChart=ChartNext(prevChart); // get the new chart ID by using the previous chart ID if(currChart<0) break; // have reached the end of the chart list string chart_symbol=ChartSymbol(currChart); //--- int size_charts=ArraySize(charts); ArrayResize(charts,size_charts+1,9); charts[size_charts]=chart_symbol; //--- Print(i,ChartSymbol(currChart)," ID =",currChart); prevChart=currChart; // let's save the current chart ID for the ChartNext() i++; // do not forget to increase the counter } //--- int total=SymbolsTotal(true); for(int j=0; j<total; j++) { string symbol_name=SymbolName(j,true); int size_symbols=ArraySize(symbols); ArrayResize(symbols,size_symbols+1,9); symbols[size_symbols]=symbol_name; } //--- int size_charts=ArraySize(charts); int size_symbols=ArraySize(symbols); for(int j=0; j<size_charts; j++) { for(int k=0; k<size_symbols; k++) { if(symbols[k]==charts[j]) { Print(charts[j]); continue; } } } } //+------------------------------------------------------------------+
You just have to insert the counter in this code
Files:
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have 100 symbols in market watch, I want to check which chart is currently active on tab or opened
What function i can look for
thanks