Money management logic behind trailing stop code

 

Hi, I don't know how to use trailing stop correctly or at least in the most optimized way. Let's talk theoretically. The symbol price is 1.200, I have both SL and TP at 10pips. Pseudo code of my trailing stop code goes something along these lines: 


int start() {

if condition has been met

BUY

TrailBuy()


if other condition has been met

SELL

TrailSell()

}


TrailBuy() {

if price moves up 1 pip

move both SL and TP up 1pip

}


TrailSell() {

if price moves down 1 pip

moves both SL and TP down 1 pip

}


That doesn't seem to work as I want it to. I've tried leaving the original TP level the same and only minimizing SL level or many other way but it doesn't seem to handle money management well. If SL and TP move as the price moves, it's true the SL IS IN FACT smaller but TP is bigger then and it doesn't get hit. Can you suggest the best way to work with trailing stop so that I actually maximize my profits and minimize losses.

 
flbroker:

Hi, I don't know how to use trailing stop correctly or at least in the most optimized way. Let's talk theoretically. The symbol price is 1.200, I have both SL and TP at 10pips. Pseudo code of my trailing stop code goes something along these lines: 


int start() {

if condition has been met

BUY

TrailBuy()


if other condition has been met

SELL

TrailSell()

}


TrailBuy() {

if price moves up 1 pip

move both SL and TP up 1pip

}


TrailSell() {

if price moves down 1 pip

moves both SL and TP down 1 pip

}


That doesn't seem to work as I want it to. I've tried leaving the original TP level the same and only minimizing SL level or many other way but it doesn't seem to handle money management well. If SL and TP move as the price moves, it's true the SL IS IN FACT smaller but TP is bigger then and it doesn't get hit. Can you suggest the best way to work with trailing stop so that I actually maximize my profits and minimize losses.

I prefer only trailing SL, not trailing TP

Another way is using Break Even, sometimes more secure than trailing.

Btw, each option has advantages and disadvantages depending on the strategy used.

 

If you're asking specific mql4 code then you can ask them in mql4 forum https://www.mql5.com/forum/en.

This topic is risk to be deleted.

MQL4: automated trading forum
  • www.mql5.com
MQL4: automated trading forum
Reason: