Monthly pivot

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #71574 quote
    jean.stiker
    Participant
    Junior

    Hi everyone,

    I looked for an answer before publishing my question, then sory  if someone already replied for a similar question.

    So, I try to have monthly pivot (code below), and to display via SCREENER.

    it don’t work, and display 0 (zero), i don’t know why !

    My questions are :

    1. do my monthly pivot calculation is right ?
    2. why it don’t detect anything, and display “0”?

     

    ====CODE===
    
    ONCE LastMonthBarIndex = BarIndex
    // Monthly data setting
    ONCE monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
    ONCE monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
    ONCE monthlyC = DClose(1)
    ONCE monthlyO = Open[BarIndex - lastMonthBarIndex]
    ONCE mPivot = (monthlyO + monthlyH + monthlyL + monthlyC) / 4
    If month <> Month[1] then
    monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
    monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
    monthlyC = DClose(1)
    monthlyO = Open[BarIndex - lastMonthBarIndex]
    mPivot = (monthlyO + monthlyH + monthlyL + monthlyC) / 4
    ENDIF
    c1 = mPivot > 1
    SCREENER[c1] (mPivot AS "% dPivot")//SCREENER[c3 AND c4] (mPivot < wPivot AS "% dPivot")

    Thanks, and many green pips / ticks for everybody.

    Jean

    #71577 quote
    Vonasi
    Moderator
    Master

    Please use the ‘Insert PRT Code button when putting code in your posts as it makes it far easier for others to read. I have tidied your post up for you 🙂

    Hopefully someone will be along with an answer soon….

    #71586 quote
    jean.stiker
    Participant
    Junior

    Hi vonasi,

    thanks a lot

    #71605 quote
    robertogozzi
    Moderator
    Master

    Practicing with the search utility won me this link https://www.prorealcode.com/prorealtime-indicators/daily-weekly-monthly-pivot-points/.

    You may win more!

    #71649 quote
    jean.stiker
    Participant
    Junior

    Hi and thanks for the answer…

    I forget to tell that it for a screener.

    I tried the solution in the link above , the screener display “0” for all products selected !

    I don’t really know what is wrong !

    Once lastMonthBarIndex = 0
    Once monthlyH = undefined
    Once monthlyL = undefined
    Once mPivot = undefined
    If month <> Month[1] then
    monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
    monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
    LastMonthBarIndex = BarIndex
    mPivot = (Open + monthlyH + monthlyL + Close[1]) / 4
    ENDIF
    SCREENER[c1 AND c2 OR c3 AND c4] (mPivot AS "% dPivot")

    thans for everything

    Jean

    #71659 quote
    robertogozzi
    Moderator
    Master

    Screeners are not applicable to MONTHLY TF, Weekly is the highest one. But you can calculate monthly pivots and use them in a lower TF.

    The screener is missing variable C1, C2, C3 and C4.

    #71684 quote
    jean.stiker
    Participant
    Junior

    Hi RobertoGozzi, thanks for the answer,

    effectively, I posted the old code, here is the new :

    Once lastMonthBarIndex = 0
    Once monthlyH = undefined
    Once monthlyL = undefined
    Once mPivot = undefined
    If month <> Month[1] then
    monthlyH = Highest[BarIndex - lastMonthBarIndex](High)[1]
    monthlyL = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
    LastMonthBarIndex = BarIndex
    mPivot = (Open + monthlyH + monthlyL + Close[1]) / 4
    ENDIF
    c1 = mPivot < High
    SCREENER[c1] (mPivot AS "% mPivot")

    Ok, there is no mean to have directly the monthly pivot, but the code above allow to calculate it (i’m not sure for the open price). once the monthly pivot calculated, i would like to display it with the last code line (SCREENER[c1] (mPivot As “% mPivot”).

    But instead I only have “0” for all rows, how can i correct that ?

    I hope I’m enough clear…

    don’t hesitate if I can clerify more.

    Thanks and cheers

    Jean

    #71700 quote
    robertogozzi
    Moderator
    Master

    I tried this code as an indicator and it works perfectly (see screenshot):

    If Month<>Month[1] then
       monthlyHigh = Highest[BarIndex - lastMonthBarIndex](High)[1]
       monthlyLow  = Lowest[BarIndex - lastMonthBarIndex](Low)[1]
       lastMonthBarIndex = BarIndex
       monthlyPivot = (Open + monthlyHigh + monthlyLow + Close[1]) / 4
    Endif
    x = high > monthlyPivot
    y = -(low < monthlyPivot)
    Return x OR y,0

    While the same code as a screener on a 4-hour TF does not return any valid scan for HIGH > monthlypivot or LOW < monthlypivot.

    I guess it may be that ProScreener can only scan at most 255 bars (the current one + the previous 254), while highest and lowest use more!

    Pivot-indicator.jpg Pivot-indicator.jpg Pivot-screener.jpg Pivot-screener.jpg
    #71703 quote
    robertogozzi
    Moderator
    Master

    The solution could be to use it as an indicator and then code a screener that reads the values returned by the indicator.

    I’ll have a try.

    #71711 quote
    robertogozzi
    Moderator
    Master

    It doesn’t work either.

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

Monthly pivot


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

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

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 05/29/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...