ProRealCode - Trading & Coding with ProRealTime™
Hi Reiner,
can you please share the programs for Natural Gas and Coffee as well?
I chewed the seasonal numbers but best results are only Natural Gas (409%/36%DD) and Coffee (795%/52%DD).
Hi Alco,
There are two easy approaches to estimate the required Pathfinder account size.
With 10k and three running Pathfinder algos you have to reduce the position size. The default parameter settings for each Pathfinder version is for an 10k account.
Best, Reiner
Hi Pranik,
Thanks for your idea. In my opinion weekly low is a weak condition and doesn’t produce high quality signals. I have extended Pathfinder DAX 4H V6 with the weekly low setup and the result is worse especially the drawdown (double). Please find attached a comparison of original V6 and V6 adopt with weekly low setup.
Best, Reiner
Hi CKW,
I never had this error message and unfortunately I have no clue what is the reason. I suppose it has something todo with the preload bars settings. Try to reduce the default setting.
DEFPARAM PRELOADBARS = 10000
Maybe someone else can advise.
Best, Reiner
Hi Reddi and welcome,
In my experience with 5M timeframe the Pathfinder breakout algo has to many fake breakouts. Higher timeframes are working like filter and increase the quality of the trade signals. I will focus with Pathfinder on the daily timeframe for the swing trades and on 4H and 1H for the intraday trades.
I encourage you hereby to verify if Pathfinder works in 5M or 15M. Let me know when you find a profitable approach.
Best, Reiner
Hallo Pfeiler,
I just rework all the Pathfinder daily backtests and will publish all saisonal adjustments soon. NG and KC is already finished.
Thanks for your hint with the @Day-function. I have changed the code accordingly.
KC has a drawdown of 36% and doesn’t fulfill my quality Pathfinder requirements but is on the other side one of the profitable versions. I let it in the top list because of the drawdown was 1972.
Best, Reiner
Hi Reiner,
Thank you for sharing your code and the time you put into this. Can see a lot more members are getting on board and have different request which is great but getting a bit long and confusing. Perhaps can open individual forum for each indices/commodities (even forex), making it easier to follow the indices/commodities you are interested in trading now or maybe in the future, and for new members to pick up too.
Best regards,
Sylvester
Hey Reiner,
I am sure you are aware of this, but in the Excel I saw that there are big differences between the available history of the instruments. You mentioned that your ranking is based partially on the total performance. But if you look at the average annual performance you see that for example hangseng has a annual performance of 39% (based on the last 10 years) and coffee is 16.5 % (in 39 years).
Just as an idea for another performance criteria.
I am looking forward to see the rest of the systems. I will try to check how consistant the annual performance for the instruments is by calculate it for the single years.
mfg
flo
Dear Reiner. During the test of a more conservative management code, where I still add more position accordingly to the equity size I came across a small issue I could not explain. To simplify things the same issue is confirmed if I just adjust the max positionsize for 3 instead of 15 in the DAX V6. The issue is that the conservative closed the 2 position today at 9:01 and the original are still going with 4 position. Both codes started at 21 Dec. 9:00 with 2 positions. later the original added 2 pos at 23 Dec 9:00. I backtested manually both code and I can see the issue is ongoing- but not every time. I could understand if the original V6 DAX closed 2 of the 4 position today at 9:00 it would result in closing of all the 2 position today, but that’s not the case. Do you have any Idea of why this is happening? Maybe you could explain the exit strategy in details, or just say if you already have, I will find it 🙂
This is the changed lines
maxPositionSizeLong = MAX(3, abs(round(maxRisk / (close * stopLossLong / 100) / PointValue) * pipsize))
maxPositionSizeShort = MAX(3, abs(round(maxRisk / (close * stopLossShort / 100) / PointValue) * pipsize))
Cheers Kasper
Update. I think I know why. when looking at the exit conditions, there is a
posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize
The posprofit would be higher with double the size of countofposition- so that why we are closing before the Original V6 DAX. but when I set out for making a more conservative code, I didn’t expect it to be on the gain side :-s Just a quick look and knowing that you properly optimized the exit strategy(maxCandlesLongWithProfit) I actually think that the original posProfit is general with higher gain. I would be nice if adjusting the maxposition size, still would follow the original posProfit -accordingly, other vice we are not only dealing with profit limited by positionsize but also missing out of profit because getting out to soon. Does this make sense?
Hey guys,
I tried to adapt the dow to version 6
// 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
// 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 = 7
// define filter parameter
ONCE periodLongMA = 160
ONCE periodShortMA = 5
// define position and money management parameter
ONCE positionSize = 1
Capital = 10000
Risk = 5 // in %
equity = Capital + StrategyProfit
maxRisk = round(equity * Risk / 100)
ONCE stopLossLong = 5.5 // in %
ONCE stopLossShort = 1.5 // in % 1.5
ONCE takeProfitLong = 1.5 // in % 2/1.5
ONCE takeProfitShort = 0.5 // in 0.5%
maxPositionSizeLong = MAX(10, abs(round(maxRisk / (close * stopLossLong / 100) / PointValue) * pipsize))
maxPositionSizeShort = MAX(10, abs(round(maxRisk / (close * stopLossShort / 100) / PointValue) * pipsize))
ONCE trailingStartLong = 1.25 // in %
ONCE trailingStartShort = 0.75 // in %
ONCE trailingStepLong = 0.2 // in %
ONCE trailingStepShort = 0.2 // in %
ONCE maxCandlesLongWithProfit = 17 // take long profit latest after 17 candles
ONCE maxCandlesShortWithProfit = 3 // take short profit latest after 4 candles
ONCE maxCandlesLongWithoutProfit = 40 // limit long loss latest after 40 candles
ONCE maxCandlesShortWithoutProfit = 11 // limit short loss latest after 11 candles
// define saisonal position multiplier for each month 1-15 / 16-31 (>0 - long / <0 - short / 0 no trade)
ONCE January1 = 3//3
ONCE January2 = 1//1
ONCE February1 = 2//2
ONCE February2 = 1//1
ONCE March1 = 2//2/3
ONCE March2 = 3//3
ONCE April1 = 2//2
ONCE April2 = 0//0
ONCE May1 = 0//0!
ONCE May2 = 0//0!
ONCE June1 = 3//3
ONCE June2 = 3//3
ONCE July1 = 0//0
ONCE July2 = 0//0
ONCE August1 = 0//0
ONCE August2 = 0//0
ONCE September1 = 3//3
ONCE September2 = 3//3
ONCE October1 = 0//0/1
ONCE October2 = 3//3
ONCE November1 = 1//1
ONCE November2 = 3//3
ONCE December1 = 1//0/1
ONCE December2 = 3//
// 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
// 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) >= trailingStartLongInPoints * pipsize THEN
newSL = tradeprice(1) + trailingStepLongInPoints * pipsize
stopLoss = stopLossLong * 0.1
takeProfit = takeProfitLong * 2
ENDIF
// next moves
IF newSL > 0 AND close - newSL >= trailingStepLongInPoints * pipsize THEN
newSL = newSL + trailingStepLongInPoints * pipsize
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
ENDIF
// next moves
IF newSL > 0 AND newSL - close >= trailingStepShortInPoints * pipsize THEN
newSL = newSL - trailingStepShortInPoints * pipsize
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
Correction: “The posprofit would be higher with double the size of countofposition- so that why we are closing before the Original V6 DAX.”
The posprofit would actually be lower with the double size of countofposition- at least in the latest exit.
Sorry about the mistake.
Perhaps can open individual forum for each indices/commodities (even forex), making it easier to follow the indices/commodities you are interested in trading now or maybe in the future, and for new members to pick up too.
I approve! Maybe we could put this as a rule: create individual topic for each different instrument version of Pathfinder. This is Reiner’s topic, so I think he may also have something to say about this idea.
But if you look at the average annual performance you see that for example hangseng has a annual performance of 39% (based on the last 10 years) and coffee is 16.5 % (in 39 years).
Good point! Normalized annualized performances should be used in this case. I believe anyone could do this calculation with the Excel file, Reiner has shared.
I like to have everything in one topic. it is easier to stay uppdated and a lot of the things that are discussed here are general for all the systems.
just my opinion…
I am having trouble getting anywhere close to your backtest.
I can only test from 30 aug 2012 and only get 57 trades (+48/-9) with time changed to 23.00 (instead of 21.00) and spread 2.8.
It seems as though I have done something wrong…
Regards, David
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.