Pivot Point “Standard” indicator code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #183025 quote
    abel1986abel1986
    Participant
    New

    Hello, anyone able to provide the code for the pivot point “standard” indicator for the several timeframes? (daily, weekly, monthly and yearly?)

    I got only the daily version:

    Ht = DHigh(1)
    Bs = DLow(1)
    C = DClose(1)
    
    IF dayofweek = 1 THEN
    Ht = DHigh(2) 
    Bs = DLow(2) 
    C = DClose(2)
    ENDIF
    
    Pivot = (Ht + Bs + C) / 3
    Res3 = Ht + ((Pivot - Bs)*2)
    Res2 = Pivot + Ht - Bs
    Res1 = (2 * Pivot) - Bs
    Sup1 = (2 * Pivot) - Ht
    Sup2 = Pivot - (Ht - Bs)
    Sup3 = Bs - ((Ht-Pivot)*2)
    
    
    return Pivot as "Point Pivot", Res1 as "R1", Res2 as "R2", Res3 as "R3", Sup1 as "S1", Sup2 as "S2", Sup3 as "S3"

    thanks in advance for your support

    #183072 quote
    JSJS
    Participant
    Master
    //Pivot calculation method
    Once mode = 1
     
    Once dailyPivot = undefined
    Once dailyR1 = undefined
    Once dailyS1 = undefined
    Once dailyR2 = undefined
    Once dailyS2 = undefined
    Once dailyR3 = undefined
    Once dailyS3 = undefined
     
    Once lastWeekBarIndex = 0
    Once weeklyHigh = undefined
    Once weeklyLow = undefined
    Once weeklyPivot = undefined
    Once weeklyR1 = undefined
    Once weeklyS1 = undefined
    Once weeklyR2 = undefined
    Once weeklyS2 = undefined
    Once weeklyR3 = undefined
    Once weeklyS3 = undefined
     
    Once lastMonthBarIndex = 0
    Once monthlyHigh = undefined
    Once monthlyLow = undefined
    Once monthlyPivot = undefined
    Once monthlyR1 = undefined
    Once monthlyS1 = undefined
    Once monthlyR2 = undefined
    Once monthlyS2 = undefined
    Once monthlyR3 = undefined
    Once monthlyS3 = undefined
     
    If Day>Day[1] then
     If mode = 0 then
      dailyPivot = (DHigh(1) + DLow(1) + Close[1]) / 3
     Elsif mode = 1 then
      dailyPivot = (Open + DHigh(1) + DLow(1) + Close[1]) / 4
     Elsif mode = 2 then
      dailyPivot = (DHigh(1) + DLow(1) + Close[1]*2) / 4
     Else
      dailyPivot = (Open*2 + DHigh(1) + DLow(1)) / 4
     Endif
     dailyR1 = 2*dailyPivot - DLow(1)
     dailyS1 = 2*dailyPivot - DHigh(1)
     dailyR2 = dailyPivot + (DHigh(1) - DLow(1))
     dailyS2 = dailyPivot - (DHigh(1) - DLow(1))
     dailyR3 = dailyR1 + (DHigh(1) - DLow(1))
     dailyS3 = dailyS1 - (DHigh(1) - DLow(1))
    Endif
     
    If DayOfWeek<DayOfWeek[1] then
     weeklyHigh = Highest[BarIndex - lastWeekBarIndex](High)[1]
     weeklyLow = Lowest[BarIndex - lastWeekBarIndex](Low)[1]
     lastWeekBarIndex = BarIndex
     
     If mode = 0 then
      weeklyPivot = (weeklyHigh + weeklyLow + Close[1]) / 3
     Elsif mode = 1 then
      weeklyPivot = (Open + weeklyHigh + weeklyLow + Close[1]) / 4
     Elsif mode = 2 then
      weeklyPivot = (weeklyHigh + weeklyLow + Close[1]*2) / 4
     Else
      weeklyPivot = (Open*2 + weeklyHigh + weeklyLow) / 4
    Endif
     weeklyR1 = 2*weeklyPivot - weeklyLow
     weeklyS1 = 2*weeklyPivot - weeklyHigh
     weeklyR2 = weeklyPivot + (weeklyHigh - weeklyLow)
     weeklyS2 = weeklyPivot - (weeklyHigh - weeklyLow)
     weeklyR3 = weeklyR1 + (weeklyHigh - weeklyLow)
     weeklyS3 = weeklyS1 - (weeklyHigh - weeklyLow)
    Endif
     
    If Month<>Month[1] then
     monthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
     monthlyLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
     lastMonthBarIndex = BarIndex
     
     If mode = 0 then
      monthlyPivot = (monthlyHigh + monthlyLow + Close[1]) / 3
     Elsif mode = 1 then
      monthlyPivot = (Open + monthlyHigh + monthlyLow + Close[1]) / 4
     Elsif mode = 2 then
      monthlyPivot = (monthlyHigh + monthlyLow + Close[1]*2) / 4
     Else
      monthlyPivot = (Open*2 + monthlyHigh + monthlyLow) / 4
     Endif
     monthlyR1 = 2*monthlyPivot - monthlyLow
     monthlyS1 = 2*monthlyPivot - monthlyHigh
     monthlyR2 = monthlyPivot + (monthlyHigh - monthlyLow)
     monthlyS2 = monthlyPivot - (monthlyHigh - monthlyLow)
     monthlyR3 = monthlyR1 + (monthlyHigh - monthlyLow)
     monthlyS3 = monthlyS1 - (monthlyHigh - monthlyLow)
    Endif
    
    #183073 quote
    JSJS
    Participant
    Master

    The above code comes from the forum by Henry.

    abel1986 thanked this post
    #183690 quote
    abel1986abel1986
    Participant
    New

    Thank you very much JS! Unfortunately as soon as I try to draw it I got the following message:

    “A positive integer field is expected with Highest”

    Any suggestion?

    #183694 quote
    JSJS
    Participant
    Master

    Hi @abel1986

    The code is from the library and I am not familiar with Pivot’s.

    I am sure @Nicolas or @Roberto will know the answer.

    abel1986 thanked this post
    #183696 quote
    abel1986abel1986
    Participant
    New

    Solved, I should have I included: DEFPARAM CalculateOnLastBars = something…

    thanks again JS

    JS thanked this post
    #183699 quote
    fifi743fifi743
    Participant
    Master

    add barindex

     

    if barindex>0 then
    If Month<>Month[1] then
    monthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
    monthlyLow = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
    lastMonthBarIndex = BarIndex
     
    If mode = 0 then
    monthlyPivot = (monthlyHigh + monthlyLow + Close[1]) / 3
    Elsif mode = 1 then
    monthlyPivot = (Open + monthlyHigh + monthlyLow + Close[1]) / 4
    Elsif mode = 2 then
    monthlyPivot = (monthlyHigh + monthlyLow + Close[1]*2) / 4
    Else
    monthlyPivot = (Open*2 + monthlyHigh + monthlyLow) / 4
    Endif
    monthlyR1 = 2*monthlyPivot - monthlyLow
    monthlyS1 = 2*monthlyPivot - monthlyHigh
    monthlyR2 = monthlyPivot + (monthlyHigh - monthlyLow)
    monthlyS2 = monthlyPivot - (monthlyHigh - monthlyLow)
    monthlyR3 = monthlyR1 + (monthlyHigh - monthlyLow)
    monthlyS3 = monthlyS1 - (monthlyHigh - monthlyLow)
    Endif
    endif
Viewing 7 posts - 1 through 7 (of 7 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

Pivot Point “Standard” indicator code


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
abel1986 @abel1986 Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by fifi743fifi743
4 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/08/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...