How to limit 1 order in 1 bar?

 
Fellows members,
Can anyone help to code this.

 i wanted to limit 1 order in 1 bar. thanks
 
datetime tradebartime;
 
 
 
int start()
{
 
 
if(Time[0]!=tradebartime)
{
   OrderSend(
   tradebartime=Time[0];
}
 
irusoh1 wrote:
datetime tradebartime;
 
 
 
int start()
{
 
 
if(Time[0]!=tradebartime)
{
   OrderSend(
   tradebartime=Time[0];
}


Thanks irusoh1.

I've code using your method but it does not work because they are more than 1 tick in 1 bar.
 
The only way I can think of is to store the start time of each bar e.g...

void start()
{
static datetime bar_start_time = 0;
static bool order_sent = false;

if (Time[0] != bar_start_time)
{
bar_start_time = Time[0];
order_sent = false;
}

if (!order_sent)
{
OrderSend();
order_sent = true;
}
}

This (like a lot of things in MQL4) could be alot easyier if there was the concept of 'event callbacks' i.e. a function callback for the start of a new bar, or a trade close etc.
 

Thanks Irusoh1 and Craig. I used Irusoh1 code and Craig Memory Class 'static' to overcome ny issue. Thanks boaders.
Reason: