Zero Error Zero Warning EA failing to give results on the Strategy Tester! Help!

 

The code below is a simple (simple) moving average cross coupled with a pinbar, and yet im failing to get results on the strategy tester! Please help...

string Symb=Symbol();                       // Security name
//--------------------------------------------------------------- 2 --
int start()
  {  
   double
   pips,
   MA_gr,                                                         // 21 moving average
   MA_gl;                                                         // 55 moving average 
  
   bool   
   Opn_B=true,                                                   // Criterion for opening Buy
   Opn_S=true;                                                   // Criterion for opening Sell
   
    double close     =  iClose(NULL,PERIOD_M15,1),
           open      =  iOpen(NULL,PERIOD_M15,1),
           bodyrange =  MathAbs(iClose(NULL,PERIOD_M15,1)-iOpen(NULL,PERIOD_M15,1)),
           barrange  =  (iHigh(NULL,PERIOD_M15,1) - iLow(NULL,PERIOD_M15,1)),
           low       =  iLow(NULL,PERIOD_M15,1),                                  //for the buy pinbar                                 
           high      =  iHigh(NULL,PERIOD_M15,1);                                 //for the sell pinbar
           
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+

  {
//---
   double ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
   if (ticksize==0.00001 || ticksize==0.001)
      pips=ticksize*10;
      else pips=ticksize;
//---
   return(0);
  }
//-----------------------------------------------------------trading criteria

   MA_gr  = iMA(NULL,PERIOD_M15,21,0,MODE_SMA,PRICE_CLOSE,1); 
   MA_gl  = iMA(NULL,PERIOD_M15,55,0,MODE_SMA,PRICE_CLOSE,1); 
   
   if ((MA_gr > MA_gl) && ((open-close)<=(0.35*barrange) || (close-open)<=(0.35*barrange)) && (((close+open)/2)>((high+low)/2)) && (low < MA_gr))
            // 21&55sma cross on the m15, and definition of bullish pinbar which is in contact with the m15 21 sma
      {   
       Alert(" Potential buy for ", Symb);                                      
      Opn_B=true;                               
      }
      
   if ((MA_gr < MA_gl) && ((open-close)<=(0.35*barrange) || (close-open)<=(0.35*barrange)) && (((close+open)/2)<((high+low)/2)) && (high > MA_gr))
            // 21&55sma cross on the m15, and definition of bearish pinbar which is in contact with the m15 21 sma
      { 
      Alert(" Potential sell for ", Symb);                                         
      Opn_S=true;                               
      }
//-----------------------------------------------------------order accounting
 
 int total=OrdersTotal();                             //total referring to open orders
 
         if(total>0)
            {
               Alert(" With trade(s) already running,no new trade will be initiated..."); 
               return (0);                            //  logic order was changed so that if crit was met, a message would be displayed first before 
            }                                         //  an attempt was made to open a trade.....
            
//---------------------------------------------------------------size calculation

   double Prots=0.5;                                           //fraction of available margin to be risked
while(true)                               
     {
      double Min_Lot=MarketInfo(Symb,MODE_MINLOT);             // Min. volume
      double Step   =MarketInfo(Symb,MODE_LOTSTEP);            //Step to change lots
      double Free   =AccountFreeMargin();                      // Free Margin
      double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);     //Cost per 1 lot
      //-------------------------------------------------------------------- calc
      double Lot=MathFloor(Free*Prots/One_Lot/Step)*Step;// Lots
      if (Lot<Min_Lot)                        // If it is less than allowed
        {
         Alert(" Not enough money for ", Min_Lot," lots");
         break;                                 // Exit cycle
        }
      //-------------------------------------------------------------------- stop loss calc.
       double SLb=low - 10*pips;              // sl for buy
       double SLs=high + 10*pips;            // sl for sell
      
      //--------------------------------------------------------------------- take profit calc.
      double TPb=Bid + 2.1*(Bid-SLb);                  // tp for buy
      double TPs=Ask - 2.1*(SLs-Ask);                  // tp for sell
      
      //the risk/reward ratio is set at 1 : 2.1
      
//-----------------------------------------------------------------------opening orders
       if (total==0 && Opn_B==true)                               // reconfirming no new orders +
        {                                                         // criterion for opening Buy
        
        RefreshRates();
         Alert("Attempt to open Buy. Waiting for response..");
         int ticket=OrderSend(NULL,OP_BUY,Lot,Ask,3,SLb,TPb);            //Opening Buy
         if (ticket > 0)                                          // Success :)
           {
            Alert ("Opened order Buy ",ticket);
            return (0);                                           // Exit start()
           }
         
         return (0);                                              // Exit start()
        }
      if (total==0 && Opn_S==true)                                // No opened orders +
        {                                                         // criterion for opening Sell
         
         RefreshRates();         
         Alert("Attempt to open Sell. Waiting for response..");
         int ticket=OrderSend(NULL,OP_SELL,Lot,Bid,3,SLs,TPs);    //Opening Sell
         if (ticket > 0)                                          // Success :)
           {
            Alert ("Opened order Sell ",ticket);
            return (0);                                           // Exit start()
           }
        
         return (0);                                              // Exit start()
        }
      break;                                                      // Exit while
     }
//--------------------------------------------------------------- 9 --
   return (0);                                      // Exit start()
  }
 
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2.   bool
       Opn_B=true,                                                   // Criterion for opening Buy
       Opn_S=true;                                                   // Criterion for opening Sell
    :
       if ((MA_gr > ...){   
          Opn_B=true;                               
       }
       if ((MA_gr < ...){ 
          Opn_S=true;                               
       }
    When are these two variables ever false?


 
whroeder1:
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. When are these two variables ever false?


1. Sorry about that, I didn't know, I've updated it...

2. I wasn't sure how to run around with that logic to get the desired effect; in the initial declaration, can I make them false? Lemme try that... I appreciate the time taken to go through the lines...