I seem to be having a problem. I have written the code needed to select the last pending order that has opened, upon opening I use PlaySound(). Now, it seems to keep selecting that order every new candle and playing the sound. Is there any filter that I can use to make the EA select it once only upon the order being opened, then play the sound once?
Any help is appreciated.
static int last_pending_order=0;
//Code to select the last pending order
//Code to send alert/play sound
You need to chek number of orders of buy sell buystop...
When pending order will be less then in previous candle(tick),it means that he was opened.
I seem to be running into a brick wall here.. My code works perfectly while back testing, but forward testing it gives invalid lots, invalid take profit and stop loss. This is my logic, and perhaps you could help?
//If pending order is opened send another order
Is my logic incorrect somewhere? Like I say, it works perfectly in back testing but live it gives OrderSend() errors for the second OrderSend(). I have tried using NormalizeDouble() but it still does the same thing.
Not enough information to guess what the problem may be.
Is pending order a buy or sell?
what lostsize , SL and TP is the order using, do you check if an order send fails?
There should be no need to Normalize lotsize unless you do calculations to get the lotsize value. Then you should normalize by checking that it is an exact multiplication of lotstep. I don't know what happens if you normalize a lot size with Digits as most lot sizes are 2 decimal places.
I don't see any code to place the initial pending order
Any orders placed manually or by another EA on the same pair will interfere with the logic.
if(Open<Close || Open==Close)
//Can be replaced with
I normalized the lot size simply because it was giving that error, so I thought I could just normalize it.
if(selli<0) Print("Failed to place Sell order, error#",GetLastError());
This triggers the buy stop order..
To add comments, please log in or register