Candle match for all currency pairs charts opened on mt4

 

Hello,

To whom it may concern;

I am new to programming but have been a trader for 12 years.

Due to free time I decided to learn some mql4.

I have written couple of scripts. The last one which I will attach at the bottom of this page checks to see if a there is an identical bar to the one the user picks. So if you run the script there are 2 inputs which the user can change; first one is "barstocheck"(this determines how many bars to check for the identical candle starting from the back) second one is "bartocheck"(this is the candle to compare against all the other candles).

What I want to do next is to check all the currency pairs with their charts open on  mt4 for the identical candle.

Is there a numerical value attached for each chart/symbolname that is open on the mt4. I want to use those numerical values in a for loop to go through all symbols.

tnx in advance.

Hal.

//+------------------------------------------------------------------+
//|                                                    findmatch.mq4 |
//|                                                            halil |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "halil"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property show_inputs
extern int barstocheck=20;
extern int bartocheck=1;
int multiplyer;
double rangetocheck;
double range;
double bodytocheck;
double body;
double wickhightocheck;
double wickhigh;
double wicklowtocheck;
double wicklow;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()                     {

 //-------------------------------------------------------------------+

Alert("");
int k=bartocheck;
for(int i=barstocheck;i>k;i--)     {
 
//RANGE VALUE=============================================
    
//Get the first bars range value

  rangetocheck=High[k]-Low[k];
  multiplyer=Digits>=5?10000:100;
  rangetocheck=rangetocheck*multiplyer;
  rangetocheck=MathRound(rangetocheck);
  rangetocheck=DoubleToStr(rangetocheck,0);
   
 //Get the second bars range value
 
  range=High[i]-Low[i];
  multiplyer=Digits>=5?10000:100;
  range=range*multiplyer;
  range=MathRound(range);
  range=DoubleToStr(range,0);
  
 
//BODY VALUE==================================================

//Get the first bars body value

  bodytocheck=Open[k]>Close[k]?Open[k]-Close[k]:Close[k]-Open[k];
  multiplyer=Digits>=5?10000:100;
  bodytocheck=bodytocheck*multiplyer;
  bodytocheck=MathRound(bodytocheck);
  bodytocheck=DoubleToStr(bodytocheck,0);
   
 //Get the second bars body value
 
  body=Open[i]>Close[i]?Open[i]-Close[i]:Close[i]-Open[i];
  multiplyer=Digits>=5?10000:100;
  body=body*multiplyer;
  body=MathRound(body);
  body=DoubleToStr(body,0);
   
     
//WICK HIGH VALUE==================================================

//Get the first bars wick high value

  wickhightocheck=Open[k]>Close[k]?High[k]-Open[k]:High[k]-Close[k];
  multiplyer=Digits>=5?10000:100;
  wickhightocheck=wickhightocheck*multiplyer;
  wickhightocheck=MathRound(wickhightocheck);
  wickhightocheck=DoubleToStr(wickhightocheck,0);
   
 //Get the second bars wick high value
 
  wickhigh=Open[i]>Close[i]?High[i]-Open[i]:High[i]-Close[i];
  multiplyer=Digits>=5?10000:100;
  wickhigh=wickhigh*multiplyer;
  wickhigh=MathRound(wickhigh);
  wickhigh=DoubleToStr(wickhigh,0);
   
      
//WICK LOW VALUE==================================================

//Get the first bars wick low value

  wicklowtocheck=Open[k]>Close[k]?Close[k]-Low[k]:Open[k]-Low[k];
  multiplyer=Digits>=5?10000:100;
  wicklowtocheck=wicklowtocheck*multiplyer;
  wicklowtocheck=MathRound(wicklowtocheck);
  wicklowtocheck=DoubleToStr(wicklowtocheck,0);
   
 //Get the second bars wick low value
 
  wicklow=Open[i]>Close[i]?Close[i]-Low[i]:Open[i]-Low[i];
  multiplyer=Digits>=5?10000:100;
  wicklow=wicklow*multiplyer;
  wicklow=MathRound(wicklow);
  wicklow=DoubleToStr(wicklow,0);
   
 //print if there is a match or not
   
      if(rangetocheck==range && bodytocheck==body && wickhightocheck==wickhigh && wicklowtocheck==wicklow)
      {
      Alert("WE HAVE AN EXACT CANDLE MATCH");
      Alert("candle we are checking candle #  ",k," =  candle # ",i);
      Alert("");
  
      }
               
                           
//===========================================================
                           }  
                 
 //+------------------------------------------------------------------+
                           }
            
            

            
 

Please paste your code using the code button (Alt + S)

In future please post in the correct section

I will move this topic to the MQL4 and Metatrader 4 section.

 

Sorry that I forgot to post the code earlier. Now its updated. Please help.

tnx.

 
21hibrahim68: What I want to do next is to check all the currency pairs
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  2. Perhaps you should read the manual.
              ChartNext - Chart Operations - MQL4 Reference
 
21hibrahim68:
Im new to this forum. But I posted my script in my first post using Alt-s. I explained what the script does. I also explained what I want it to do next. I can see my script being posted on my end but perhaps its not seen from your end. 
Let me explain again here, if you cant see my script let me know.
When you run the script the dialog box appears and the user can change inputs for 2 things. 1 is bartocheck (this is  the # of the bar you want to compare with other bars, default is 1 the last closed bar). 2 is barstocheck (this is how many bars you want to compare with bartocheck). Than the script runs and checks to see if there is an exact match with the chosen bartocheck candle comparing range,body, wickhigh and wicklow. And alerts if there is an exact match and the index of the candle that is a match.
What I want to do now is to check all available symbols that are open on mt4 not just the chart that the script is run on.

So I wanted to know if there is a way to do this.

 
21hibrahim68:
Im new to this forum. But I posted my script in my first post using Alt-s. I explained what the script does. I also explained what I want it to do next. I can see my script being posted on my end but perhaps its not seen from your end. 
Let me explain again here, if you cant see my script let me know.
When you run the script the dialog box appears and the user can change inputs for 2 things. 1 is bartocheck (this is  the # of the bar you want to compare with other bars, default is 1 the last closed bar). 2 is barstocheck (this is how many bars you want to compare with bartocheck). Than the script runs and checks to see if there is an exact match with the chosen bartocheck candle comparing range,body, wickhigh and wicklow. And alerts if there is an exact match and the index of the candle that is a match.
What I want to do now is to check all available symbols that are open on mt4 not just the chart that the script is run on.

So I wanted to know if there is a way to do this.

Its weird its like there is a post thief.

I posted my code under the previous post but now its gone.

Weird forum this is.

 
The code is in the first post, so no need to post it again.
 
Keith Watford:
The code is in the first post, so no need to post it again.

Ok, I understand.

I posted it again because William said that I didn't post it. So I thought that it was not seen by others.

And also I'm not used to admin or anyone else going inside my post and erasing whatever they want. Its just weird to me.

I have been posting in FFactory for a long time, that never happened to me. What can happen is they will move the whole post into a different thread.

Reason: