Indicator for highs/lows in a range
Forums › ProRealTime English forum › ProBuilder support › Indicator for highs/lows in a range
- This topic has 3 replies, 2 voices, and was last updated 5 months ago by RichardVeen.
-
-
06/19/2024 at 4:18 PM #234108
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.
06/21/2024 at 10:46 AM #234177Hi!
Here you have something to start working your own code:12345678910111213141516171819202122232425262728293031323334353637//-----Inputs------------------------------------------------------------------//bars=6x=20*pointsizeatr=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 thendrawtext("■",barindex[bars-1],high[bars-1]+0.5*atr)coloured("yellow")//-----Drawing Upper&Lower Limits------------------------------------------//hi=high[bars-1]+xlo=low[bars-1]-xdrawsegment(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 doif high[i]<hi and low[i]>lo thendrawtext("#i#",barindex[i],high[i]+0.25*atr)coloured("yellow")//-----Check for the highest Candle inside---------------------------//if high[i]>=Maxhigh thenMaxhigh=high[i]MaxhighX=barindex[i]MaxhighL=low[i]endifendifnextdrawtext("Highest",MaxhighX,MaxhighL-atr*0.5)coloured("yellow")endifreturn06/21/2024 at 3:08 PM #234197Thanks Iván,
I will test the code and adjust if needed.
I’ll let you know the results.
BR,
Richard
07/03/2024 at 2:54 PM #234747Hi 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.
-
AuthorPosts
Find exclusive trading pro-tools on