Detect cross 4 hour pivots? (incl. example)

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #225165 quote
    Robin81
    Participant
    Junior

    I am working on creating a strategy in which a candle passes through the lines of a 4-hour pivot. The formulas of the pivots correspond to IG Markets, so the values of the pivots correspond to the standard indicator in pro real time.
    The script below does not work during testing. It gives random results, but not when the lines go through a pivot. What am I overlooking here? In the attachment there is another image to explain the situation.

    Timeframe(4 hours)
    // Formula Pivots H4
    P4 = (high + low + close)/3
    P4R1 = (2*P4) - low
    P4R2 = P4 + high - low
    P4R3 = high + 2*(P4-low)
    P4R4 = P4R3 + (high - low)
    
    P4S1 = (2*P4) - high
    P4S2 = P4 - (high - low)
    P4S3 = low - 2*(high - P4)
    P4S4 = P4S3 - (high - low)
    
    Timeframe(default)
    
    Timeframe (1 minute)
    c1= high[1] > P4 AND low[1] < P4
    c2= (high[1] > P4R1 AND low[1] < P4R1) OR (high[1] > P4R2 AND low[1] < P4R2) OR (high[1] > P4R3 AND low[1] < P4R3) OR (high[1] > P4R4 AND low[1] < P4R4)
    c3= (high[1] > P4S1 AND low[1] < P4S1) OR (high[1] > P4S2 AND low[1] < P4S2) OR (high[1] > P4S3 AND low[1] < P4S3) OR (high[1] > P4S4 AND low[1] < P4S4)
    
    IF c1 OR c2 OR c3 THEN
    signal = 1
    screener [ signal > 0 ] sort by signal as "TEST"
    ENDIF
    Example-PRT.jpg Example-PRT.jpg
    #225167 quote
    JS
    Participant
    Veteran

    Hi @Robin81

    Remove “TimeFrame(Default)” in line 14

    A “screener” instruction in an “If… Then” isn’t going to work:

    If C1 or C2 or C3 then

    Signal=1

    EndIf

    Screener[Signal=1]

    #225186 quote
    Robin81
    Participant
    Junior
    @JS, I adjusted it, but to no avail. It still gives random notifications. It seems like he doesn’t want to take over the value of the pivot?
    #225194 quote
    JS
    Participant
    Veteran
    Try using High and Low instead of High[1] and Low[1]
    #225199 quote
    Robin81
    Participant
    Junior
    @JS, Just did it, but unfortunately without success. I chose [1] so that it looks at the recently closed candle. Unfortunately that’s not the problem. In any case, thanks for your thoughts.
    #225201 quote
    Robin81
    Participant
    Junior
    If I place the pivots as a ‘separate indicator’ under the graph, you see that the values of the outcome are equal to the standard pivot in PRT. So the formulas for all pivot values 4 hours are correct. Only detecting when a candle is closed on the line has not been possible so far 🙁
    P4.bmp P4.bmp
    #225210 quote
    JS
    Participant
    Veteran
    Hi, Try using: c1= high > P4[1] AND low < P4[1] (change also for c2 and c3)
    #225226 quote
    Robin81
    Participant
    Junior
    @JS, Do you know the reason why you use P4[1] instead of P4? Your idea was the right way, looks like it works! I am very curious about the explanation…. I will continue testing in the coming days. Thanks for your quick response, great!
    #225227 quote
    JS
    Participant
    Veteran

    Hi Robin,

    It’s great that it worked.

    For example, suppose you use a current price (Close) to check whether the price is higher or lower than the same current price (Close), then you understand that this is not going to work.

    The solution is to use the previous price (Close[1]) and check it with the current price…

    Close>Close[1] or in this case High>P4[1]

    #226653 quote
    qigley
    Participant
    Junior
    Hi @Robin81 A “screener” instruction in an “If… Then” isn’t going to work:
    Not correct. You can use a SCREENER command in an IF statement.
    #226654 quote
    JS
    Participant
    Veteran

    That’s right, that was already clear and was not the problem…

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

Detect cross 4 hour pivots? (incl. example)


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Robin81 @robin81 Participant
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by JS
2 years, 1 month ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 12/13/2023
Status: Active
Attachments: 2 files
Logo Logo
Loading...