Hi all,
Would like to share my strategy, very simple, nothing too complicated . Wanted to ask for feedback and any ideas of improvement.
Regards
Note: standard takeprofit and stoploss =100 points
For WS
takeprofit = 200 //takeprofit in points
stoploss = 200 //stoploss in points
For EU
takeprofit = 50 //takeprofit in points
stoploss = 50 //stoploss in points
DEFPARAM CumulateOrders = false // Acumulación de posiciones desactivada
units=10 //units to buy or sell
takeprofit = 100 //takeprofit in points
stoploss = 100 //stoploss in points
BreakevenAt = 25 //percent achieved of target to move stop to entry (breakeven)
PointsToKeep = 1 //how much points to keep in profit above of below our entry price when the breakeven is activated (beware of spread)
// Condiciones para entrada de posiciones largas
indicator1 = ExponentialAverage[30](close)
indicator2 = ExponentialAverage[60](close)
c1 = (indicator1 > indicator2)
indicator3 = ExponentialAverage[60](close)
c2 = (close < indicator3)
IF c1 AND c2 THEN
BUY units CONTRACT AT MARKET
SET STOP pTRAILING stoploss
ENDIF
// Condiciones de entrada de posiciones cortas
indicator6 = ExponentialAverage[30](close)
indicator7 = ExponentialAverage[60](close)
c4 = (indicator6 < indicator7)
indicator8 = ExponentialAverage[60](close)
c5 = (close > indicator8)
IF c4 AND c5 THEN
SELLSHORT units CONTRACT AT MARKET
SET STOP pTRAILING stoploss
ENDIF
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
startBreakeven = (BreakevenAt/100)*takeprofit //how much points in gain to activate the breakeven function
// --- BUY SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF LONGONMARKET AND breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
// --- SELL SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF SHORTONMARKET AND tradeprice(1)-close>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF SHORTONMARKET AND breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF
Thanks a lot! So that’s for the daily timeframe? Did you include spread, fees and backtested with tick-by-tick mode enable?
Hi, it works for 1 hour time frame, spread is NOT included, tick by tick YES. Check the difference in the attached picture.
I dont know why but today it didnt respect the stoploss at breakeven when I was long in Crude.
On simulation, no problem, the stoploss worked fine but not in real market. Any idea why?
Thanks
Manuel
The SET STOP pTRAILING might be the cause of the differences.