Candle Range Match Finder

 

Hi to all,

I have coded a script that compares the range of the "any candle" that you choose on "the current chart" with the available charts on "marketwatch". You also choose how many bars to check for. 

For example:  (J) represents the amount of symbols from the market watch the code will check. (i) represents the amount of bars to check on each symbol.


What I want to do is get the code to check open charts only not the whole marketwatch list.

Any Idea on how to do this?

I tried with chartnext(), chart(first) but I had bunch of problems.


Also when I want to assign an int variable for the bar to check on the current Symbol I get bunch of errors. So at the moment I physically enter it at the code. I'm referring to the value 14 on this line    "rangetocheck=iHigh(ChartSymbol(),PERIOD_H1,14)-iLow(ChartSymbol(),PERIOD_H1,14);"


tnx in advance for your help.

//+------------------------------------------------------------------+
//|                                                   NOTEPAD.mq4 |
//|                                                            halil |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "halil"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

int multiplyer;
double rangetocheck;
double range;
 
   

void OnStart(){    
 

       rangetocheck=iHigh(ChartSymbol(),PERIOD_H1,14)-iLow(ChartSymbol(),PERIOD_H1,14);
       Alert("chartsymbol  ",ChartSymbol(),"---Range =  ",rangetocheck);          
  for(int j=28;j>-1;j--){
         for(int i=100;i>14;i--){
  
      range=iHigh(SymbolName(j, true),PERIOD_H1,i)-iLow(SymbolName(j, true),PERIOD_H1,i);
      if(rangetocheck==range){Alert("Range of Symbol: ",ChartSymbol(),"--Candle# ",14,"  Is a match with Symbol: ",SymbolName(j, true),"--Candle# ",i);}
      
      }
      }
      }