Yes I did. The drawdown I have now is coming from when the price is consolidation around the moving average. Hopefully the system is better on a longer history now.
Yes, it’s a better now. 200k bars test attached.
Nice. Still not super good until the more volatile market starts in 2015. I added one more short term moving average (100 periods). It didn’t improve the return on the 2 year timeframe I have but it did lower the draw down which is visible on the gain/loss ratio. Backtest with 2p spread.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = TEMA[10](close)
indicator2 = SuperTrend[3,10]
c1 = (indicator1 >= indicator2)
indicator3 = CCI[20]
c2 = (indicator3 CROSSES OVER -100)
indicator4 = SuperTrend[3,10]
indicator5 = Average[2200](close)
c3 = (indicator4 > indicator5)
indicator6 = TEMA[10](close)
indicator7 = Average[100](close)
c4 = (indicator6 > indicator7)
IF (c1 AND c2 AND c3 AND c4) AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator8 = CCI[20]
c5 = (indicator8 CROSSES UNDER 100)
IF c5 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator9 = TEMA[10](close)
indicator10 = SuperTrend[3,10]
c6 = (indicator9 < indicator10)
indicator11 = CCI[20]
c7 = (indicator11 CROSSES UNDER 200)
indicator12 = TEMA[10](close)
indicator13 = Average[2200](close)
c8 = (indicator12 < indicator13)
indicator14 = TEMA[10](close)
indicator15 = Average[100](close)
c9 = (indicator14 < indicator15)
IF (c6 AND c7 AND c8 AND c9) AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator16 = CCI[20]
c10 = (indicator16 CROSSES OVER -200)
IF c10 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP %LOSS 0.8
Better is worse than good. Too much filtering reduce trades (almost 30% less for a limited increase in gain in my 200k bars test) and also statistics about robustness. It’s always difficult to be sure of what is a good filter or not. That’s why you should only make backtest with In Sample and Out Of Sample period, like I explain in this blog article: https://www.prorealcode.com/blog/avoid-equity-curve-fitting-with-probacktest-trading-strategy-optimisation/
(it talks about optimisation, but the idea is the same for a normal backtest).
Try to improve the strategy on IS period with as much ideas you can imagine. Then test the strategy on OOS period to see if it has improved the strategy result in the “future”, like if you were trading the strategy in real time. If the answer is “yes”, then your new ideas may be considered to be a good ones.
Fair point! I have to start doing the OOS test you mention in your blog article. Very well written btw! On that point, do you know why the walk forward settings are not visible on my platform (v10.3)? (I have attached a picture of my screen).
Walk Forward will be available to IG customers within the next weeks. It’s only available now for prorealtime trading customers.
@ nicolas , could you post here the backtest on 200 k bars please .
This is the latest update I have on the code. Now without the longer moving average which excluded a large amount of trades. All values have been selected by the optimisation function in PRT, apart from the stop loss which was suggested to be 1.05. In my opinon were the increase of risk greater than the increase of return. I have not yet tested on an OOS period.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
// Conditions to enter long positions
indicator1 = CCI[20]
c1 = (indicator1 CROSSES OVER -100)
indicator2 = TEMA[18](close)
indicator3 = SuperTrend[3,10]
c2 = (indicator2 > indicator3)
indicator4 = TEMA[18](close)
indicator5 = Average[130](close)
c3 = (indicator4 > indicator5)
IF (c1 AND c2 AND c3) AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator6 = CCI[20]
c4 = (indicator6 CROSSES UNDER 200)
IF c4 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator7 = TEMA[18](close)
indicator8 = SuperTrend[3,10]
c5 = (indicator7 < indicator8)
indicator9 = CCI[20]
c6 = (indicator9 CROSSES UNDER 170)
indicator10 = TEMA[18](close)
indicator11 = Average[130](close)
c7 = (indicator10 < indicator11)
IF (c5 AND c6 AND c7) AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator12 = CCI[20]
c8 = (indicator12 CROSSES OVER -160)
IF c8 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP %LOSS 0.8
You should have optimised on 70% of history (IS) and test if it was correct on the last 30% by yourself (OOS) 🙂
haha, why didn’t I think of that myself.. thanks a lot Nicolas!
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
once ordersize=1
if Ordersize>18 then
Ordersize=18
endif
// Riesgo, multiplicador de contratos.
n=1
// Conditions to enter long positions
indicator1 = CCI[20]
c1 = (indicator1 CROSSES OVER -100)
indicator2 = TEMA[18](close)
indicator3 = SuperTrend[3,10]
c2 = (indicator2 > indicator3)
indicator4 = TEMA[18](close)
indicator5 = Average[130](close)
c3 = (indicator4 > indicator5)
IF (c1 AND c2 AND c3) AND not daysForbiddenEntry THEN
IF PositionPerf(1) < 0 THEN
OrderSize = OrderSize/2//+1
if ordersize 0 THEN
OrderSize =OrderSize+2
endif
BUY ordersize*n shares AT MARKET
ENDIF
// Conditions to exit long positions
indicator6 = CCI[20]
c4 = (indicator6 CROSSES UNDER 200)
IF c4 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator7 = TEMA[18](close)
indicator8 = SuperTrend[3,10]
c5 = (indicator7 < indicator8)
indicator9 = CCI[20]
c6 = (indicator9 CROSSES UNDER 170)
indicator10 = TEMA[18](close)
indicator11 = Average[130](close)
c7 = (indicator10 < indicator11)
IF (c5 AND c6 AND c7) AND not daysForbiddenEntry THEN
iF PositionPerf(1) < 0 THEN
OrderSize = OrderSize/2//+1
if ordersize 0 THEN
OrderSize =OrderSize+2
ENDIF
SELLSHORT ordersize*n shares AT MARKET
ENDIF
// Conditions to exit short positions
indicator12 = CCI[20]
c8 = (indicator12 CROSSES OVER -160)
IF c8 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP %LOSS 0.8
just code your code with accumalation , here it is the backtest with 1 € per contract
I wouldn’t recommend this. Better to have several systems which you size up simultaneously.