How to validate one order per candle?

 
Please help me, How to validate one order per candle?
 
sheriffonline:
Please help me, How to validate one order per candle?


How to help....   your code please ......  

what have you attempt....

what is failling.....

this has be discussed here many times   have you done searching ??... 

 

I am not sure if I guessed your intention correctly, but in case you are looking for a way to do something only once per candle (=> when the first tick that forms a new candle is received), this could be a way to do it:

#define DO_NOTING 0
#define DO_SOMETHING 1
#define DO_SOMETHING_ELSE 2

datetime lastExecDatetime;

int validateOrder() {
   if(isInSamePeriod(lastExecDatetime, TimeCurrent(), Period())) {
      return(DO_NOTING);
   } else {
        lastExecDatetime = TimeCurrent();
        
        // Place your validations here
           
        return(DO_SOMETHING);
   }
}

bool isInSamePeriod(datetime time1, datetime time2, int period) {
   int divider = period * 60;
   return(time1 / divider == time2 / divider);
}
 
lars.lamprecht:

I am not sure if I guessed your intention correctly, but in case you are looking for a way to do something only once per candle (=> when the first tick that forms a new candle is received), this could be a way to do it:

<CODE DELETED> 

Please read some other posts before posting . . .

Please   edit   your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 

 
Got it andfixed. thanks for the support here.
Reason: