Basic pivot point intraday trading strategy

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #34489 quote
    Seemore Profit
    Participant
    Junior

    A very basic strat i have used manually but with more flexability. Would require
    further back testing. Happy for your comments, very new to code so go easy on me!

    // Definition of code parameters 
    DEFPARAM CumulateOrders = False 
    // Cumulating positions deactivated // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time. 
    DEFPARAM FLATBEFORE = 070000 
    // Cancel all pending orders and close all positions at the "FLATAFTER" time 
    DEFPARAM FLATAFTER = 184500 
    // Prevents the system from placing new orders on specified days of the week 
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 
    // Conditions to enter long positions 
    ignored, ignored, ignored, ignored, ignored, ignored, indicator1 = CALL "Daily Pivots Points" 
    c1 = (close CROSSES UNDER indicator1) 
    IF c1 AND not daysForbiddenEntry THEN 
    BUY 1 PERPOINT AT MARKET 
    ENDIF 
    // Conditions to enter short positions 
    ignored, ignored, ignored, indicator2, ignored, ignored, ignored = CALL "Daily Pivots Points" 
    c2 = (close CROSSES OVER indicator2) 
    IF c2 AND not daysForbiddenEntry THEN 
    SELLSHORT 1 PERPOINT AT MARKET 
    ENDIF 
    // Stops and targets 
    SET STOP pLOSS 10 
    SET TARGET pPROFIT 20
    GraHal and Francesco78 thanked this post
    pivot-1493828348l84cp1.png pivot-1493828348l84cp1.png
    #34495 quote
    Despair
    Blocked
    Master

    You should attach also your “Daily PP indicator”.

    #34496 quote
    Maz
    Participant
    Veteran

    Hiya, thanks for starting the topic. Would you care to explain a bit more around the premise – why it works, etc?

    Apart from eurodollar M3 what other assets and resolutions have you tested this on?

    Here is a template / boilerplate that will make it more portable and easier for the community to back test different instruments.

    // ====================================== \\
    // :: System Parameters --
    // -------------------------------------- //
    DEFPARAM cumulateOrders = false
    DEFPARAM flatBefore     = 070000
    DEFPARAM flatAfter      = 184500
    
    // ====================================== \\
    // :: Globals --
    // -------------------------------------- //
    once positionSize = 1
    
    // ====================================== \\
    // :: Optimizations --
    // -------------------------------------- //
    once optimization = 1
    
    // -- Optimization selection sets
    if optimization = 1 then // EUR_USD M3
    dayStart    = 230000 // for pivot points
    tradingTime = not (openDayOfWeek = 6 OR openDayOfWeek = 0)
    pointTarget = 20
    pointRisk   = 10
    
    elsif optimization = 2 then // ANOTHER MARKET
    //dayStart    = 230000 
    //tradingTime = not (openDayOfWeek = 6 OR openDayOfWeek = 0)
    //pointTarget = 20
    //pointRisk   = 10
    
    endif
    
    
    // ====================================== \\
    // :: Indicator logic--
    // -------------------------------------- //
    
    // -- Pivot points ================= \\
    nd = dayStart
    if barindex = 0 then
    init = 1
    lastClose = undefined
    lastHigh  = undefined
    lastLow   = undefined
    PP   = undefined
    Res1 = undefined
    Res2 = undefined
    Res3 = undefined
    Sup1 = undefined
    Sup2 = undefined
    Sup3 = undefined
    else
    ndA = ( time[2] < nd and time[1] >= nd AND dayofweek <> 0)
    ndB = ( time[2] < nd and time[1] >= nd and dayofweek[1] <> 0 and dayofweek[0] = 0)
    isNewDay = ndA or ndB  // bit of speed optimziation
    if isNewDay then
    if init = 1 then
    lastHigh = High
    lastLow = Low
    init = 2
    elsif init = 2 then
    lastClose = Close[1]
    PP = (lastClose + lastHigh + lastLow) / 3
    hl = lastHigh - lastLow
    Res1 = 2 * PP - lastLow
    Sup1 = 2 * PP - lastHigh
    Res2 = PP + hl
    Sup2 = PP - hl
    Res3 = Res1 + hl
    Sup3 = Sup1 - hl
    lastHigh = High
    lastLow = Low
    endif
    endif
    if init = 2 then
    lastHigh = Max(lastHigh, High)
    lastLow = Min(lastLow, Low)
    endif
    endif
    // ----------------------------------- //
    
    
    // Ignored values to stop PRT kicking up a fuss
    if Res2 or Sup2 then
    endif
    
    // ====================================== \\
    // :: Conditional logic--
    // -------------------------------------- //
    closeAboveSup3 = (close CROSSES UNDER Sup3)
    closeBelowRes3 = (close CROSSES OVER Res3)
    
    bc1 = tradingTime and closeAboveSup3
    sc1 = tradingTime and closeBelowRes3
    
    
    // ====================================== \\
    // :: Execution Handlers --
    // -------------------------------------- //
    // -- Entry --
    if bc1 then
    buy positionSize perPoint at Market
    endif
    if sc1 then
    sellShort positionSize perPoint at Market
    endif
    
    // -- Exit --
    if onMarket then
    SET STOP pLOSS pointRisk
    SET TARGET pPROFIT pointTarget
    endif
    
    
    
    

    Hope that’s of use

    Best,

    M

    Cosmic1, ALE, GraHal and victormork thanked this post
    #34498 quote
    Maz
    Participant
    Veteran

    Indicator is included in above template btw

    victormork thanked this post
    #34554 quote
    Seemore Profit
    Participant
    Junior

    HI Maz.

    Its just a simple fade trading strat really. Wanted to put it out there for traders like yourself to maybe think of ways to add and improve it.

    Tested on FSTE wasnt great, but was good on the AUD/USD. I tried 5m but wasnt as good.

    Thanks for the code, much more like it!!

    AUDUSD.png AUDUSD.png
    #34578 quote
    Cosmic1
    Participant
    Senior

    I’ve thought about this algo idea many times. Great starting point. Is this pivot point code calculating the Spreadbet / CFD market or real market?

    #34611 quote
    Seemore Profit
    Participant
    Junior

    I used it on my spreadbet market IG. I included the spread size of 0.8 tick which is larger than the 0.6 i pay. I done this to allow for slippage.

    #34615 quote
    Seemore Profit
    Participant
    Junior

    It might be even more effective if combined with daily ATR.

    #34619 quote
    Elsborgtrading
    Participant
    Veteran

    @MAZ did you format this code with Notepad++ and copy pasted it? It seems like it’s keeping the formatting when I copy it into onenote- that is nice 🙂

    Cheers Kasper

    Screenshot_25.jpg Screenshot_25.jpg
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Basic pivot point intraday trading strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 8 replies,
has 5 voices, and was last updated by Elsborgtrading
8 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/04/2017
Status: Active
Attachments: 3 files
Logo Logo
Loading...