As I could see from some comments (I have not read all 98 pages yet, maybe I did notsee “the” explanation for it), there seems to be a variation of positions / entries. Is there any forum for following / compareing / commenting the “real trades” of the pathfinder system? So I would not spam this forum…
“My” HS live closed short (1 position) & opened long (3 positions) @28705,1 / 13:oo pm (Germany, which is CEST).
@guitarrocker
Which HS version are you running?
@dajvop: Pathfinder HS 4H V7
Hauptcode : Pathfinder HS 4H V7
//-------------------------------------------------------------------------
// Pathfinder Trading System based on ProRealTime 10.3
// Reiner @ www.prorealcode.com
// Breakout system triggered by previous daily, weekly and monthly high/low crossings with smart position management
// Version 7 - last optimization from 18.07.2017
// Instrument: Hang Seng mini 4H, 5-17:00 CET, 10 points spread, account size 100.000 HKD
// V7 release notes:
// fix the preloadbars error
// fix the maxPositionSizeShort error
// fix the erroneous calculation of the short postion size
// add dynamic position sizing based on weekly performance
// add maximum size per trade monitoring
// remove dynamic max position size calculation
// optimize all relevant parameters
// ProOrder code parameter
DEFPARAM CUMULATEORDERS = true // cumulate orders if not turned off
DEFPARAM PRELOADBARS = 10000
// define intraday trading window
ONCE startTime = 050000
ONCE endTime = 170000
// define instrument signalline with help of multiple smoothed averages
ONCE periodFirstMA = 5
ONCE periodSecondMA = 10
ONCE periodThirdMA = 8
// define filter parameter
ONCE periodLongMA = 200
ONCE periodShortMA = 25
// size calculation: size = positionSize * trendMultiplier * saisonalPatternMultiplier
ONCE positionSize = 1 // default start size
ONCE trendMultiplier = 2 // >1 with dynamic position sizing; 1 without
ONCE maxPositionSizePerTrade = 6 // maximum size per trade
ONCE maxPositionSizeLong = 6 // maximu size for a long position
ONCE maxPositionSizeShort = 6 // maximum size for a short position
ONCE stopLossLong = 3 // in %
ONCE stopLossShort = 1.5 // in %
ONCE takeProfitLong = 2.25 // in %
ONCE takeProfitShort = 2 // in %
ONCE trailingStartLong = 2 // in %
ONCE trailingStartShort = 1.5 // in %
ONCE trailingStepLong = 0.2 // in %
ONCE trailingStepShort = 0.2 // in %
ONCE maxCandlesLongWithProfit = 19 // take long profit latest after x candles
ONCE maxCandlesShortWithProfit = 10 //10 take short profit latest after x candles
ONCE maxCandlesLongWithoutProfit = 25 // limit long loss latest after x candles
ONCE maxCandlesShortWithoutProfit = 6 // limit short loss latest after x candles
// define saisonal position multiplier for each month 1-15 / 16-31 (>0 - long / <0 - short / 0 no trade)
ONCE January1 = 0 //0 ok
ONCE January2 = 0 //2 ok
ONCE February1 = 3 //1 chance
ONCE February2 = 0 //0 ok
ONCE March1 = 1 //0 risk(1)
ONCE March2 = 2 //1 chance
ONCE April1 = 2 //0 risk(2)
ONCE April2 = 2 //0 risk(2)
ONCE May1 = 1 //0 risk(1)
ONCE May2 = 2 //0 risk(2)
ONCE June1 = 0 //0 ok
ONCE June2 = 0 //1 ok
ONCE July1 = 2 //0 risk(3)
ONCE July2 = 1 //1 ok
ONCE August1 = 1 //0 chance
ONCE August2 = 0 //1 ok
ONCE September1 = 0 //0 ok
ONCE September2 = 0 //0 ok
ONCE October1 = 3 //3 ok
ONCE October2 = 3 // 0 risk(3)
ONCE November1 = 1 //1 ok
ONCE November2 = 2 //0 risk(2)
ONCE December1 = 0 //0 ok
ONCE December2 = 1 //1 chance
// dynamic position sizing based on weekly performance
ONCE profitLastWeek = 0
IF DayOfWeek <> DayOfWeek[1] and DayOfWeek = 1 THEN
IF strategyProfit > profitLastWeek + 1 THEN
positionSize = min(trendMultiplier, positionSize + 1) // increase risk
ELSE
positionSize = max(1, positionSize - 1) // decrease risk
ENDIF
profitLastWeek = strategyProfit
ENDIF
// calculate daily high/low (include sunday values if available)
dailyHigh = DHigh(1)
dailyLow = DLow(1)
//previousDailyHigh = DHigh(2)
// calculate weekly high, weekly low is a poor signal
If DayOfWeek < DayOfWeek[1] and lastweekbarindex = 0 then
lastWeekBarIndex = BarIndex
else
if DayOfWeek < DayOfWeek[1] then
weeklyHigh = Highest[BarIndex - lastWeekBarIndex](dailyHigh)
lastWeekBarIndex = BarIndex
ENDIF
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 = OpenDay
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)
f4 = signalline < 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
s4 = signalline CROSSES UNDER dailyHigh
s5 = 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
numberContracts = MIN(maxPositionSizePerTrade, positionSize * saisonalPatternMultiplier)
IF (COUNTOFPOSITION + numberContracts) <= maxPositionSizeLong THEN
BUY numberContracts CONTRACT AT MARKET
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize)
IF (COUNTOFPOSITION + numberContracts) <= maxPositionSizeLong THEN
BUY numberContracts CONTRACT AT MARKET
ENDIF
ENDIF
stopLoss = stopLossLong
takeProfit = takeProfitLong
ENDIF
// short entry with order cumulation
IF ((s1 AND f3) OR (s5 AND f1) OR (f4 AND (s4 AND f2)) ) AND NOT alreadyReducedShortPosition THEN
// check saisonal booster setup and max position size
IF saisonalPatternMultiplier < 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize * ABS(saisonalPatternMultiplier))
IF (ABS(COUNTOFPOSITION) + numberContracts) <= maxPositionSizeShort THEN
SELLSHORT numberContracts CONTRACT AT MARKET
ENDIF
ELSIF saisonalPatternMultiplier <> 0 THEN
numberContracts = MIN(maxPositionSizePerTrade, positionSize)
IF (ABS(COUNTOFPOSITION) + numberContracts) <= maxPositionSizeShort THEN
SELLSHORT numberContracts 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
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
takeProfit = takeProfitLong
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
@guitarrocker
Same version that I am running.
I had the 2 short position close and 6 open long yesterday at 1 pm. Have you changed anything if only 1 short closed and 3 long opened?
@dajvop: Nope. That is what I meant with #49546. Maybe because the Account is my “regular” trading Account and the free money is <10k?
rebParticipant
Master
Hi guys
@guitarroker
have you used this strat for a long time ?
oI had the same issue before, I think it is due to :
IF DayOfWeek <> DayOfWeek[1] and DayOfWeek = 1 THEN
IF strategyProfit > profitLastWeek + 1 THEN
positionSize = min(trendMultiplier, positionSize + 1) // increase risk
ELSE
positionSize = max(1, positionSize – 1) // decrease risk
ENDIF
profitLastWeek = strategyProfit
ENDIF
you cannot benefit from the increase risk option because of a lack of strategyprofit
@reb: I think you are right. I tried it only on demo. Seems to be the point. Thank you!
Should have waited one more week 😉 HS long (3) closed and HS short (2) opened at 28283.4 (5 o’clock).
DOW long (3) opened at 23345,1 (9 o ‘clock)
HS 6 Long @28177,9 (yesterday 17h)
Dow 3 Long closed @23349,2 (today 9h)
hey guys. great work.
one question: I run all the backtests, on everyone 2017 is not really good. Is it like this or do I make a mistake?
@raphaelopilski: If you ask for a comparison backtest / realdepot, I cannot answer. I, myself am running “live” only for days…
yes, I made a backtest. 4 hours and 100.000 units. everything looks good, but 2017 is quite bad.
How do you run it? Only for days? How does it work?
@raphaelopilski: Not fully sure, what you mesn. EVERY strategy hss bad & good periods. It is important that in the long run the figures are green.
I run it some 2 & 1/2 weeks now. Some are negative (HS), some positive (Dow). But as Statistics is an asshole, the number of incidents (N) is too little in my case to give a qualified answer.