l requst you plz make coording for Backtest of Pi. EXPERT ADVISORY

BUY SCRIPTS {(RSI - Lowest Low RSI) / (Highest High RSI - Lowest Low RSI)} <20

SELL SCRIPTS {(RSI - Lowest Low RSI) / (Highest High RSI - Lowest Low RSI)} >80

Highest High and Lowest Low of how many candles.

1 Like

By default 14 candles. RSI means 14 candles RSI.

Skeleton AFL Code is as follows.

``````_SECTION_BEGIN("RSI_CUSTOM");
Buy = ( ( RSI(14) - LLV(RSI(14),14) ) / ( HHV(RSI(14),14) - LLV(RSI(14),14) ) ) < 20;
Sell = ( (RSI(14) - LLV(RSI(14),14) ) / ( HHV(RSI(14),14) - LLV(RSI(14),14) ) ) > 80;

BuyRSI = ( (RSI(14) - LLV(RSI(14),14) ) / ( HHV(RSI(14),14) - LLV(RSI(14),14) ) );
SellRSI = ( (RSI(14) - LLV(RSI(14),14) ) / ( HHV(RSI(14),14) - LLV(RSI(14),14) ) );

_SECTION_END();
``````

It appears that your formula is not correct. See the screenshot. Reliance 25th March 2019 12 : 00 PM RSI(14) was 35. Highest RSI of last 14 Candles was 65 and lowest was 33. So the calculation {(RSI - Lowest Low RSI) / (Highest High RSI - Lowest Low RSI)} comes at 0.06.

1 Like

This formula is ‘‘Stochastic RSI’’. I had read this formula on the calculation trading view website. The link to which is given below.

Stochastic RSI CALCULATION
In this example, a very common 14 Period Stoch RSI is used.

Stoch RSI = (RSI - Lowest Low RSI) / (Highest High RSI - Lowest Low RSI)

### The Formulas For the Stochastic RSI (StochRSI) are

StochRSI= (RSI - min (RSI)) / (max (RSI)-−min (RSI))

Where:
Lowest RSI = Lowest RSI reading over last 14 periods (or chosen lookback period); and
Highest RSI = Highest RSI reading over last 14 period (or lookback period).

A StochRSI reading above 0.8 is considered [overbought], while a reading below 0.2 is considered [oversold].

Values of 80 and 20 were mentioned in the original post.

So after the correction of comparison values the formula works fine.

Dear Sir,
l request you plz make cording…

SELL SCRIPTS : Stochastic RSI >80