Indicator for highs/lows in a range

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #234108 quote
    RichardVeen
    Participant
    Junior

    Hi,

    I’m looking for an indicator which indicates the following:

    – The high/lows of max. 6 candles and min. of 2 candles within a range of 2 points (8 ticks)

    If the highs/lows of 1 of the 6 candles is out of range (more than 2 points of the high/low of candle 1), then this candle is not part of the indicator calculation.

    – The trigger for the indicator is: it should counting after a reversal candle is being created

     

    For example: 

    1. If the highs of 6 candles within the range of 2 points, then if will indicate the highest candle

    2. if the highs of 4 candles within the range of 2 points, then if will indicate the highest candle. 

    If the fifth candle is more than 2 points than candle 1, then the fifth candle will not be part of calculation and the sixth candle will automatically also not be part of the calculation.

    3. After the sixth candle the calculation for the indicator will start again.

     

    Attached 2 screenshots:

    In screenshot 1 a reversal candle is being created and then the indicator should be triggered and check the last 6 candles for the lowest low within the range of 2 points.

     

    In screenshot 2 a reverse candle is being created and then the indicator should be triggered and the last 6 candles should be checked. The high of the 4th candle is more than 2 points higher than the high of candle 1, it should not be part of the indicator calculation. In this situation, candle 3 has the highest high.

    #234177 quote
    Iván González
    Moderator
    Master

    Hi!
    Here you have something to start working your own code:

    //-----Inputs------------------------------------------------------------------//
    bars=6
    x=20*pointsize
    atr=averagetruerange[14](close)
    //----------------------------------------------------------------------------//
    //-----Reversal Condition-----------------------------------------------------//
    reversal=(close>open and close[1]<open[1]) or (close < open and close[1]>open[1])
    
    sumreversal=summation[bars](reversal)
    //----------------------------------------------------------------------------//
    //-----Identify Reversal Candle-----------------------------------------------//
    if reversal[bars-1]  and sumreversal[bars-1]=1 then
    drawtext("■",barindex[bars-1],high[bars-1]+0.5*atr)coloured("yellow")
    //-----Drawing Upper&Lower Limits------------------------------------------//
    hi=high[bars-1]+x
    lo=low[bars-1]-x
    drawsegment(barindex[bars-1],hi,barindex,hi)coloured("yellow")style(dottedline)
    drawsegment(barindex[bars-1],lo,barindex,lo)coloured("yellow")style(dottedline)
    //-----Count Candles inside Limits-----------------------------------------//
    Maxhigh=high[bars-1]
    MaxhighX=barindex[bars-1]
    MaxhighL=low[bars-1]
    for i=bars-1 downto 0 do
    if high[i]<hi and low[i]>lo then
    drawtext("#i#",barindex[i],high[i]+0.25*atr)coloured("yellow")
    //-----Check for the highest Candle inside---------------------------//
    if high[i]>=Maxhigh then
    Maxhigh=high[i]
    MaxhighX=barindex[i]
    MaxhighL=low[i]
    endif
    endif
    next
    drawtext("Highest",MaxhighX,MaxhighL-atr*0.5)coloured("yellow")
    endif
    
    return
    #234197 quote
    RichardVeen
    Participant
    Junior

    Thanks Iván,

    I will test the code and adjust if needed.

    I’ll let you know the results.

    BR,

    Richard

    #234747 quote
    RichardVeen
    Participant
    Junior

    Hi Iván,

    I have tested and the result is ok but it gives not yet the result I wanted.

    Attached a screenshot of the result of the code and below my remarks:

    • The numbers doesn’t need to be visible
    • Only the yellow ‘square’ need to be visible, so I know when the indicator starts counting
    • Only a highest candle need to be highlighted,  for example with an arrow or an other figure.
    • When the highest bar of the previous range of bars (max. 6 bars) has been highlighted then the indicator need to ‘scan’ the next candles for the highest or lowest candle within a range of 2 points
    • When the reversal is a red candle, then the indicator need to check for the lowest candle within 2 points and when the reversal a green candle, the indicator need to check the highest candle.

    I don’t have the code knowledge to modify the code to process my remarks so hopefully you can help.

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

Indicator for highs/lows in a range


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by RichardVeen
1 year, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/19/2024
Status: Active
Attachments: 2 files
Logo Logo
Loading...