EA Running 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.

//+------------------------------------------------------------------+
//|                                                       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.

Hello,

in ' WeeklyBias' function the input parameter called 'input1' not 'DoW' as you use in function.

And is better to move 'Comment' operation in end of 'OnTick' function, because some parameter to uses in Comment got value after called function.