Cross – expert for MetaTrader 4

Simple code for Candle Cross above or below Conditions..

Mt5 version:- https://www.mql5.com/en/code/27597

Note: This is just a sample

Get E-Book Worth $100 for Free!!!

Main Function


bool   crossed[2];

//+------------------------------------------------------------------+
int OnInit()
  {
   for (int i = 0; i < ArraySize(crossed); i++)
      crossed[i] = true;
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnTick()
  {
//Your Buy condition
if(Cross(0,Open[0] > Condition))
     {

....//your conditions//...
     
     }

//Your Sell condition
if(Cross(1,Open[0] < Condition))
     {

....//your conditions//...
     
     }
  }
//+------------------------------------------------------------------+
bool Cross(int i, bool condition)
  {
   bool ret = condition && !crossed[i];
   crossed[i] = condition;
   return(ret);
  }


  • Recommended broker: icmarketsXM,  FXTM,  tickmill
  • 0/5 (0 Reviews)