Trading Signal Indicator Problem

 
int start()
{
   

  
   double EnterTrade0,EnterTrade1,Confirm0,Confirm1,ConfirmTrend0,ConfirmTrend1;
   
  
       EnterTrade0       =iCustom(NULL,0,"IdicatorA",ID1MA,a ,b,c,0,0);
       EnterTrade1       =iCustom(NULL,0,"IdicatorA",ID1MA,a ,b,c,0,1);

       Confirm0          = iCustom(NULL,PERIOD_M5,"IdicatorB",d, e,f,0,0);
       Confirm1          = iCustom(NULL,PERIOD_M5,"IdicatorB",d, e,f,0,1);
          
        ConfirmTrend0    = iCustom(NULL,PERIOD_M15,"IdicatorB",g, h,i,,0,0);
       ConfirmTrend1     = iCustom(NULL,PERIOD_M15,"IdicatorB",g, h,i,,0,1);


                   
                  BuyEntry    = (EnterTrade0 > 0 && EnterTrade1 <= 0 && Confirm0 > 0 && Confirm0 > Confirm1 && ConfirmTrend0 > 0 && ConfirmTrend0 > ConfirmTrend1 );  
                   SellEntry  = (EnterTrade0 < 0 && EnterTrade1 >= 0 && Confirm0 < 0 && Confirm0 < Confirm1 && ConfirmTrend0 < 0 && ConfirmTrend0 < ConfirmTrend1 );
    
    
                      if(BuyEntry && (GlobalVariableGet(GlobalTradeDirection) == 2.0  || GlobalVariableGet(GlobalTradeDirection) == 0.0))
                    { 
                       
                       GlobalVariableSet(GlobalTradeDirection, 1.0);
                        Trend="Buy";   
                      
                     }
                  else if(SellEntry && (GlobalVariableGet(GlobalTradeDirection) == 1.0  || GlobalVariableGet(GlobalTradeDirection) == 0.0))
                    {
                        GlobalVariableSet(GlobalTradeDirection, 2.0);
                        Trend="Sell";  
                     }
                     
                  if(GlobalVariableGet(GlobalTradeDirection) == 0.0)
                     Trend="None";    
                     
          ShowData=StringConcatenate(         "     Current Trend : ",Trend,"\n");             
          
          ShowData=StringConcatenate(ShowData,"     EnterTrade0 : ",EnterTrade0," EnterTrade1 : ",EnterTrade1,"\n") ;  
          ShowData=StringConcatenate(ShowData,"     Confirm0 : ",Confirm0,"    Confirm1 : ",Confirm1,"\n") ;  
          ShowData=StringConcatenate(ShowData,"     ConfirmTrend0 : ",ConfirmTrend0," ConfirmTrend1 : ",ConfirmTrend1,"\n") ;     
          Comment(ShowData );
                             
                                       

   return(0);
}



I want make signal  indicator as inside code above.

But when I ran backtest I think there is something wrong with this code that make false signal with other timeframe indicator.

The current timeframe indicator the value is ok, But Period M5 and M15 indicator have  strange value.

Anybody please fix it for me or recommend me.


Thank you in advance.

Reason: