EA Not Working in Strategy Tester

 

I am using the Strategy Tester for the first time and just wanted to test a basic EA to get a feel for the function, but am having some trouble in getting my EA to actually work on there. 

I have downloaded the required data from the History Centre and have used the Strategy Tester to test the default EA's (MACD Sample, Moving Average) and it works absolutely fine on these two. I have also tried it on another extremely simple EA I made and it works fine on that too, which leads me to believe that the problem must be something to do with my actual code. 

When I select my EA and then start the test with identical settings... nothing happens.

The last message I get in the journal is "ADX System test started".

The screen just looks as it does below:

Here is the full code:

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
int Ticket;
int Error;
int Count;
datetime Bar_Time;
double plusDI;
double minusDI;
double ADX;
double Previous_ADX;
double ADXR;
double Coefficient;
double Barrier_Level;
double Resistance;
double Support;
double Open_Price;
double Stop_Loss;
double ADX_High=1000.0;
bool Long_Condition=false;
bool Closed=false;
bool Modified=false;
bool Unmodified;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   Coefficient   = GlobalVariableGet("Coefficient");
   Barrier_Level = GlobalVariableGet("Barrier_Level");
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//+------------------------------------------------------------------+
//| Whilst no orders open                                            |
//+------------------------------------------------------------------+  
   while(Ticket==0)
     {
      Refresh_Values(plusDI,minusDI,Previous_ADX,ADX,ADXR);

      if(ADX>ADXR && ADX>Barrier_Level && plusDI>minusDI)
        {
         if(Count<1)
           {
            Resistance     = High[1];
            Bar_Time       = Time[1];
           }
         Long_Condition=true;
         Count++;
        }

      if(ADX<=ADXR || ADX<=Barrier_Level || plusDI<=minusDI)
        {
         Long_Condition = false;
         Count          = 0;
        }

      if(Bar_Time!=Time[1] && Long_Condition==true && Close[1]>Resistance)
        {
         Bar_Time = Time[1];
         Ticket   = OrderSend(Symbol(),OP_BUY,0.1,Ask,2,0,0,NULL,1,0,clrBlue);
         if(Ticket>0)
           {
            if(OrderSelect(Ticket,SELECT_BY_TICKET)==true)
              {
               Open_Price=OrderOpenPrice();
               Alert("Order ",Ticket," successfully opened at ",Open_Price);
              }
           }
         else
           {
            if(Ticket<=0)
              {
               Error=GetLastError();
               Alert("Error ",Error," occured whilst trying to open trade");
              }
           }
        }
     }
//+------------------------------------------------------------------+      
//| Whilst order open                                                |                                             
//+------------------------------------------------------------------+   
   while(Bar_Time!=Time[1] && Ticket>0)
     {
      if(OrdersTotal()<1)
        {
         Alert("Order ",Ticket," has been closed via stop loss at ",OrderClosePrice());
         Ticket = 0;
         Count  = 0;
         break;
        }

      Refresh_Values(plusDI,minusDI,Previous_ADX,ADX,ADXR);

      if(ADX<ADXR)
        {
         Closed=OrderClose(Ticket,0.1,Bid,2,clrRed);
         if(Closed==true)
           {
            Alert("Order ",Ticket," successfully closed at ",OrderClosePrice());
            Ticket = 0;
            Count  = 0;
            break;
           }
         else
           {
            if(Closed==false)
              {
               Error=GetLastError();
               Alert("Order ",Ticket," cannot be closed due to error ",GetLastError());
              }
           }
        }

      if(ADX<Previous_ADX && Modified==false)
        {
         ADX_High  = Previous_ADX;
         Stop_Loss = Low[1]-(Point*10);
         Modified  = OrderModify(Ticket,Open_Price,Stop_Loss,0,0,clrNONE);
         if(Modified==true)
           {
            Alert("Stop loss added at ",Stop_Loss," on order ",Ticket);
            continue;
           }
         else
           {
            if(Modified==false)
              {
               Error=GetLastError();
               Alert("Order ",Ticket," cannot be modified due to error ",Error);
              }
           }
        }

      if(ADX>ADX_High && Modified==true)
        {
         Unmodified=OrderModify(Ticket,Open_Price,0,0,0,clrNONE);  // remove SL
         if(Unmodified==false)
           {
            Error=GetLastError();
            Alert("Stop loss cannot be removed on order ",Ticket," due to error ",GetLastError());
           }
         else
           {
            if(Unmodified==true)
              {
               Alert("Stop loss removed on order ",Ticket," due to ADX recovery");
               Modified=false;
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Values_Function                                                  |
//+------------------------------------------------------------------+
void Refresh_Values(double &PDI,double &MDI,double &P_ADX,double &C_ADX,double &C_ADXR)
  {
   PDI    =iCustom(NULL,1440," ADX & ADXR",Coefficient,Barrier_Level,0,1);
   MDI    =iCustom(NULL,1440," ADX & ADXR",Coefficient,Barrier_Level,1,1);
   P_ADX  =iCustom(NULL,1440," ADX & ADXR",Coefficient,Barrier_Level,2,2);
   C_ADX  =iCustom(NULL,1440," ADX & ADXR",Coefficient,Barrier_Level,2,1);
   C_ADXR =iCustom(NULL,1440," ADX & ADXR",Coefficient,Barrier_Level,3,1);
  }
//+------------------------------------------------------------------+

What is it I am doing incorrectly?

Reason: