Pathfinder Trading System

Viewing 15 posts - 376 through 390 (of 1,835 total)
  • Author
    Posts
  • #17979 quote
    Mr MackeyMr Mackey
    Participant
    Junior

    The only reason I ask is that backtesting v3 on DAX30 shows awsome results compared to v4…

    #17980 quote
    ReinerReiner
    Participant
    Veteran

    Hi Mark,

    the DAX daily version trade only the strongest signal based on daily cross over/under (less signals but higher quality). The DAX 1D consider all 6 breakout signals and has higher profits but also a higher drawdown. I developed the versions based on daily data to have something for a quick check whether the instrument is suitable for the Pathfinder breakout algorithm or not. The test is done in minutes and if profitable I will look deeper and invest more time to create a H4 or H1 version.

    best, Reiner

    #17981 quote
    ReinerReiner
    Participant
    Veteran

    Adam, as requested here is the code of the last H4 version V6 from today

    // 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 = 3
    
    // define filter parameter
    ONCE periodLongMA = 300
    ONCE periodShortMA = 50
    
    // 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 = 3.25 // in %
    ONCE takeProfitLong = 3.25 // in %
    ONCE takeProfitShort = 3.25 // 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 // in %
    ONCE trailingStartShort = 0.75 // in %
    ONCE trailingStepLong = 0.2 // in %
    ONCE trailingStepShort = 0.4 // in %
    
    ONCE maxCandlesLongWithProfit = 16  // take long profit latest after 16 candles
    ONCE maxCandlesShortWithProfit = 15  // take short profit latest after 15 candles
    ONCE maxCandlesLongWithoutProfit = 30  // limit long loss latest after 30 candles
    ONCE maxCandlesShortWithoutProfit = 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
    ONCE January2 = 0
    ONCE February1 = 3
    ONCE February2 = 3
    ONCE March1 = 3
    ONCE March2 = 2
    ONCE April1 = 3
    ONCE April2 = 3
    ONCE May1 = 1
    ONCE May2 = 1
    ONCE June1 = 2
    ONCE June2 = 2
    ONCE July1 = 3
    ONCE July2 = 1
    ONCE August1 = 1
    ONCE August2 = 1
    ONCE September1 = 3
    ONCE September2 = 0
    ONCE October1 = 3
    ONCE October2 = 2
    ONCE November1 = 2
    ONCE November2 = 3
    ONCE December1 = 3
    ONCE December2 = 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
    
    // 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
    
    #17983 quote
    AlcoAlco
    Participant
    Senior

    Hello Reiner,

    First I will thank you for this great system. If I run a backtest with the latest version (v6) from 9 aug 2012 – 8 dec 2016 and looked at the losing trades, I came to the conclusion that if you separate the month in four, you probably get better results.

    Im not a programmer, so I don’t know to do that.

    The results of losing trades if you split the month in 4
    1 – 7        5 losing trades     5,95%
    8 – 15     8 losing trades     6,54%
    16 – 23   13 losing trades   11,32%
    24 – 31   5 losing trades     1,6%

    So, if I look back in 4,5 years history, it’s probably better to adapt the seasonal booster for those weeks, or do not trade in week  3.

    Alco

    #18047 quote
    ReinerReiner
    Participant
    Veteran

    Hi Simon,

    the current Pathfinder DAX version is V6. http://www.prorealcode.com/topic/pathfinder-trading-system/page/25/#post-17954

    Please find attached a comparision of the results from V3 to V6. Pathfinder was created for the DAX and I have no clue if it works with DFB.

    @UK guys: please advise to answer Simons question if Pathfinder works with a DAX DFB – Thanks

    best, Reiner

    Pathfinder-DAX-V3-V6.png Pathfinder-DAX-V3-V6.png
    #18056 quote
    Cosmic1Cosmic1
    Participant
    Senior

    Yes, works all good. Just adjust start and finish times back 1 hour.

    #18084 quote
    Viktor ZetterblomViktor Zetterblom
    Participant
    Junior

    Hello everyone!
    Thank you Reiner for this great system. It works very well for me so far.
    I have been programing my own trading systems for about 7 months so i´m still learning a lot.

    But there is one thing i don´t understand with your system.

    It says in the code that it is active between 09:00 – 21:00 but when i have done the same thing in my own trading systems that i have programmed it has ended open positions after the time has ended.
    But your system can keep positions open for days, even after 21:00
    So my question is what does the timeframe do more exactly in your code?

    Viktor

    #18087 quote
    Choo Jen-SinChoo Jen-Sin
    Participant
    New

    Hi Reiner,

    Do we set the timezone in platform options to CET (UTC +01:00)?

    Thank You.

    #18088 quote
    ElsborgtradingElsborgtrading
    Participant
    Veteran

    Hi Viktor. It sounds like you have incorporated a timecondition correct. However it does not close position. A simple example I often use my self is this. Trades will only be open between 09:00 and 17:00, and all trades will be closed after 22:00

    defparam flatafter=220000
    
    
    //===========Trade hours =============
    IF (Time >= 09000 AND Time <= 170000) then
    Tradetime=1
     else
    Tradetime=0
    endif
    
    // enter Long Position
    IF  <longcondition> and Tradetime THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // enter short Position
    IF <shortCondition> and Tradetime THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    #18089 quote
    AlcoAlco
    Participant
    Senior

    Could someone make the v6 version with months seperate in 4 instead of 2? i would really appreciate it.

    Kind regards,

    Alco

    #18095 quote
    NicolasNicolas
    Keymaster
    Legend

    @viktor

    If you have general questions about coding, please open a specific topic for each of them, in order to keep this topic clear and dedicated to Reiner’s strategy.

    @Choo Jen-Sin

    Please update your country into your profile. Thank you.

    #18099 quote
    ReinerReiner
    Participant
    Veteran

    Hi Alco,

    Thanks for your contribution and welcome. I checked  your idea and will deliver an adapted Pathfinder version tomorrow. Is some work to optimize 48 variables :-).

    best, Reiner

    #18100 quote
    ElsborgtradingElsborgtrading
    Participant
    Veteran

    Hi Reiner. I a couple of question for you brilliant work. In advance my apologies if the subject already has been mentioned but 385 reply in this thread I might have overlooked a few things 🙂

    First  DAX V6 is the one I looked deeper into, but you published V6b2 before the V6? With all the versions it could be hard to track changes, so why a ver 6b2 before a clean V6? It just the order in me that what this to be at least a V6.5 or am I missing something? Anyway a suggestion would be to make a matrix with the changes up through the version on various instrument as well and post it as perhaps a sticky non reply-able post(Nicolas is this possible for the only mortals?), and yes I know it would probably be very time consuming, but very informative. It sure would be nice to have

    About the order cumulation- it only for Long position and not for Short. But looking at the DAX Seasonality chart it could be profitable in to implement cumulation of short in the saisonal position multiplier.

    • January2
    • February2
    • March1
    • August1
    • August2
    • September2
    • September1
    • October1

    It just a quick look at the DAX Seasonality chart and I know it will overlap of some of the high multiplier for Long, for eksample in September1

    Could this be an idea, or is it already tried?

    Cheers Kasper

    #18101 quote
    ReinerReiner
    Participant
    Veteran

    Hi Choo Jen-Sin,

    Welcome – could you please set your location code in your profile to check where do come from. Usually it’s sufficient when you adjust the two variables:

    ONCE startTime = 90000
    ONCE endTime = 210000

    best, Reiner

    #18103 quote
    Cosmic1Cosmic1
    Participant
    Senior

    Just a thought but splitting the months in to 4 will surely become over curve fitted..?

Viewing 15 posts - 376 through 390 (of 1,835 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Pathfinder Trading System


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Reiner @reiner Participant
Summary

This topic contains 1,834 replies,
has 139 voices, and was last updated by CFD AutoTradingCFD AutoTrading
3 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/22/2016
Status: Active
Attachments: 435 files
ProRealCode ProRealCode
Loading...