Hello anyone could help me with this issue?
sounds like a trail stop; albeit it is rather over complicated code.
But a suggestion to try: Move the code that you added, the line ending "Where I added my Modification", and the brackets; to be above the previous brackets, and below the line ending with "SYMBOL_BID"
Also note that most ppl are away on festivities.
Good that you are programming on your holidays, this should be an example for most.
First of all, you modify Position in the same time twice on the same tick, because you just sent the order in a queue.
Therefore I don't know if Editing PositionModify twice, will react to your second call. Look at the debugger of CTrade:
Second part is that use Print function to verify your call:
Not used bit, is a wasted bit:
My guess is that you can't call twice something which is a request to your broker.
The code is very complicated to read due to non standard variable names. You mix aesthetics of code.
Pick one, and stick to it, if you are lazy to put comments, use your variable names as comments, which will self explain what is happening, don't be scared to use long variable names.
camelCase or PascalCase or snake_case
Example camelCase:
First of all, you modify Position in the same time twice on the same tick, because you just sent the order in a queue.
Therefore I don't know if Editing PositionModify twice, will react to your second call. Look at the debugger of CTrade:
trade.LogLevel(2)
Does CTrade log in your debuger mentions your call twice of your PositionModify ?:
trade.PositionModify(_p_symbol,_new_sl,_p_tp) trade.PositionModify(_p_symbol,_new_sl,_p_tp)
Second part is that use Print function to verify your call:
//-- This function call returns boolean right? bool PositionModify( const string symbol, // symbol double sl, // Stop Loss price double tp // Take Profit price )
Not used bit, is a wasted bit:
if (trade.PositionModify(_p_symbol,_new_sl,_p_tp)) { Print("Return Code Test: ", trade,ResultRetcode()); }Return codes and their meaning: https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes
My guess is that you can't call twice something which is a request to your broker.
The code is very complicated to read due to non standard variable names. You mix aesthetics of code.
Pick one, and stick to it, if you are lazy to put comments, use your variable names as comments, which will self explain what is happening, don't be scared to use long variable names.
camelCase or PascalCase or snake_case
Example camelCase:
double positionSL = PositionGetDouble(POSITION_SL); double positionTP = PositionGetDouble(POSITION_TP); double positionPriceOpen = PositionGetDouble(POSITION_PRICE_OPEN);

Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
- www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

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
Here is the code Of Buy function only, please take a look.
Note:
A1 is StepSL_plus_breakeven; A2 is PlusPoints_breakeven;
B1 is StepSL_plus_breakeven1; B2 is PlusPoints_breakeven1;
Thank you so much for your time