# How to find vertex of RSI in definded Range

Good evening,
im quite new in AFL Programming and need some help.
Here is my problem:
I Want to mark the lowest vertex of the RSI Value within a variable period with an Setpoint named L. Additional i only need Setpoints which are RSI< "unten" (for example 30)
I tried a lot but still not get it.
Here is my basics:

``````range_L= Param("Range Low", 5, 1, 100, 1);
periods = Param( "Periods", 15, 1, 200, 1 );
unten= Param("Untergrenze", 30, 0, 49, 1);
setpoint_L=IIf(RSI(periods)<unten,1,0);
setpoint_TP=TroughBars(RSI(periods),per, 1)==0;
``````

how do i have to write the next:

L=IIf( lowest setpoint_TP within range_L AND setpoint_L==1 ,1,0);

i hope you understand my question. Here we get the point i'm looking for: Thank you very much!

The valuewhen() function along with barindex() function can get you the x - axis . The llv() function get the y- axis point.

Pseudo code

``````bi = barindex();
Lowestvalue = llv(rsi(periods),range);(y axis)
LowestvalueBar = valuewhen(L == lowestvalue, bi) ; (x-axis point reflected as barindex).

``````

Hello Metamega, thanks a lot for your hint. This helped a lot.

Now i can identify Lows, but as an error sometimes i get double-lows, if the second Low ist smaller then the first low.

For example: i think it's because the llv function is only looking into the future.

i was trying to write a for-Loop to find out if there was a higher low in the past range. This was my not working Result:

``````for( i = 0; i < (range_L+1); i++ )
{
LowestvalueBar=IIf(Lowestvalue> ValueWhen(Lowestvalue==RSI(periods), x+i),ValueWhen(Lowestvalue==RSI(periods), bi),ValueWhen(Lowestvalue==RSI(periods), bi+1));
}

``````

do you have a hint or a better idea for me?
Tanks a lot!

Trying to think. So you don’t want the lowest low value, you want the first occurrence that low crosses below 30?

llv() will return lowest low value over a set range. Llv(close,20), returns lowest low value of close over past 20 days.

Valuewhen() can allow future leaks if 3rd parameter is set to 0 or negative values.

FYI, upper line is not correct to get LLV() bar of RSI.
There are two mistakes:

1. Equality check `L == RSI` is not correct. Left side is price, right side is Indicator value.
2. To get bar of LLV() you should use `LLVBars`() not `ValueWhen`().
You will not get correct output with ValueWhen.

So correct line, e.g.

``````LowestvalueBar = Ref(BarIndex(), -LLVBars(Rsi(),30));
``````

Please do yourself a favour and plot LLV then you will see why ValueWhen is not correct way of getting location of lowest low.

As to the OP...

@Regenbogenhamster,
It is not really rock solid clear what you are actually looking for.
Do you look for lowest RSi being lower than 30 within visible range?
Or for the lowest RSI since cross below 30?
Or for the lowest LLV(RSI,period) since cross below 30?
Or for the lowest LLV(RSI, period) of visible range?
Or...?

Your post leaves too much room for guessing yet.

Hallo fxshrat,
i had no clue there are so many ways to understand my question, sorry for writing not clear.
i hope this picture will make it clear: L has the following conditions:
-has to be lower than 30

• has to be the lowest point in defined Range or otherwises two L's should not be closer than range_L
• it does not matter if RSI was crossing 30 or not within the range nor how many times it was crossing
• i want to mark every low, not only visible lows

if i use

``````Lowestvalue = llv((RSI(periods)),(range_Low));
``````

and print the Lowestvalue i only have the half of the Range (+ range_L). With this i will get the blue and the red points marked but i only want the red points to get marked.

i also tried to use (range_L*2) and introduce a second variable Lowestvalue_absolute. Then i tried to give the variable Lowestvalue_absolute the information of Lowestvalue with the distance "range_L", like shunting the information. But it also did not work.

Otherwise i could use the second variable Lowestvalue_absolut to compare Lowestvalues that are closer than range_L but i did not manage to write a comparison.

im sorry for explaning so difficult, it is hard for me to write it in english (Greetings from Europe!) also i realy start with coding AFL so often im missing the commands to use it right.

Thanks a lot for your help!

I don't think it is possible to know if an indicator has reached it's lowest value within a specified range until after it happens. But if you figure out how, please share! This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.