Hi guys! I'd like to code a trailingstop of basket's gain but until now i cann't. i wrote this code:
For example: i want my EA starts trailingstop when profitnow is bigger than 10$ (trailingstopbasketvalue):
- +2 bar: gain 12$ -> stop shouldbe set at 2$
- +1 bar: gain 13$ -> stop shouldbe set at 3$
- now: gain 11.5$ -> stop shouldbe set always at 3$ (max value reached (profitnow-trailingstop)
// profitnow = gain/loss of basket each tick
// TrailingStopBasketValue = vale of TrailingStop of basket where trailingstop starts
// stop= where EA should close all trades of basket
if (profitnow > TrailingStopBasketValue) {
if (stop<(profitnow-TrailingStop))stop=profitnow-TrailingStop;
}
if (profitnow < stop) CloseAllBasketTrades();
Someone can help me..... tnx u so much!
Regards
For example: i want my EA starts trailingstop when profitnow is bigger than 10$ (trailingstopbasketvalue):
- +2 bar: gain 12$ -> stop shouldbe set at 2$
- +1 bar: gain 13$ -> stop shouldbe set at 3$
- now: gain 11.5$ -> stop shouldbe set always at 3$ (max value reached (profitnow-trailingstop)
// profitnow = gain/loss of basket each tick
// TrailingStopBasketValue = vale of TrailingStop of basket where trailingstop starts
// stop= where EA should close all trades of basket
if (profitnow > TrailingStopBasketValue) {
if (stop<(profitnow-TrailingStop))stop=profitnow-TrailingStop;
}
if (profitnow < stop) CloseAllBasketTrades();
Someone can help me..... tnx u so much!
Regards