-
double execBuy = (Bid > smoothedMA && OrdersTotal() < 1); double execSell = (Ask < smoothedMA && OrdersTotal() < 1);
Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number/symbol filtering on your OrderSelect / Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum (2013)
PositionClose is not working - MQL5 programming forum (2020)
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles 2011You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.
-
OrderSend(NULL,OP_SELLSTOP,WJls3
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum (2020)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone.
I'm a beginner MQL4 programmer and I've been stuck for months solving this issue.
The code isn't really the cleanest as it is a chimera of all MQL4 knowledge that I took here in the forums but please bear with me.
If you try to run the code it should have one running order and multiple pending orders overlapping. I coded this reset feature that when the running order hits TP, it erases all pending orders. After testing it, when the running order hit its TP, the reset feature worked and erased all orders. BUT! The EA messes up the supposed next pending trades after its RESET!
Please try and run the code in MT4 to see what I'm talking about.
I am very much in need of help. Please help me solve the RESET issue of my code.