Hello,
I was playing around a little with the breakeven-code posted on here (https://www.prorealcode.com/blog/learning/breakeven-code-automated-trading-strategy/) when i noticed that that I seem to have something wrong with my code.
As shown in the inserted printscreen of the backtest, the breakeven code gets activated once 30 points have moved in my favour, but once the price begins to move against me, the breakeven-code gets “removed” and it doesn’t sell on the set level for some reason, what am I doing wrong?
Regards,
Anton
breakeven = 30
keeppoints = 5
if not onmarket then
breakeven = 0
endif
IF LONGONMARKET AND close-tradeprice(1)>=Breakeven*pipsize THEN
breakeven = tradeprice(1)+keeppoints*pipsize
ENDIF
if breakeven > 0 then
sell at breakeven stop
endif
Graph breakeven as "be"
Try this. Not tested.
breakeven = 30
keeppoints = 5
if not onmarket then
flag = 0
endif
IF longonmarket and close - tradeprice >= Breakeven*pipsize THEN
flag = 1
endif
if flag then
sell at (tradeprice + keeppoints) stop
endif
That seems to be working, thank you!