There is so much about trailing stops: https://www.mql5.com/en/search#!keyword=traling%20stop
Select one example and amend it according to your ideas.
-
if(OrderType() == ORDER_TYPE_BUY) buycnt++; if(OrderType() == ORDER_TYPE_SELL) sellcnt++;
OrderSelect loop only has pending orders. Position select loop has open positions. Your counts will always be zero.
-
if(OrderSend(symbol, ORDER_TYPE_BUY, volume, Ask, 0, 0, 0, NULL, magicNumber)){}
Invalid MT5 call. Invalid MT4 order type. MT5 has no predefined Ask.
-
Stop using ChatGPT.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)
-
OrderSelect loop only has pending orders. Position select loop has open positions. Your counts will always be zero.
-
Invalid MT5 call. Invalid MT4 order type. MT5 has no predefined Ask.
-
Stop using ChatGPT.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)
Using MT4 not MT5

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have created one dynamic trailing stoploss but it's only working in backtesting how can I modify it to live trading. Also can anyone check whether I am doing right or not