ProRealCode - Trading & Coding with ProRealTime™
The DOW result is impressive but there are also a couple of higher losses.
Pathfinder DOW V4
// 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 4
// Instrument: DOW mini 4H, 8-22 CET, 2.8 points spread, account size 10.000 Euro
// ProOrder code parameter
DEFPARAM CUMULATEORDERS = true // cumulate orders if not turned off
DEFPARAM PRELOADBARS = 10000
// define intraday trading window
ONCE startTime = 80000
ONCE endTime = 220000
// define instrument signalline with help of multiple smoothed averages
ONCE periodFirstMA = 5
ONCE periodSecondMA = 10
ONCE periodThirdMA = 7
// define filter parameter
ONCE periodLongMA = 300
ONCE periodShortMA = 10
// define position and money management parameter
ONCE positionSize = 1
ONCE maxPositionSizeLong = 3
ONCE maxPositionSizeShort = 3
ONCE stopLossLong = 5.5 // in %
ONCE stopLossShort = 1.75 // in %
ONCE takeProfitLong = 2.75 // in %
ONCE takeProfitShort = 1.75 // in %
ONCE maxCandlesLongWithProfit = 17 // take long profit latest after 15 candles
ONCE maxCandlesShortWithProfit = 13 // take short profit latest after 13 candles
ONCE maxCandlesLongWithoutProfit = 40 // limit long loss latest after 30 candles
ONCE maxCandlesShortWithoutProfit = 25 // limit short loss latest after 25 candles
// define saisonal position multiplier >0 - long / <0 - short
ONCE January = 2
ONCE February = 3
ONCE March = 2
ONCE April = 2
ONCE May = 2
ONCE June = 2 // 3
ONCE July = 2
ONCE August = 2
ONCE September = -2
ONCE October = 3
ONCE November = 2
ONCE December = 2
// calculate daily high/low
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 <> 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)
// trade only in defined trading window
IF Time >= startTime AND Time <= endTime THEN
// filter criteria because not every breakout is profitable
f1 = close > Average[periodLongMA](close)
f2 = close < Average[periodLongMA](close)
f3 = close > Average[periodShortMA](close)
// saisonal pattern
IF CurrentMonth = 1 THEN
saisonalPatternMultiplier = January
ELSIF CurrentMonth = 2 THEN
saisonalPatternMultiplier = February
ELSIF CurrentMonth = 3 THEN
saisonalPatternMultiplier = March
ELSIF CurrentMonth = 4 THEN
saisonalPatternMultiplier = April
ELSIF CurrentMonth = 5 THEN
saisonalPatternMultiplier = May
ELSIF CurrentMonth = 6 THEN
saisonalPatternMultiplier = June
ELSIF CurrentMonth = 7 THEN
saisonalPatternMultiplier = July
ELSIF CurrentMonth = 8 THEN
saisonalPatternMultiplier = August
ELSIF CurrentMonth = 9 THEN
saisonalPatternMultiplier = September
ELSIF CurrentMonth = 10 THEN
saisonalPatternMultiplier = October
ELSIF CurrentMonth = 11 THEN
saisonalPatternMultiplier = November
ELSIF CurrentMonth = 12 THEN
saisonalPatternMultiplier = December
ENDIF
// 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
IF ( l1 OR l4 OR l2 OR (l3 AND f2) ) THEN // cumulate orders for long trades
IF saisonalPatternMultiplier > 0 THEN // check saisonal booster setup and max position size
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
IF NOT SHORTONMARKET AND ( (s1 AND f3) OR (s2 AND f1) ) THEN // no cumulation for short trades
IF saisonalPatternMultiplier < 0 THEN // check saisonal booster setup and max position size
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
m1 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithProfit
m2 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithProfit
m3 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithoutProfit
m4 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithoutProfit
IF LONGONMARKET AND (m1 OR m3) THEN
SELL AT MARKET
ENDIF
IF SHORTONMARKET AND (m2 OR m4) THEN
EXITSHORT AT MARKET
ENDIF
SET STOP %LOSS stopLoss
SET TARGET %PROFIT takeProfit
ENDIF
So a little play with V4 IN/OUT sample. Jan 2009 – March 2014.
Actually picks out first and third MA as 2…
Bit choppier than your version with MUCH more drawdown, overall result slightly better but prefer your version. I think it proves that your version is solid…?
// define instrument signalline with help of multiple smoothed averages
ONCE periodFirstMA = 2 //5
ONCE periodSecondMA = 12 //10
ONCE periodThirdMA = 2 //3
// define filter parameter
ONCE periodLongMA = 280 //300
ONCE periodShortMA = 45 //50
// define position and money management parameter
ONCE positionSize = 1
ONCE maxPositionSizeLong = 15
ONCE maxPositionSizeShort = 10
ONCE stopLossLong = 6.5 // in % 5.5
ONCE stopLossShort = 2.75 // in % 3.5
ONCE takeProfitLong = 3.25 // in % 2.75
ONCE takeProfitShort = 1.5 // in % 1.75
ONCE maxCandlesLongWithProfit = 18 // take long profit latest after 15 candles
ONCE maxCandlesShortWithProfit = 10 // take short profit latest after 13 candles
ONCE maxCandlesLongWithoutProfit = 32 // limit long loss latest after 30 candles
ONCE maxCandlesShortWithoutProfit = 27 // limit short loss latest after 25 candles
in backtest the version 4 seems better results for the DAX and the FTSE 100 while Wallstreet looks no better. I noticed that putting as 8-23 transaction time is improved a little.
Cosmic1, Thanks for your confirmation. It’s good to know that DAX V4 works reliable and without big drawdowns before 2013.
Miguel, You are right. In Pathfinder DOW V4 the new variables maxPositionSizeLong and maxPositionSizeShort have the wrong values (3) and limit the result. Please change the values to 15 and you will see a comparable V3 result. I have attached a comparison of V3 and V4. Sorry for the confusion.
Hi Reiner, DOW not looking so pretty before 2012.
If you want to ping me a message on email travel141 at gmail dot com I can give you skype details if you want to throw any code like this at the extended data I have if that would help?
Hi Reiner,
Great work!
I have been running v3 live since Sept 19 and it opened a long position on Sept 26 17 pm, but the backtest did not, unless I limit the starting date and time to Sept 19. Is there anything I should think about before starting v4?
Regards,
David
Hi Reiner,
Disregard my post above. I had forgot to set the correct no. of units to show in the backtest, so now both show the same.
Regards,
David
Perfetto. Tutto ok Reiner.
Hi Reiner,
I’ve been following your progress over the last few months and its been really impressive. I only put it on a live demo account in the last few weeks. How have things matched up in relation to the backtest and live testing/trading since you started.
I know you have talked about this in a previous post but I think this is the topic everyone is keen to find out about. Many of my simple strategies produce fine results on PRT but when it is a complex piece of coding it concerns me that the live results and backtest may be quite different.
Thanks for all your effort,
James
Cosmic1, Thanks for DOW backtest and your offer. I appreciate your support for this project and will come back to you.
No worries.
IN/OUT optimise with 10 years of data. 2.8 Spread.
ONCE periodFirstMA = 7 //5
ONCE periodSecondMA = 10 //10
ONCE periodThirdMA = 6 //7
// define filter parameter
ONCE periodLongMA = 315 //300
ONCE periodShortMA = 3 //10
// define position and money management parameter
ONCE positionSize = 1
ONCE maxPositionSizeLong = 15
ONCE maxPositionSizeShort = 15
ONCE stopLossLong = 6.25 // in 5.5%
ONCE stopLossShort = 2 // in 1.75%
ONCE takeProfitLong = 3.25 // in 2.75%
ONCE takeProfitShort = 1.75 // in 1.75%
ONCE maxCandlesLongWithProfit = 20 // take long profit latest after 17 candles
ONCE maxCandlesShortWithProfit = 11 // take short profit latest after 13 candles
ONCE maxCandlesLongWithoutProfit = 41 // limit long loss latest after 40 candles
ONCE maxCandlesShortWithoutProfit = 21 // limit short loss latest after 25 candles
Miguel, I have tested your idea that Pathfinder avoid intraday reopen a position in the same direction. Please find attached the comparison of both backtests with DAX mini. Your idea is valueable!
Here is the code, changes are tagged with #Miguel:
// 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 4 - avoid reopen of intraday positions in same direction (from Miguel)
// Instrument: DAX mini 4H, 8-22 CET, 2 points spread, account size 10.000 Euro
// ProOrder code parameter
DEFPARAM CUMULATEORDERS = true // cumulate orders if not turned off
DEFPARAM PRELOADBARS = 10000
// define intraday trading window
ONCE startTime = 80000
ONCE endTime = 220000
// 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
ONCE maxPositionSizeLong = 15
ONCE maxPositionSizeShort = 10
ONCE stopLossLong = 5.5 // in %
ONCE stopLossShort = 3.5 // in %
ONCE takeProfitLong = 2.75 // in %
ONCE takeProfitShort = 1.75 // in %
ONCE maxCandlesLongWithProfit = 15 // take long profit latest after 15 candles
ONCE maxCandlesShortWithProfit = 13 // take short profit latest after 13 candles
ONCE maxCandlesLongWithoutProfit = 30 // limit long loss latest after 30 candles
ONCE maxCandlesShortWithoutProfit = 25 // limit short loss latest after 25 candles
// define saisonal position multiplier >0 - long / <0 - short / 0 no trade
ONCE January = 2
ONCE February = 2
ONCE March = 2
ONCE April = 3
ONCE May = 2
ONCE June = 2
ONCE July = 3
ONCE August = -1
ONCE September = -2
ONCE October = 1
ONCE November = 3
ONCE December = 3
// calculate daily high/low
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 <> 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 #Miguel
If Time < startTime then
startPositionLong = COUNTOFLONGSHARES
startPositionShort = COUNTOFSHORTSHARES
EndIF
// trade only in defined trading window
IF Time >= startTime AND Time <= endTime THEN
// filter criteria because not every breakout is profitable
f1 = close > Average[periodLongMA](close)
f2 = close < Average[periodLongMA](close)
f3 = close > Average[periodShortMA](close)
// reduced position? #Miguel
reduceLongInTradingWindow = COUNTOFLONGSHARES < startPositionLong
reduceShortInTradingWindow = COUNTOFSHORTSHARES < startPositionShort
// saisonal pattern
IF CurrentMonth = 1 THEN
saisonalPatternMultiplier = January
ELSIF CurrentMonth = 2 THEN
saisonalPatternMultiplier = February
ELSIF CurrentMonth = 3 THEN
saisonalPatternMultiplier = March
ELSIF CurrentMonth = 4 THEN
saisonalPatternMultiplier = April
ELSIF CurrentMonth = 5 THEN
saisonalPatternMultiplier = May
ELSIF CurrentMonth = 6 THEN
saisonalPatternMultiplier = June
ELSIF CurrentMonth = 7 THEN
saisonalPatternMultiplier = July
ELSIF CurrentMonth = 8 THEN
saisonalPatternMultiplier = August
ELSIF CurrentMonth = 9 THEN
saisonalPatternMultiplier = September
ELSIF CurrentMonth = 10 THEN
saisonalPatternMultiplier = October
ELSIF CurrentMonth = 11 THEN
saisonalPatternMultiplier = November
ELSIF CurrentMonth = 12 THEN
saisonalPatternMultiplier = December
ENDIF
// 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
IF ( (l1 OR l4 OR l2 OR (l3 AND f2)) AND not reduceLongInTradingWindow ) THEN // cumulate orders for long trades #Miguel
IF saisonalPatternMultiplier > 0 THEN // check saisonal booster setup and max position size
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
IF NOT SHORTONMARKET AND ( (s1 AND f3) OR (s2 AND f1) ) AND not reduceShortInTradingWindow THEN // no cumulation for short trades #Miguel
IF saisonalPatternMultiplier < 0 THEN // check saisonal booster setup and max position size
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
m1 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithProfit
m2 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithProfit
m3 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithoutProfit
m4 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithoutProfit
IF LONGONMARKET AND (m1 OR m3) THEN
SELL AT MARKET
ENDIF
IF SHORTONMARKET AND (m2 OR m4) THEN
EXITSHORT AT MARKET
ENDIF
SET STOP %LOSS stopLoss
SET TARGET %PROFIT takeProfit
ENDIF
Hi James,
Pathfinder is a completely transparent project from the first idea up to the current state every step is documented here in the forum. The backtest with the DAX seems to be realible over the last years but to be honest I have no idea whether such a system realy works under real condition. From mid of July until now I traded several versions V2, V3 and now V4 but not continously and the return is more or less zero. An automatic trading system needs volatility and a trend to make money and over the last month DAX was a “lame duck”. It requires hundreds of trades to realy judge a system and requires a lot of patience. In a 4H timeframe it will take a time (months).
Perfetto Reiner.
if you enter definendo intra dal trading window 8-23. …. Incredibile more
miguel.
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.