5 min EMA AND daily pivot points : distance from price

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #90670 quote
    Sébi
    Participant
    Junior

    Hello,

    Is it possible to screen at the same time the markets that meet the following conditions : the distance between the actual price and the closest daily pivot point AND the distance between the actual price and the 5 min EMA [21] is inferior to a certain number?

    I could make the program for both and it works, but when I mix them in a single program, either it will show the conditions for a 5 min timeframe (the pivot points are no more the daily ones) or for a daily timeframe (the EMA is no more a 5 min EMA).

    I fail to understand (I am a beginner with ProScreener) why when I launch the program with the option “5 min timeframe” the daily pivot points are no more the daily ones. Here is the beginning of the program for the calculation of the pivot points. The instructions DHigh(1), Dlow(1) and DClose(1) should refer to the previous day, not to the previous candle, shouldn’t it?

    Ht = DHigh(1)
    L = DLow(1)
    C = DClose(1)

    Pt = (Ht + L + C) / 3
    Re4 = Pt + ((Ht – L)*3)
    Re3 = Pt + ((Ht – L)*2)
    Re2 = Pt + Ht – L
    Re1 = (2 * Pt) – L
    Su1 = (2 * Pt) – Ht
    Su2 = Pt – (Ht – L)
    Su3 = Pt – ((Ht – L)*2)
    Su4 = Pt – ((Ht – L)*3)
    mRe1 = (Pt + Re1) / 2
    mSu1 = (Pt + Su1) / 2
    mRe2 = (Re1 + Re2) / 2
    mSu2 = (Su1 + Su2) / 2

    #90686 quote
    Nicolas
    Keymaster
    Master

    Your assumption is right, this code should work on any other timeframe than the daily one and return the correct daily pivot points. On what instrument did you made your tests?

    With this code, on a 5-minute TF, the right pivot point value is correctly returned:

    Ht = DHigh(1)
    L = DLow(1)
    C = DClose(1)
    
    Pt = (Ht + L + C) / 3
    
    screener(pt)
    #91002 quote
    Sébi
    Participant
    Junior

    Thank you Nicolas.

    It does not give me the proper pivot points when I select “5 minutes” as a time frame for currencies (I need to select “journalier” for getting the correct ones). Surprisingly, it gives the correct pivot points for the indices in any timeframe selected. Any idea why it is so?

    Capture-d’écran-2019-02-11-à-4.57.07-AM.png Capture-d’écran-2019-02-11-à-4.57.07-AM.png
    #91114 quote
    Sébi
    Participant
    Junior

    The problem happens only with 5 min time frame and less (smaller the time frame, bigger the difference with the daily pivot points). With 10 min and higher time frame, the pivot points are correct and the same. Strange indeed.

    #91123 quote
    robertogozzi
    Moderator
    Master

    Replace line 7 with:

    screener[pt]
    #91149 quote
    Sébi
    Participant
    Junior

    Thanks for your reply Roberto.

    Below is what I wrote :
    It shows the markets which price is near EMA21 or any Pivot point. My lonely problem is that the pivot points are not what they suppose to be when I choose to screen with a 5min TimeFrame or less.

    Ht = DHigh(1)
    L = DLow(1)
    C = DClose(1)
    
    Pt = (Ht + L + C) / 3
    Re4 = Pt + ((Ht - L)*3)
    Re3 = Pt + ((Ht - L)*2)
    Re2 = Pt + Ht - L
    Re1 = (2 * Pt) - L
    Su1 = (2 * Pt) - Ht
    Su2 = Pt - (Ht - L)
    Su3 = Pt - ((Ht - L)*2)
    Su4 = Pt - ((Ht - L)*3)
    mRe1 = (Pt + Re1) / 2
    mSu1 = (Pt + Su1) / 2
    mRe2 = (Re1 + Re2) / 2
    mSu2 = (Su1 + Su2) / 2
    
    ema = ExponentialAverage[21]
    price = close
    
    cema = abs(ema-price)
    cp = abs(Pt-price)
    cr1 = abs(Re1-price)
    cr2 = abs(Re2-price)
    cr3 = abs(Re3-price)
    cr4 = abs(Re4-price)
    cs1 = abs(Su1-price)
    cs2 = abs(Su2-price)
    cs3 = abs(Su3-price)
    cs4 = abs(Su4-price)
    cmr1 = abs(mRe1-price)
    cmr2 = abs(mRe2-price)
    cmS1 = abs(mSu1-price)
    cmS2 = abs(mSu2-price)
    
    If price < 90 then
    
    // conditions pour le forex
    
    if cema<0.0005 then
    criteria = ROUND(cema*10000)
    elsif cp<0.0005 OR cr1<0.0005 OR cr2<0.0005 OR cr3<0.0005 OR cr4<0.0005 OR cs1<0.0005 OR cs2<0.0005 OR cs3<0.0005 OR cs4<0.0005 OR cmr1<0.0005 OR cmr2<0.0005 OR cmS1<0.0005 OR cmS2<0.0005 then
    criteria = Pt
    endif
    
    Filter1 = cema<0.0006 OR cp<0.0005 OR cr1<0.0005 OR cr2<0.0005 OR cr3<0.0005 OR cr4<0.0005 OR cs1<0.0005 OR cs2<0.0005 OR cs3<0.0005 OR cs4<0.0005 OR cmr1<0.0005 OR cmr2<0.0005 OR cmS1<0.0005 OR cmS2<0.0005
    
    elsif price > 1000 then
    
    // conditions pour les indices
    
    if cema<6 then
    criteria = ROUND(cema)
    elsif cp<6 OR cr1<6 OR cr2<6 OR cr3<6 OR cr4<6 OR cs1<6 OR cs2<6 OR cs3<6 OR cs4<6 OR cmr1<6 OR cmr2<6 OR cms1<6 OR cms2<6 then
    criteria = Pt
    endif
    
    Filter2 = cema<6 OR cp<6 OR cr1<6 OR cr2<6 OR cr3<6 OR cr4<6 OR cs1<6 OR cs2<6 OR cs3<6 OR cs4<6 OR cmr1<6 OR cmr2<6 OR cms1<6 OR cms2<6
    
    endif
    
    Filter = Filter1 OR Filter2
    
    SCREENER [Filter](criteria)
    #91156 quote
    robertogozzi
    Moderator
    Master

    To write code, please use the <> “insert PRT code” button, to make code easier to read (I tided it up for you). Thank you.

    Sébi thanked this post
    #91180 quote
    Nicolas
    Keymaster
    Master

    It’s normal since ProScreener has a limitation of 254 bars. If you want to know the pivot points from yesterday, use the TIMEFRAME instruction.

    Replace line 7 with:

    It was not the purpose of the code to screen a condition 🙂

    robertogozzi and Sébi thanked this post
    #91208 quote
    Sébi
    Participant
    Junior

    The TIMEFRAME instruction does not help.

    #91216 quote
    Nicolas
    Keymaster
    Master

    A short template on how-to with the TIMEFRAME instruction:

    TIMEFRAME(daily)
    Ht = High[1]
    L = Low[1]
    C = Close[1]
     
    Pt = (Ht + L + C) / 3
    Re4 = Pt + ((Ht - L)*3)
    Re3 = Pt + ((Ht - L)*2)
    Re2 = Pt + Ht - L
    Re1 = (2 * Pt) - L
    Su1 = (2 * Pt) - Ht
    Su2 = Pt - (Ht - L)
    Su3 = Pt - ((Ht - L)*2)
    Su4 = Pt - ((Ht - L)*3)
    mRe1 = (Pt + Re1) / 2
    mSu1 = (Pt + Su1) / 2
    mRe2 = (Re1 + Re2) / 2
    mSu2 = (Su1 + Su2) / 2
    
    TIMEFRAME(default)
    //put here the rest of the code ...
    #91248 quote
    Sébi
    Participant
    Junior

    This is what I wrote (except that I put (1) instead of [1]), but it did not change the results. The lonely solution seems to be working on a 10 min timeframe instead of a 5 min one.

    #91298 quote
    Nicolas
    Keymaster
    Master

    No, this is not what you wrote, High[1] is not the same as DHigh(1), please try the above solution.

    I can’t replicate your issue, this is why I’d like you to test the code I gave on the last post, thank you.

    #91430 quote
    Sébi
    Participant
    Junior

    Splendid!
    It does work now. I now understand that with the instruction TIMEFRAME(daily) I should not use Dhigh() but only high[], etc.
    Thank you Nicolas!

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

5 min EMA AND daily pivot points : distance from price


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Sébi @sebiji Participant
Summary

This topic contains 12 replies,
has 3 voices, and was last updated by Sébi
7 years ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 02/07/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...