NDTParticipant
Junior
Hi All,
I’ve created my first system using two moving averages and have been testing it on the DAX, IT40 and Japan 225.
The result I’m getting from the back tests are pretty good, since 2013, but I’m worried that I’m missing something and this system is to good too be true….
The code is below:
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FLATAFTER = 215500
// Conditions to enter long positions
indicator1 = ExponentialAverage[10](close)
indicator2 = ExponentialAverage[35](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 10 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = ExponentialAverage[10](close)
indicator4 = ExponentialAverage[35](close)
c2 = (indicator3 CROSSES UNDER indicator4)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator5 = ExponentialAverage[10](close)
indicator6 = ExponentialAverage[35](close)
c3 = (indicator5 CROSSES UNDER indicator6)
IF c3 THEN
SELLSHORT 10 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator7 = ExponentialAverage[10](close)
indicator8 = ExponentialAverage[35](close)
c4 = (indicator7 CROSSES OVER indicator8)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 6
Too good to be true, or is this system displaying good results?
What timeframe do you use?
With timeframe of 1 hour and a. Stop so short may not be real and the problem of zero bars
Yes i´m sorry but it´s too good to be true. A 6p trailing stop on such a high timeframe doesn’t´t work.
Test it in demo for a while and compare the results with the backtest
I tweaked it a bit and now it performs quiet well.
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FLATAFTER = 215500
n=5
m=19
// Conditions to enter long positions
indicator1 = ExponentialAverage[n](close)
indicator2 = ExponentialAverage[m](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 10 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = ExponentialAverage[n](close)
indicator4 = ExponentialAverage[m](close)
c2 = (indicator3 CROSSES UNDER indicator4)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator5 = ExponentialAverage[n](close)
indicator6 = ExponentialAverage[m](close)
c3 = (indicator5 CROSSES UNDER indicator6)
IF c3 THEN
SELLSHORT 10 PERPOINT AT MARKET
ENDIF
// Conditions to exit short positions
indicator7 = ExponentialAverage[n](close)
indicator8 = ExponentialAverage[m](close)
c4 = (indicator7 CROSSES OVER indicator8)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP ploss 180
set target pprofit 150
Ran the following code on japan 225 with good results.
Only problem is the draw down is too high
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM FLATAFTER = 215500
n=5
m=19
// Conditions to enter long positions
indicator1 = ExponentialAverage[n](close)
indicator2 = ExponentialAverage[m](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 1 contract AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = ExponentialAverage[n](close)
indicator4 = ExponentialAverage[m](close)
c2 = (indicator3 CROSSES UNDER indicator4)
IF c2 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
indicator5 = ExponentialAverage[n](close)
indicator6 = ExponentialAverage[m](close)
c3 = (indicator5 CROSSES UNDER indicator6)
IF c3 THEN
SELLSHORT 1 contract AT MARKET
ENDIF
// Conditions to exit short positions
indicator7 = ExponentialAverage[n](close)
indicator8 = ExponentialAverage[m](close)
c4 = (indicator7 CROSSES OVER indicator8)
IF c4 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP ploss 180
set target pprofit 150
NDTParticipant
Junior
Thank you so much everyone for your feedback and for adjusting the code! That’s so kind of you :).
I’m slightly confused though (pardon my ignorance here) but why are the back tests so mis-leading if in the real world they’re not really valid? And how can you determine if a system you’ve developed in actually going to work…?
Best wishes
WingParticipant
Veteran
In any backtest on the 10.2 version of PRT, trades that reach the SL and TP within the same bar that the trade is opened, will always count as a win. That is what can mislead you, which is why you must check for how many bars your trades in the backtest are held.
NDTParticipant
Junior
Thank you so much Eric and Wing! 🙂
It is flat after February no? Overfitting here I presume.