davidb012: (Alternative I guess, would be to create some kind of static flag, updated when an order is opened to indicate order type.
EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV/file) of ticket numbers required.
WHRoeder:
EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV/file) of ticket numbers required.
EA's must be coded to recover. If the power fails, OS crashes, terminal or chart is accidentally closed, on the next tick, any static/global ticket variables will have been lost. You will have an open order but don't know it, so the EA will never try to close it, trail SL, etc. How are you going to recover? Use a OrderSelect loop to recover, or persistent storage (GV/file) of ticket numbers required.
Yes, that's what I feared about having a static flag, rather than an OrderSelect loop.
So, just trying to figure out how to efficiently search through both open and closed orders (MODE_TRADES and HISTORY)

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
Hi,
I'm trying to code to find whether the last order was a buy or a sell. Seems simple.
My typical code would be:
Unfortunately, I had ignored the fact that the last order may by now have been closed, and would not be found in the pool MODE_TRADES, but in HISTORY.
How can I efficiently look through both open and closed trades, to find whether the last opened order was a Buy or Sell?
(Alternative I guess, would be to create some kind of static flag, updated when an order is opened to indicate order type. Is this a better solution?) .
Any suggestions appreciated