Hi all,
I want to open only one trade at the same bar. I use M5 timefrime. My EA opens trades according to some rules.
However, I want to open only one trade in a bar. Do you have any idea how I can do that?
Best wishes.
use a conditional ie only new trade when iTimeLastM5 < iTimeNewM5
use a conditional ie only new trade when iTimeLastM5 < iTimeNewM5
Hi rod178, Thank you for information. However, I don't understand exactly.
iTimeLastM5 < iTimeNewM5
What are the mean Last and New? About last trade and new trade?
if(mostRecentTradeTime() < Time[0]) //ok to trade.
Hi all,
I want to open only one trade at the same bar. I use M5 timefrime. My EA opens trades according to some rules.
However, I want to open only one trade in a bar. Do you have any idea how I can do that?
Best wishes.
Yes, try using this function:
bool CheckForNewBar() { static datetime PTime; datetime CTime = SeriesInfoInteger (Symbol(), Period(), SERIES_LASTBAR_DATE); if (PTime == 0) { PTime = CTime; return (false); } else if (PTime != CTime) { PTime = CTime; return (true); } else { return (false); } }
The first time it is called, it will always return False until the next bar. If this is not the desired behavior, you can remove the "PTime == 0" If-statement so that the function will return True the first time it is called. You could then place this function before your order opening code, and only one order will be placed per bar.
Yes, try using this function:
The first time it is called, it will always return False until the next bar. If this is not the desired behavior, you can remove the "PTime == 0" If-statement so that the function will return True the first time it is called. You could then place this function before your order opening code, and only one order will be placed per bar.
Thank you Shalem. Problem solved. Thnak you all!
Best.
Thank you Shalem. Problem solved. Thnak you all!
Best.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I want to open only one trade at the same bar. I use M5 timefrime. My EA opens trades according to some rules.
However, I want to open only one trade in a bar. Do you have any idea how I can do that?
Best wishes.