Experts: Dynamic Trailing Stop Loss and Profit Target Management

 

Dynamic Trailing Stop Loss and Profit Target Management:

This code snippet implements a dynamic risk management strategy for existing trades. It focuses on closing trades based on profit or loss thresholds and employs a trailing stop loss to lock in profits as the trade moves favorably. The strategy helps manage risk and enhance profitability in a streamlined manner.

Dynamic Trailing Stop Loss and Profit Target Management

Author: Ohene Kofi Akuoku Osei

 
thank you.....
 

I'm super new here - first day, but for me this just doesn't work in MetaTrader5 (on Mac, anyway). I'm a software engineer so have tried to work out why - and I found the symbolInfo.Bid() returns 0.0. 

It turns out the correct fix (for me at least) is to use:

MqlTick tick;
if (SymbolInfoTick(_Symbol, tick))
{
   Print("Bid =", tick.bid, "Ask =", tick.ask);
}

... which does output the correct bid price, then the code starts working. Full updating working code is here (in case anyone is interested)...

Update to training stop mql5 file to make it work
Update to training stop mql5 file to make it work
  • gist.github.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 
simoncveracity #:

I'm super new here - first day, but for me this just doesn't work in MetaTrader5 (on Mac, anyway). I'm a software engineer so have tried to work out why - and I found the symbolInfo.Bid() returns 0.0. 

It turns out the correct fix (for me at least) is to use:

... which does output the correct bid price, then the code starts working. Full updating working code is here (in case anyone is interested)...

same probleme for me.
here is my fix :


   double ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   double bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
 
SFX
 
Hello, this EA is great, but it seems wrong. No matter how the parameters are set, the position will be closed as soon as there is an order. Please correct it, thank you!
 
Jason #:
Hello, this EA is great, but it seems wrong. No matter how the parameters are set, the position will be closed as soon as there is an order. Please correct it, thank you!

did you make the changes described in the messages earlier?

Reason: