Brage,
as requested for play around please find attached itf-file for Pathfinder OMX 4H V5B2.
best, Reiner
Thanks again Reiner!
But when backtesting with the file you attached, I don’t get even close to the results you showed me before on OMX. What am I doing wrong?
Brage, I’m confused. I imported the itf file from above and with OMX mini 20 SEK the backtest shows the attached result.
Here is the used code:
// 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 5 Beta 2
// Instrument: OMX mini 4H, 8-22 CET, 1.5 points spread, account size 100.000 SEK
// 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 = 210
ONCE periodShortMA = 10
// define position and money management parameter
ONCE positionSize = 1
Capital = 10000
Risk = 2 // in %
equity = Capital + StrategyProfit
maxRisk = round(equity * Risk / 100)
ONCE stopLossLong = 5 // in %
ONCE stopLossShort = 3.25 // in %
ONCE takeProfitLong = 3.25 // in %
ONCE takeProfitShort = 2 // in %
maxPositionSizeLong = MAX(15, abs(round(maxRisk / (close * stopLossLong / 100) / PointValue) * pipsize))
maxPositionSizeShort = MAX(15, abs(round(maxRisk / (close * stopLossShort / 100) / PointValue) * pipsize))
ONCE trailingStartLong = 2.75 // in %
ONCE trailingStartShort = 0.75 // in %
ONCE trailingStepLong = 0.2 // in %
ONCE trailingStepShort = 0.4 // in %
ONCE maxCandlesLongWithProfit = 21 // take long profit latest after 21 candles
ONCE maxCandlesShortWithProfit = 12 // take short profit latest after 12 candles
ONCE maxCandlesLongWithoutProfit = 30 // limit long loss latest after 30 candles
ONCE maxCandlesShortWithoutProfit = 3 // limit short loss latest after 3 candles
// define saisonal position multiplier >0 - long / <0 - short / 0 no trade
ONCE January = 3
ONCE February = 3
ONCE March = 1
ONCE April = 3
ONCE May = 1
ONCE June = 2
ONCE July = 3
ONCE August = -2
ONCE September = -2
ONCE October = 3
ONCE November = 1
ONCE December = 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 <> 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 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
// 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
IF LONGONMARKET THEN
posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize
ELSIF SHORTONMARKET THEN
posProfit = (((positionprice - close) * pointvalue) * countofposition) / pipsize
ENDIF
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
// 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
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
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
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
// superordinate stop and take profit
SET STOP %LOSS stopLoss
SET TARGET %PROFIT takeProfit
ENDIF
Oil also sees real good results. Reiner the FTSE 100 updated to v5 you have available?
and the poor Italian index as it behaves?
Patrick, Miguel,
as requested here the current Pathfinder version V5B2 for the FTSE mini.
regards, Reiner
Hi Patrick,
Current Pathfinder’s algorithm requires 24H quoting for an underlying instrument (e.g. calculation of signalline, max holding candles, etc.). It won’t work for futures without adaptation. In IG’s world the future instruments have a very limited life time and unfortunately avoid backtesting over a longer time period. I have seen your test based on an instrument DAX30 Full1216 Future – were can I find this underlying in IG’s PRT?
best, Reiner
wp01Participant
Master
Hi Reiner,
Thank you for your reply. Unfortunately you can not find DAX30FULL1216 Future in PRT from IG. IG is a CFD provider and only has derivates of the original future or index.
With a CFD you never trade directly in the future or other product, but always in a derivate of the original product. This is also the discussion. You trade directly with CFD created software
in a CFD created environment which means that it looks like that you trade against IG, what they of course deny.
When you trade with futures from for example Interactive , you buy directly a future on the stock exchange in for example the DAX Bourse or Euronext. These bourses also closes at 20.00 hrs. or at
22.00 hrs. After these times until 08.00 hrs. there will not be a pricing and of course no candles. Now you have to take a look at the candles in the night at IG. You see sometimes very weird
results where all kind of stops are being triggered while there in the meantime no pricing is on the real stockexchange. Al these pricings in the night affect backtests of course.
If you want to adjust Pathfinder for the future market i suggest you open a free account at prorealtime.de. I thought you can get the first 2 weeks fully access including daytrading free of charge.
So if you want to you can try it free of charge and maybe you can with your experience easily adjust the Pathfinder for futuretrading. When it is working you can set your account to automatic trading
and than your trades will go through Interactive Brokers.
Best regards,
Patrick
Hi Reiner,
Fantastic work on the Pathfinder strategy! Do you know if this is also a good strategy for the CAC French index?
Thanks,
Mikael
Hi Miguel,
in general MIB is suitable for Pathfinder because of the high absolute value and the volatility. With IG MIB is unfortunately not tradable because of the very high spread outside of the core trading time (48 points).
Please find attached a MIB mini backtest, I didn’t find a smoothed equity curve because of the high spreads and the tough down trends. The return is really good but drawdown is also significant. The backtest is done with an unrealistic spread of 15 points and is very optimized.
I love Italian food and especially Italian women but not the MIB, stay with the DAX is still the best :-).
best, Reiner
hahahahahah great reiner .
Dax are many days that pathfinder not trade
Miguel,
look at the DAX over the last days and weeks. No trend, low volatility, no saisonal behavior and catched in a small range. Only scalping systems made some money in that scenario. Pathfinder is a swing trading system makes money mainly on the long side. In my opinion it’s an advantage of the system that it stay beside the line and wait for better trading chances instead of loosing money in sideway trends.
best, Reiner
rebParticipant
Master
Hi Reiner, Hi all
The Reiner’s previous post shows the main reason why a lot of trading systems (swing trading) have some results problems.
One day you win, the day after you loose or vice and versa
At the end, you don’t earn anything but your broker does….
Reb
Hi Mikael,
Pathfinder works also well for CAC mini that’s not really surprising because the European Indices are more or less related. Please find attached the backtest and the code. Please be aware that this is an optimized view over the last 4 years. CAC had a longer sideway range (Feb 2015 – Feb 2016) and I suppose that a lot of traders loose the patience in that time. Overall the result is solid and drawdown is around 20% as mentioned before my favourite is still the DAX because of better performance and drawdown.
best, Reiner