EA Brackout 9Am..... The problem is that he doesn't open sell positions for me in the backtest HELP ME

 
Good evening, I need help,
I built an EA that opens Buy or Sell if it breaks the night channel, this if it does not exceed 12 and if there are no open positions, also closes all positions at 11pm.

The problem is that he doesn't open sell positions for me in the backtest.
You can help me?

Here is the code:


double MassimoCanale;

double MinimoCanale;



int TicketBuy;

int TicketSell;



bool ContatoreCanale=true;

bool ContatoreOrdineLong=true;

bool ContatoreOrdineShort=true;



int OnInit()

  {

//---

   

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

if(Hour()==8) ContatoreOrdineLong=true;

if(Hour()==8) ContatoreOrdineShort=true;



    MemorizzaCanale(MassimoCanale,MinimoCanale);

    

    if(Ask>MassimoCanale && Hour()<12) EseguiOrdineLong();

    if(Bid<MinimoCanale && Hour()<12) EseguiOrdineShort();



    NoOverNight();



   

  }

//+------------------------------------------------------------------+







void MemorizzaCanale(double insMassimo, double insMinimo){



    if(Hour()==9 && Minute()<5 && ContatoreCanale){

    

       insMassimo=iHigh(Symbol(),PERIOD_CURRENT,iHighest(Symbol(),PERIOD_CURRENT,MODE_HIGH,10,1));

       insMinimo=iLow(Symbol(),PERIOD_CURRENT,iLowest(Symbol(),PERIOD_CURRENT,MODE_LOW,10,1));

       ContatoreCanale=false;

    

    }

    

    

    if(Hour()==8 && !ContatoreCanale) ContatoreCanale=true;

    

}









void EseguiOrdineLong(){





     if(Hour()>=9 && ContatoreOrdineLong){

     

         TicketBuy=OrderSend(Symbol(),OP_BUY,1,Ask,0,Ask-0.003,Ask+0.003,"ordine buy strategia canale notturno",0,0,0);

         

         if(TicketBuy<0){

         

           Print("Errore Ordine Buy: ",GetLastError());

         

         }

         else ContatoreOrdineLong=false;

         

         

     

    

     }

}



void EseguiOrdineShort(){





     if(Hour()>=9 && ContatoreOrdineShort){

     

         TicketSell=OrderSend(Symbol(),OP_SELL,1,Bid,0,Bid+0.003,Bid-0.003,"ordine sell strategia canale notturno",0,0,0);

         

         if(TicketSell<0){

         

           Print("Errore Ordine Sell: ",GetLastError());

         

         }

         else ContatoreOrdineShort=false;

         

         

     

    

     }

}





void NoOverNight(){



   if(OrdersTotal()>0 && Hour()==23){

   

   

       if(!OrderSelect(TicketBuy,SELECT_BY_TICKET,MODE_TRADES)){

          Print("Errore ordine select: ", GetLastError());       

       }

       

       if(OrderCloseTime()==0){      

         if(!OrderClose(OrderTicket(),OrderLots(),Bid,0,0)){

           Print("Errore ordine close: ", GetLastError());         

         }

      }

   

       if(!OrderSelect(TicketSell,SELECT_BY_TICKET,MODE_TRADES)){

          Print("Errore ordine select: ", GetLastError());       

       }

       

       if(OrderCloseTime()==0){      

         if(!OrderClose(OrderTicket(),OrderLots(),Ask,0,0)){

           Print("Errore ordine close: ", GetLastError());         

         }

      }   

   }

}



 
Use the </> button to insert your code.