Have, as you know, worked on an algo that has taken many trads / day.
Do not believe in an complicated code, then there will be fewer trads.
Here is a simple code that takes 5 trads / day with low DD.
I haven’t tested it with WF.
It’s probably a bit over op.
An idea anyway.
Spread=1
DEFPARAM CumulateOrders=false
defparam flatbefore =090000
defparam flatafter = 180000
// Conditions to enter long positions
indicator1 = Average[20](close)
indicator2 = Average[50](close)
c1 = (indicator1 CROSSES OVER indicator2)
indicator100 = close
indicator101 = Supertrend[5,4]
c100 = indicator100 > indicator101
IF c1 and c100 THEN
BUY 1 CONTRACT AT MARKET
endif
//************************************************************************
// TSL trailing stop function
//************************************************************************
//************************************************************************
//trailing stop function
trailingstart = 17// 20trailing will start @trailinstart points profit
trailingstep = 5// 5trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
set stop ploss 17
Love the principle … we think alike! 🙂
Love that staircase equity curve!
Will it make any money? Easy to find out … I will Forward Test on Demo!
I let you know if I make any improvements.
Thank You
Hi Bullbear,
Very interesting system, thanks for sharing. Have you tried similar algo for short positions ?
I will run it in demo and let you know if I find any solution to improve it !
@Lifen
I did a similar for short positions.
Uses the same trailing as for long positions with the same settings.
All in order not to over-optimize.
It doesn’t look very funny, but still it makes 136 € in 10 days.
Think it is next to impossible to manage to get an algo with such a short TF.
You probably have to optimize about it very often if you are going to make it work.
Will run it on demo for the week to com.
Who knows the two might complement each other?
You should probably not have too high hopes 🙂
DEFPARAM CumulateOrders=false
defparam flatbefore =090000
defparam flatafter = 180000
// Conditions to enter long positions
indicator1 = Average[70](close)
indicator2 = Average[80](close)
c1 = (indicator1 CROSSES UNDER indicator2)
indicator100 = close
indicator101 = Supertrend[4,11]
c100 = indicator100 > indicator101
IF c1 and c100 THEN
sellshort 1 CONTRACT AT MARKET
endif
//************************************************************************
// TSL trailing stop function
//************************************************************************
//************************************************************************
//trailing stop function
trailingstart = 17// 20trailing will start @trailinstart points profit
trailingstep = 5// 5trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
set stop ploss 17
thanked this post
@bullbear
Thanks for the code for short position. I will run long and short algo in demo for the coming Week and will see if we can make any improvements.
Will keep you informed. Should be better if we would have a higher TF but who knows…
Did a 3 min DAX algo instead of getting some more data to do backtest on.
WF is also made.
thanked this post
Long
DEFPARAM CumulateOrders=false
defparam flatbefore =090000
defparam flatafter = 180000
// Conditions to enter long positions
indicator1 = Average[10](close)
indicator2 = Average[50](close)
c1 = (indicator1 CROSSES OVER indicator2)
indicator100 = close
indicator101 = Supertrend[7,1]
c100 = indicator100 > indicator101
IF c1 and c100 THEN
BUY 1 CONTRACT AT MARKET
endif
//************************************************************************
// TSL trailing stop function
//************************************************************************
//************************************************************************
//trailing stop function
trailingstart = 19// 20trailing will start @trailinstart points profit
trailingstep = 1// 5trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
set stop ploss 24
Short
//-------------------------------------------------------------------------
// Main code : MySystem(30)
//-------------------------------------------------------------------------
DEFPARAM CumulateOrders=false
defparam flatbefore =090000
defparam flatafter = 180000
// Conditions to enter long positions
indicator1 = Average[70](close)
indicator2 = Average[100](close)
c1 = (indicator1 CROSSES UNDER indicator2)
indicator100 = close
indicator101 = Supertrend[7,13]
c100 = indicator100 > indicator101
IF c1 and c100 THEN
sellshort 1 CONTRACT AT MARKET
endif
//************************************************************************
// TSL trailing stop function
//************************************************************************
//************************************************************************
//trailing stop function
trailingstart = 20// 20trailing will start @trailinstart points profit
trailingstep = 17// 5trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
set stop ploss 44