ProRealCode - Trading & Coding with ProRealTime™
Hey dajvop,
there is nothing you did wrong. It seems to be caused by the starting date of the backtest. if you change it to another date is shows a better restult. e.g. 01.09.2012 (the time change that you made should make no changes, because the times the system makes trades is at 9:00, 13:00, 17:00 and 21:00)
but I cannot say why there are these differences.
maybe the calculation of the high and low points depends on the starting date?
Hope I was able to help.
mfg
Flo
Changed starting date to 1 sept 2012 and got 136 trades (+118/-18) instead. Mighty strange if you ask me 🙂
How is one supposed to backtest properly if a date change of 2 days has that kind of impact?
Regards, David
We noticed such errors of the backtests previously (a few pages before), especially around the 29/12/2015-03/01/2016: the results are quite differents for all the following trades of the year, which is absurd. We have no explanations.
Hi Renier,
can you post in a excel the optimization variable for seasonal pattern of your daily comparison?
Do you test one by one the month for optimization or all together?
Thanks in advance
Hi Flo,
Thanks for your contribution. Your backtest is really good and I like that you follow my recommendation to focus on the drawdown. I recommend to increase takeProfitShort from 0.5 to 1.5 because the system could make more money on the short side with the same drawdown. Please keep in mind that the parameter settings should also cover different future scenarios. Your saisonal adjustments are good for the last 7 years and you did a perfect job. With the help of Pathfinder DOW daily we can now compile saisonal adjustments for the last 37 years and this information is very valuable. Based on your work I made some optimizations and I have tried to harmonize the settings with the longterm saisonal pattern. Overall this approach provides more robust parameter settings and especially show the potential risks (e.g. June and September).
// shortterm//longterm, ok - same or smaller value, chance - same direction but more aggressive, risk - be careful because of the past
ONCE January1 = 1//0 risk(1)
ONCE January2 = 3//2 chance
ONCE February1 = 2//1 chance
ONCE February2 = 2//0 risk(2)
ONCE March1 = 2//0 risk(2)
ONCE March2 = 3//2 chance
ONCE April1 = 3//3 ok
ONCE April2 = 3//3 ok
ONCE May1 = 0//3 ok
ONCE May2 = 0//0 ok
ONCE June1 = 3//0 risk(3)
ONCE June2 = 3//0 risk(3)
ONCE July1 = 1//1 ok
ONCE July2 = 1//1 ok
ONCE August1 = 0// ok
ONCE August2 = 0// ok
ONCE September1 = 3//0 risk(3)
ONCE September2 = 3//0 risk(3)
ONCE October1 = 0//0 ok
ONCE October2 = 3//3 ok
ONCE November1 = 0//0 ok
ONCE November2 = 3//3 ok
ONCE December1 = 3//3 ok
ONCE December2 = 3//2 chance
Please find attached Pathfinder DOW 4H V6 and Pathfinder DOW daily V2
Best, Reiner
Hi sylvess,
as long as not all Pathfinder pieces are together I prefer to have everything in one topic. This forum is so much more as this little breakout algo and I don’t want bother the other users with 20 Pathfinder topics. Maybe we split later in different subtopics but not yet.
Best, Reiner
Salve AleX,
I just reworking all Pathfinder daily versions and will publish all infos soon.
I described the optimization approach here http://www.prorealcode.com/topic/pathfinder-trading-system/page/33/#post-19123
Last step is to set all saisonal adjustments to 0 and start with January and optimize with two variables every month in the range of 0-3 focused on the drawdown value.
ONCE January1 = x
ONCE January2 = y
ONCE February1 = 0
ONCE February2 = 0
ONCE March1 = 0
ONCE March2 = 0
ONCE April1 = 0
ONCE April2 = 0
ONCE May1 = 0
ONCE May2 = 0
ONCE June1 = 0
ONCE June2 = 0
ONCE July1 = 0
ONCE July2 = 0
ONCE August1 = 0
ONCE August2 = 0
ONCE September1 = 0
ONCE September2 = 0
ONCE October1 = 0
ONCE October2 = 0
ONCE November1 = 0
ONCE November2 = 0
ONCE December1 = 0
ONCE December2 = 0
move to next month and so on
ONCE January1 = 0
ONCE January2 = 2
ONCE February1 = x
ONCE February2 = y
ONCE March1 = 0
ONCE March2 = 0
ONCE April1 = 0
ONCE April2 = 0
ONCE May1 = 0
ONCE May2 = 0
ONCE June1 = 0
ONCE June2 = 0
ONCE July1 = 0
ONCE July2 = 0
ONCE August1 = 0
ONCE August2 = 0
ONCE September1 = 0
ONCE September2 = 0
ONCE October1 = 0
ONCE October2 = 0
ONCE November1 = 0
ONCE November2 = 0
ONCE December1 = 0
ONCE December2 = 0
Saluti, Reiner
Hi
I tried to do the job for Natural Gas (NG), but I only have few months back..
Is it the same for everyone?
@ Reiner In Pathfinder-DOW-4H-V6 I notice a huge drawdown in the period starting from 29-Jan ending 12-Feb. Profits sinked from 22606 to 18002.Is it my mistake? Regards, Massimo
Salve Massimo,
all Pathfinder 4H systems require 24 hours quoting (6 candles per day). For the DOW these feature is available since April 2010. Backtests before this date doesn’t work with the default parameter setup.
Saluti, Reiner
Hi traderfred,
Here you will find the Pathfinder NG daily version V2 with data history start from 1990.
http://www.prorealcode.com/topic/pathfinder-trading-system/page/34/#post-19171
Best, Reiner
Hi Reiner,
Thanks a lot.
I will use it..The question was also in order to see if I’m able to make the optimization 🙂
Other question: I’m running DAX 4H V6 on backtest. (next week live!) Positions are currently open (from 21st and 23th of december) Is it correct?
Best regards,
Fred
Hi Reiner. I’m still trying to make a more conservative version of DAX 4H v6. I wrote about the risk before, also someone asked about a ver. for a small account. I saw you suggested a max 3 positionsize ver. I tested many variation of v6 code but since the positionsize is not linear I can’t find a solution that would go all the way including a money management code. I discovered that simplify the original code to only maxpositionsize=3 it also cut more on the gain side. So perhaps a new optimisation was needed? I multiplied the DD with 2 and added 1K for margin if the 3 positions. So this should be for a 4k account. Downside is that the DD is still more or less same as the V6 but the gain is only half. On the good side, it only risk a third of the orginal V6.- it has max 2 consecutive loss and 22 wins since July 2009
I tried to do the optimisation, and this was what I came up with. I’d like you comments if you think it’s optimized correct or not since this is my first optimisation try for you code 🙂
I have added a comparison screenshoot of the orginal V6 with max 3 positionsize and the new optimized V6b5
cheers Kasper
// Pathfinder Trading System based on ProRealTime 10.2
// Breakout system triggered by previous daily, weekly and monthly high/low crossings with smart position management
// Version 6.5 MM Elsborgtrading Live ver
// Instrument: DAX mini 4H, 9-21 CET, 2 points spread, account size 10.000 Euro, from August 2010
// ProOrder code parameter
DEFPARAM CUMULATEORDERS = true // cumulate orders if not turned off
DEFPARAM PRELOADBARS = 10000
// define intraday trading window
ONCE startTime = 90000
ONCE endTime = 210000
// define instrument signalline with help of multiple smoothed averages
ONCE periodFirstMA = 5
ONCE periodSecondMA = 10
ONCE periodThirdMA = 3
// define filter parameter
ONCE periodLongMA = 300
ONCE periodShortMA = 50
// define position and money management parameter
ONCE positionSize = 1
Capital = 4000
Risk = 5 // in %
equity = Capital + StrategyProfit
maxRisk = round(equity * Risk / 100)
ONCE stopLossLong = 5.5 // in %
ONCE stopLossShort = 3.25 // in %
ONCE takeProfitLong = 3.25//x1//3.25 // in %
ONCE takeProfitShort = 3.5//x2//3.25 // in %
reinvest =1
if reinvest then
positionSize=max(round((equity+Capital)/(capital*10)),1)
maxPositionSizeLong = MAX(positionSize+2, abs(round(maxRisk / (close * stopLossLong / 100) / PointValue) * pipsize))
maxPositionSizeShort = MAX(positionSize+2, abs(round(maxRisk / (close * stopLossShort / 100) / PointValue) * pipsize))
else
positionSize=1
maxPositionSizeLong = MAX(15, abs(round(maxRisk / (close * stopLossLong / 100) / PointValue) * pipsize))
maxPositionSizeShort = MAX(15, abs(round(maxRisk / (close * stopLossShort / 100) / PointValue) * pipsize))
Endif
ONCE trailingStartLong = 2 // in %
ONCE trailingStartShort = 0.75 // in %
ONCE trailingStepLong = 0.2 // in %
ONCE trailingStepShort = 0.4 // in %
ONCE maxCandlesLongWithProfit = 17//x1//16 // take long profit latest after 16 candles
ONCE maxCandlesShortWithProfit = 13//x2//15 // take short profit latest after 15 candles
ONCE maxCandlesLongWithoutProfit = 26//x1//30 // limit long loss latest after 30 candles
ONCE maxCandlesShortWithoutProfit = 25//x2//12 // limit short loss latest after 12 candles
// define saisonal position multiplier for each month 1-15 / 16-31 (>0 - long / <0 - short / 0 no trade)
ONCE January1 = 3//x1//3
ONCE January2 = 0//x2//0
ONCE February1 = 1//x1//3
ONCE February2 = 2//x2//3
ONCE March1 = 3//x1//3
ONCE March2 = 3//x2//2
ONCE April1 = 0//x1//1
ONCE April2 = 3//x2//3
ONCE May1 = 1//x1//1
ONCE May2 = 3//x2//1
ONCE June1 = 0//x1//2
ONCE June2 = 2//x2//2
ONCE July1 = 1//x1//3
ONCE July2 = 3//x2//1
ONCE August1 = 2//x1//1
ONCE August2 = 1//x2//1
ONCE September1 = 3//x1//3
ONCE September2 = 0//x2//0
ONCE October1 = 3//x1//3
ONCE October2 = 3//x2//2
ONCE November1 = 2//x1//1
ONCE November2 = 3//x2//3
ONCE December1 = 3//x1//3
ONCE December2 = 2//x2//2
// calculate daily high/low (include sunday values if available)
dailyHigh = DHigh(1)
dailyLow = DLow(1)
// calculate weekly high/low
If DayOfWeek < DayOfWeek[1] then
weeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)
lastWeekBarIndex = BarIndex
ENDIF
// calculate monthly high/low
If Month[1] <> Month[2] then
//If Month <> Month[1] then
monthlyHigh = Highest[BarIndex - lastMonthBarIndex](dailyHigh)
monthlyLow = Lowest[BarIndex - lastMonthBarIndex](dailyLow)
lastMonthBarIndex = BarIndex
ENDIF
// calculate instrument signalline with multiple smoothed averages
firstMA = WilderAverage[periodFirstMA](close)
secondMA = TimeSeriesAverage[periodSecondMA](firstMA)
signalline = TimeSeriesAverage[periodThirdMA](secondMA)
// save position before trading window is open
If Time < startTime then
startPositionLong = COUNTOFLONGSHARES
startPositionShort = COUNTOFSHORTSHARES
EndIF
// trade only in defined trading window
IF Time >= startTime AND Time <= endTime THEN
// set saisonal multiplier
currentDayOfTheMonth = Date - ((CurrentYear * 10000) + CurrentMonth * 100)
midOfMonth = 15
IF CurrentMonth = 1 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = January1
ELSE
saisonalPatternMultiplier = January2
ENDIF
ELSIF CurrentMonth = 2 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = February1
ELSE
saisonalPatternMultiplier = February2
ENDIF
ELSIF CurrentMonth = 3 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = March1
ELSE
saisonalPatternMultiplier = March2
ENDIF
ELSIF CurrentMonth = 4 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = April1
ELSE
saisonalPatternMultiplier = April2
ENDIF
ELSIF CurrentMonth = 5 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = May1
ELSE
saisonalPatternMultiplier = May2
ENDIF
ELSIF CurrentMonth = 6 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = June1
ELSE
saisonalPatternMultiplier = June2
ENDIF
ELSIF CurrentMonth = 7 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = July1
ELSE
saisonalPatternMultiplier = July2
ENDIF
ELSIF CurrentMonth = 8 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = August1
ELSE
saisonalPatternMultiplier = August2
ENDIF
ELSIF CurrentMonth = 9 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = September1
ELSE
saisonalPatternMultiplier = September2
ENDIF
ELSIF CurrentMonth = 10 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = October1
ELSE
saisonalPatternMultiplier = October2
ENDIF
ELSIF CurrentMonth = 11 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = November1
ELSE
saisonalPatternMultiplier = November2
ENDIF
ELSIF CurrentMonth = 12 THEN
IF currentDayOfTheMonth <= midOfMonth THEN
saisonalPatternMultiplier = December1
ELSE
saisonalPatternMultiplier = December2
ENDIF
ENDIF
// define trading filters
// 1. use fast and slow averages as filter because not every breakout is profitable
f1 = close > Average[periodLongMA](close)
f2 = close < Average[periodLongMA](close)
f3 = close > Average[periodShortMA](close)
// 2. check if position already reduced in trading window as additonal filter criteria
alreadyReducedLongPosition = COUNTOFLONGSHARES < startPositionLong
alreadyReducedShortPosition = COUNTOFSHORTSHARES < startPositionShort
// long position conditions
l1 = signalline CROSSES OVER monthlyHigh
l2 = signalline CROSSES OVER weeklyHigh
l3 = signalline CROSSES OVER dailyHigh
l4 = signalline CROSSES OVER monthlyLow
// short position conditions
s1 = signalline CROSSES UNDER monthlyHigh
s2 = signalline CROSSES UNDER dailyLow
// long entry with order cumulation
IF ( (l1 OR l4 OR l2 OR (l3 AND f2)) AND NOT alreadyReducedLongPosition) THEN
// check saisonal booster setup and max position size
IF saisonalPatternMultiplier > 0 THEN
IF (COUNTOFPOSITION + (positionSize * saisonalPatternMultiplier)) <= maxPositionSizeLong THEN
BUY positionSize * saisonalPatternMultiplier CONTRACT AT MARKET
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
IF (COUNTOFPOSITION + positionSize) <= maxPositionSizeLong THEN
BUY positionSize CONTRACT AT MARKET
ENDIF
ENDIF
stopLoss = stopLossLong
takeProfit = takeProfitLong
ENDIF
// short entry without order cumulation
IF NOT SHORTONMARKET AND ( (s1 AND f3) OR (s2 AND f1) ) AND NOT alreadyReducedShortPosition THEN
// check saisonal booster setup and max position size
IF saisonalPatternMultiplier < 0 THEN
IF (COUNTOFPOSITION + (positionSize * ABS(saisonalPatternMultiplier))) <= maxPositionSizeShort THEN
SELLSHORT positionSize * ABS(saisonalPatternMultiplier) CONTRACT AT MARKET
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
IF (COUNTOFPOSITION + positionSize) <= maxPositionSizeLong THEN
SELLSHORT positionSize CONTRACT AT MARKET
ENDIF
ENDIF
stopLoss = stopLossShort
takeProfit = takeProfitShort
ENDIF
// stop and profit management
posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize
numberCandles = (BarIndex - TradeIndex)
m1 = posProfit > 0 AND numberCandles >= maxCandlesLongWithProfit
m2 = posProfit > 0 AND numberCandles >= maxCandlesShortWithProfit
m3 = posProfit < 0 AND numberCandles >= maxCandlesLongWithoutProfit
m4 = posProfit < 0 AND numberCandles >= maxCandlesShortWithoutProfit
// take profit after max candles
IF LONGONMARKET AND (m1 OR m3) THEN
SELL AT MARKET
ENDIF
IF SHORTONMARKET AND (m2 OR m4) THEN
EXITSHORT AT MARKET
ENDIF
// trailing stop function (convert % to pips)
trailingStartLongInPoints = tradeprice(1) * trailingStartLong / 100
trailingStartShortInPoints = tradeprice(1) * trailingStartShort / 100
trailingStepLongInPoints = tradeprice(1) * trailingStepLong / 100
trailingStepShortInPoints = tradeprice(1) * trailingStepShort / 100
//ONCE Breakeven=0
// reset the stoploss value
IF NOT ONMARKET THEN
newSL = 0
//breakeven=0
ENDIF
// manage long positions
IF LONGONMARKET THEN
// first move (breakeven)
IF newSL = 0 AND close - tradeprice(1) >= trailingStartLongInPoints * pipsize THEN
newSL = tradeprice(1) + trailingStepLongInPoints * pipsize
stopLoss = stopLossLong * 0.1
takeProfit = takeProfitLong * 2
//breakeven=1
ENDIF
// next moves
IF newSL > 0 AND close - newSL >= trailingStepLongInPoints * pipsize THEN
newSL = newSL + trailingStepLongInPoints * pipsize
//breakeven=1
ENDIF
ENDIF
// manage short positions
IF SHORTONMARKET THEN
// first move (breakeven)
IF newSL = 0 AND tradeprice(1) - close >= trailingStartShortInPoints * pipsize THEN
newSL = tradeprice(1) - trailingStepShortInPoints * pipsize
//breakeven=1
ENDIF
// next moves
IF newSL > 0 AND newSL - close >= trailingStepShortInPoints * pipsize THEN
newSL = newSL - trailingStepShortInPoints * pipsize
//breakeven=1
ENDIF
ENDIF
// stop order to exit the positions
IF newSL > 0 THEN
IF LONGONMARKET THEN
SELL AT newSL STOP
ENDIF
IF SHORTONMARKET THEN
EXITSHORT AT newSL STOP
ENDIF
ENDIF
// superordinate stop and take profit
SET STOP %LOSS stopLoss
SET TARGET %PROFIT takeProfit
ENDIF
//dif=(newsl1-tradeprice)
//graph ((dif*COUNTOFPOSITION*pipsize*pointvalue)/(equity))*100 COLOURED(0,0,255) AS "MAXRISKNEWSL"//blue
//graph (((tradeprice-(tradeprice-(tradeprice*(stoploss/100))))*positionsize*pipsize*pointvalue)/(equity))*100 COLOURED(0,0,0) AS "MAXRISK"//blue
//graph (((close-positionprice)*pointvalue)*countofposition)/pipsize/(equity)*100 COLOURED(0,0,255) AS "MAXRISK3"//blue
//graph (((positionprice-(positionprice-(positionprice*(stoploss/100))))*COUNTOFPOSITION*pipsize*pointvalue)/(equity))*100 COLOURED(0,0,255) AS "MAXRISK2"//blue
if ((tradeprice-(tradeprice-((tradeprice*(stoploss/100)*COUNTOFPOSITION)))*pipsize*pointvalue)/equity)*100 <0 then
graph -1*((tradeprice-(tradeprice-((tradeprice*(stoploss/100)*COUNTOFPOSITION)))*pipsize*pointvalue)/equity)*100 COLOURED(0,0,255) AS "MAXRISK"//Aqua
else
graph ((tradeprice-(tradeprice-((tradeprice*(stoploss/100)*COUNTOFPOSITION)))*pipsize*pointvalue)/equity)*100 COLOURED(0,0,255) AS "MAXRISK"//Aqua
endif
//graph ((tradeprice-(tradeprice-((tradeprice*(stoploss/100)*COUNTOFPOSITION)))*pipsize*pointvalue)/equity)*100 COLOURED(0,0,255) AS "MAXRISK"//Aqua
//graph ((tradeprice-(tradeprice-((tradeprice*(newsl/100)*COUNTOFPOSITION)))*pipsize*pointvalue)/equity)*100 COLOURED(0,0,255) AS "MAXRISK-NewSL"//Aqua
//graph breakeven COLOURED(255,0,0) AS "breakeven"//Aqua
//graph ((newsl-tradeprice)/equity)*100 COLOURED(0,0,255) AS "newsl"
//graph positionsize COLOURED(0,125,255) AS "position"
//graph countofposition COLOURED(0,125,255) AS "countofposition"
//graph tradeprice-(tradeprice-(tradeprice-newsl)) COLOURED(0,0,255) AS "stoplossin%"
//graph (tradeprice-(tradeprice-((tradeprice*(stoploss/100)))))COLOURED(0,0,0) AS "pointstoSL"//Aqua
//graph (((tradeprice-(tradeprice-((tradeprice*stoploss)/100)))*positionsize*pointvalue*100)/(equity+capital))*100 COLOURED(0,0,0) AS "MAXRISK"//Aqua
Pathfinder Trading System
This topic contains 1,834 replies,
has 139 voices, and was last updated by CFD AutoTrading
2 years, 6 months ago.
| Forum: | ProOrder support |
| Language: | English |
| Started: | 09/22/2016 |
| Status: | Active |
| Attachments: | 435 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.