datetime tradebartime; int start() { if(Time[0]!=tradebartime) { OrderSend( tradebartime=Time[0]; }
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.
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.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can anyone help to code this.
i wanted to limit 1 order in 1 bar. thanks