Pivot monthly strategi

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #10394 quote
    filiprb
    Participant
    Average

    Hello,

    I’m currently building a strategy based on different kind of pivot points. In my testing I’m using a modified version of this indicator; http://www.prorealcode.com/prorealtime-indicators/daily-weekly-monthly-pivot-points/#comment-1059 . I though run into problems using the monthly pivot points in different ways. I’ll give you an example bellow;

     

    DEFPARAM CUMULATEORDERS = FALSE
    
    //
    
    Once lastMonthBarIndex = 0
    Once monthlyHigh = undefined
    Once monthlyLow = undefined
    Once monthlyPivot = undefined
    
    If Month<>Month[1] then
    monthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
    monthlyLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
    lastMonthBarIndex = BarIndex
    
    
    monthlyPivot = (close[1] + monthlyHigh + monthlyLow) / 3
    Endif
    
    MM1 = AVERAGE[7](CLOSE)
    
    //
    
    C1 = MM1 CROSSES OVER MONTHLYPIVOT
    
    IF NOT LONGONMARKET AND C1 THEN
    BUY 1 CONTRACTS AT MARKET
    
    SET STOP %LOSS 2
    SET TARGET %PROFIT 5
    ENDIF

    This is just an example of what kind of strategy I’m trying to achieve. I can’t though see what I’m doing wrong here?
    Help much appreciated!

    #10399 quote
    Nicolas
    Keymaster
    Master

    What is the problem you encountered with this trading strategy? No trades are initiated?

    #10402 quote
    filiprb
    Participant
    Average

    Obs sorry, forgot to mention the problem. Exactly, no trades were initiated and i can’t seem to understand why. Any clue?

    #10408 quote
    Nicolas
    Keymaster
    Master

    Try to change the line 23 with this (not tested) :

    C1 = MM1 CROSSES OVER MONTHLYPIVOT[1]
    #10416 quote
    filiprb
    Participant
    Average

    Did not work unfortunetly, no trades initiated.

    #10418 quote
    filiprb
    Participant
    Average

    I’ve also tried other approaches with the monthly pivot code. But nothing seems to work. For example; when the weekly pivot < monthly pivot and bla bla bla, then buy 1 contracts at market. Doesn’t work.

    #10432 quote
    Nicolas
    Keymaster
    Master

    This is the fixed code:

    DEFPARAM CUMULATEORDERS = FALSE
    defparam preloadbars = 20000
    
    Once lastMonthBarIndex = 0
    
    If Month <> Month[1] then
    monthlyHigh = Highest[BarIndex - lastMonthBarIndex](DHigh(1))
    monthlyLow = Lowest[BarIndex - lastMonthBarIndex](DLow(1))
    lastMonthBarIndex = BarIndex
    monthlyPivot = (Dclose(1) + monthlyHigh + monthlyLow) / 3
    ENDIF
    
    MM1 = AVERAGE[7](CLOSE)
    
    GRAPH monthlypivot
    GRAPH lastmonthBarIndex
    
    
    C1 = MM1 CROSSES OVER MONTHLYPIVOT
    
    IF NOT LONGONMARKET AND C1 THEN
    BUY 1 CONTRACTS AT MARKET
    
    SET STOP %LOSS 2
    SET TARGET %PROFIT 5
    ENDIF

    Your calculation of the monthly pivot were not good because you took the actual timeframe OHLC, which should be the Daily one that you can retrieve with DOPEN/DHIGH/DLOW/DCLOSE. I also add some bars to be preloaded in case it is needed.

    #10444 quote
    filiprb
    Participant
    Average

    Thank you Nicolas, i appreciate this! 🙂

    #13239 quote
    pivottrader
    Participant
    New

    Hi Guys

    I’m struggling with my monthly and weekly pivots. This is my code (PS – I’m not really following the logic. Just copying and trying to adjust here and there):

    Once lastMonthBarIndex = 0
    
    If Month <> Month[1] then
    monthlyHigh = Highest[BarIndex - lastMonthBarIndex](DHigh(1))
    monthlyLow = Lowest[BarIndex - lastMonthBarIndex](DLow(1))
    lastMonthBarIndex = BarIndex
    monthlyPivot = (Dclose(1) + monthlyHigh + monthlyLow) / 3
    ENDIF
    
    return monthlyPivot as "MPivot"

    However, my last month data is as follows:

    MHigh = 47144

    MLow = 44802

    MClose = 46201

    MOpen = 46201

    If I use the classic pivot calculation of (last month high + last month low + last month close) / 3 I get 46049. However the system shows a pivot of 46253? Why would it differ? How can I fix it please?

    Thanks and regards

    South-Africa-40-Cash-.png South-Africa-40-Cash-.png
    #13242 quote
    Nicolas
    Keymaster
    Master

    Maybe you can try first to see what values are returned by the calculation of the code and find how and why they are the ones actually calculated by it.

    return monthlyPivot as "MPivot", monthlyHigh as "high", monthlylow as "low", Dclose(1) as "monthly close"
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Pivot monthly strategi


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
filiprb @filiprb Participant
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by Nicolas
9 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/11/2016
Status: Active
Attachments: No files
Logo Logo
Loading...