Bad formulation

 

Good morning all

I have a problem with my code, I have checked my code and everything seems to be good .. but my code is not working as I want it to .. and I think maybe it is the code line at the bottom ..


I think that's it:

if (candle_Low1 <candle_Low2)

my code :

void OnTick()
  {      
      if(isnewbar()){
      double candle_Low1 = iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,1);
      double candle_Low2 = iMA(NULL,0,20,0,MODE_SMA,PRICE_LOW,2);     
      
      if(candle_Low1 < candle_Low2 && OrdersTotal () < 1){
       
        OrderSend(Symbol (),OP_SELL,LotSize,Bid,3,Bid + (StopLoss * Pips), Bid - (TakeProfit * Pips),NULL,MagicNumber,0,Red);
      }
      }
   }
  
  bool isnewbar(){
   if(Time[0] !=dt){
     dt = Time[0];
     return true;
   }
   return false;
   
   
   
}

What do you think of the code?


Thanks for your help and your time (I'm sure the problem is very simple but I can't see it ...)

Thomas

 
ThomasBrd51:

Good morning all

I have a problem with my code, I have checked my code and everything seems to be good .. but my code is not working as I want it to .. and I think maybe it is the code line at the bottom ..


I think that's it:

if (candle_Low1 <candle_Low2)

my code :

What do you think of the code?


Thanks for your help and your time (I'm sure the problem is very simple but I can't see it ...)

Thomas

Check your return codes

check this one with a Print 

isnewbar()
 
ffoorr:

Vérifiez vos codes de retour

vérifiez celui-ci avec une impression 

Hello,

I'm not sure I understood

How can I check is newbar ()?

Reason: