Attempting to Run EA on multiple pairs

 

Hello All,

I have been working on this EA that is to send alerts when at certain time of the day. It works on tester and will keep up with the days of rise and fall and send alerts based of what price had done previously.

basically when I run this EA on multiple pairs it doesn't keep up with the days for that any of the pairs and I am not sure why its not.

if someone would be so kind and look over the code and give some direction as to how I can write it to do what I am looking to do.

Going to try to add this topic one more time, not sure why it stay listed in the forum


//+------------------------------------------------------------------+
//|                                                       Algo_2.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property strict

//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
int      dayRF,HighCount,LowCount,cCount,lcnt,DoW;
double   oneDayH,oneDayL,oneDayC,twoDayH,twoDayL;
bool     dFirstTick=true,wFirstTick = true;
string   WeeklyTrend =  "",Trend ="";

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
  
//Daily Level Count  
int Level()
  {
/*
  Comment(
   "The High Count is: ",HighCount,"\n",
   "The Low Count is: ",LowCount,"\n",
   "The Day of RF: ",dayRF);
*/

if (TimeToString(TimeCurrent(),TIME_SECONDS)=="00:00:00" && dFirstTick )
  {
  //Print("inside if statement");
  dFirstTick = false;    
  iHigh(Symbol(),PERIOD_D1,1);
  iLow(Symbol(),PERIOD_D1,1);
  iClose(Symbol(),PERIOD_D1,1);
  twoDayH=iHigh(Symbol(),PERIOD_D1,2);
  twoDayL=iLow(Symbol(),PERIOD_D1,2);
 

   if (oneDayH > twoDayH && oneDayC > twoDayH)
      {
      LowCount = 0;
      HighCount++;
      Print("The Consecutive Day of Rise: ",HighCount);
      } else HighCount = 0;
      
      
   if (oneDayL < twoDayL && oneDayC < twoDayL)
      {
      HighCount = 0;
      LowCount--;
      Print("The Consecutive Day of Fall: ",LowCount);
      } else LowCount = 0;
      
   if (oneDayC > twoDayL && oneDayC < twoDayH)
      {
      LowCount = 0;
      HighCount = 0;
      cCount++;
      Print("Days of Consolidation Range: ",cCount);
      } else cCount = 0;
      
      
      if (HighCount > 0) dayRF=HighCount;
      else if (LowCount <  0) dayRF=LowCount;
      else if (HighCount == 0 && LowCount == 0) dayRF=0;
      else Print("Error");
      
  } 

  else if (TimeToString(TimeCurrent(),TIME_SECONDS)!="00:00:00") 
   {
   dFirstTick=true;
   } 

    return dayRF;    
  }
  
//Weekly Bias using 5 & 13 EMA cross  
string WeeklyBias(int input1)
{

if (DoW==1 && wFirstTick)
     {

         wFirstTick=false;
         
         double fiveEMA = iMA(Symbol(),PERIOD_W1,5,0,MODE_EMA,0,0);
         double thirteenEMA = iMA(Symbol(),PERIOD_W1,13,0,MODE_EMA,0,0);
         
         if(fiveEMA > thirteenEMA)
         {
         Trend="Buy";
         }
         
         if(fiveEMA < thirteenEMA)
         {
         Trend="Sell";
         }
         Alert("The Weekly Bias for ",Symbol()," is: ",Trend);
     } else if (DoW!=1 ) wFirstTick = true;
  return Trend;
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

     Comment(
     "The High Count is: ",HighCount,"\n",
      "The Low Count is: ",LowCount,"\n",
      "The Day of RF: ",dayRF,"\n",
      "TimeCurrent :",TimeCurrent(),"\n",
      "Day of Week :",DoW,"\n",
      "Weekly Trend :",WeeklyTrend,"\n",
      "Level :",Level(),"\n",
      "TimeToString: ",TimeToString(TimeLocal(),TIME_SECONDS),"\n");
   /*      */
   
      
     DoW=TimeDayOfWeek(TimeCurrent());
     WeeklyTrend=WeeklyBias(DoW);
     Level();
     
       
   if (TimeToString(TimeCurrent(),TIME_SECONDS)=="00:00:00")
   {
   if (Level()==0)
      {
      Alert(Symbol()," Market Consolidating Look for Stop Hunts in line with Weekly Bias");
      }
   
   else if(WeeklyTrend=="Sell")
      {
      if (Level()<0 && Level()>=-5)
         {
         Alert(Symbol()," Wait for Higher Sells ");
         }
      if (Level()==1 || Level()==2)
         {
         Alert(Symbol()," Look for Selling Opportunities");
         }
      if (Level()==3 || Level()==4 || Level()==5)
         {
         Alert(Symbol()," Extended Level Count High Probable Sell Trade Setups");
         }   
      }
      
   else if(WeeklyTrend=="Buy")
      {
      if (Level()>0 && Level()<=5)
         {
         Alert(Symbol(),"Wait for Lower Buys");
         }
      if (Level()==-1 || Level()==-2)
         {
         Alert(Symbol()," Look for Buying Opportunities");
         }
      if (Level()==-3 || Level()==-4 || Level()==-5)
         {
         Alert(Symbol()," Extended Level Count High Probable Buy Trade Setups");
         }
      } else Print("Error With Level");     
    } 
  }
 
Joe Ramirez:

Hello All,

I have been working on this EA that is to send alerts when at certain time of the day. It works on tester and will keep up with the days of rise and fall and send alerts based of what price had done previously.

basically when I run this EA on multiple pairs it doesn't keep up with the days for that any of the pairs and I am not sure why its not.

if someone would be so kind and look over the code and give some direction as to how I can write it to do what I am looking to do.

Going to try to add this topic one more time, not sure why it stay listed in the forum


Hello,

I make a quickly check in code and I found an issue.

In WeeklyBias function the input parameter called 'input1' not 'DoW' as you write.

And is better to move 'Comment()' operation end of 'OnTick()' function, because some parameters got prices after calling comments (like  WeeklyTrend, Dow, ..... and more).


string WeeklyBias(int input1)
{

if (input1==1 && wFirstTick)
     {

         wFirstTick=false;
         
         double fiveEMA = iMA(Symbol(),PERIOD_W1,5,0,MODE_EMA,0,0);
         double thirteenEMA = iMA(Symbol(),PERIOD_W1,13,0,MODE_EMA,0,0);
         
         if(fiveEMA > thirteenEMA)
         {
         Trend="Buy";
         }
         
         if(fiveEMA < thirteenEMA)
         {
         Trend="Sell";
         }
         Alert("The Weekly Bias for ",Symbol()," is: ",Trend);
     } else if (input1!=1 ) wFirstTick = true;
  return Trend;
}
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
Nikolaos Pantzos:

Hello,

I make a quickly check in code and I found an issue.

In WeeklyBias function the input parameter called 'input1' not 'DoW' as you write.

And is better to move 'Comment()' operation end of 'OnTick()' function, because some parameters got prices after calling comments (like  WeeklyTrend, Dow, ..... and more).


Thanks I originally had this in separate EA files that I called in case I wanted to use the pieces of the code in a different ea.

Not sure if the is the reason it wont work on multiple pairs when running live, the code works as intended when running in tester on 1 pair. But I will adjust and see if it works as intended on live.

Reason: