I don't know what you are trying to achieve with your static variables. Doesn't seem logical to me
if(Close[1] > pendingBuyPrice) bool deleteSell = OrderDelete(gSellTicket,clrRed); if(Close[1] < pendingSellPrice) bool deleteBuy = OrderDelete(gBuyTicket,clrGreen);
You don't check whether the order has already been deleted or whether it has been triggered.
Before deleting the order check that gSellTicket>0 Check for a successful delete and then set the gSellTicket to 0 or -1
Personally, I would select the orders and check if gSellTicket is now an OP_SELL. If it is, you know that it has been triggered, so delete the other one
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
With the code below the instructions are as follows :
After 10 bars it opens both a buy and sell pending orders each 200 points from the close price at 10th bar. Then, when price closes higher than one of the pending order price points it closes the opposite order.
It places trades like I want no problems and compiles with no warnings or errors. But I have noticed on the MT4 journal it says OrderDelete error 4108 and unknown ticket 1 for OrderDelete function.
I cant see why it says this.