Only open one pending order while bar is still open
I’m working on an EA that opens a pending order once specific criteria is met. I have it analyzing the current open bar to ensure precise entry, as sometimes the criteria does not get met until mid-way into the current bar. I am getting it to work, however, upon doing some backtesting it looks to open thousands of pending orders (canceling the previous one every time) until the stop price is met. Then once the order is actually placed, if the current bar is still open, it attempts to open new pending orders for the same criteria. It is not successful at opening the additional order(s) because the magic number for the order is already in a trade (Which is what it should do) Obviously this would tax the resources of a machine if I have this same EA running on several different pairs which meet the criteria at similar times.
I have used the check mark on “evaluate rule on bar open only” and the EA works as I want it to with only entering the one order, but only if the criteria is met at the time the bar opens. Using this makes me miss out on some potentially good trades.
My question is, how can I get the EA to only place one pending order per open bar? Then not have it look to place any additional pending orders during that current bar as well without having to check the bar open only checkbox?
Thank you in advance!
You can force EA to do something only at bar open when you use condition like shown on screen even without checking ‘evaluation on bar open only’
Yes, I am aware of that condition, however, this will not solve my problem as it will still only check at bar open, not mid-way thru bar formation. I want the EA to keep checking after bar open but then stop looking once criteria is met and pending order is placed.
I have situation like you too before, and finally find the solution :
Use this in condition -> “OrderOpenedThisBar” –> is not –> True ( Its return to true when order with magic number opened at current bar)
“OrderClosedThisBar” –> is not –> True ( Its return to true when order with magic number closed at current bar)
Viewing 4 posts - 1 through 4 (of 4 total)