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.

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) ) );

Filter = Buy OR Sell;
AddColumn(RSI(14), "RSI", 1.0,colorDefault);
AddColumn(HHV(RSI(14),14), "H_RSI", 1.0,colorDefault);
AddColumn(LLV(RSI(14),14), "L_RSI", 1.0,colorDefault);
AddColumn(BuyRSI, "BuyValue", 1.0,colorDefault);
AddColumn(SellRSI, "SellValue", 1.0,colorDefault);


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.

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))

RSI = Current RSI reading;
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).

Click on the link below for more information:

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…

BUY SCRIPTS : Stochastic RSI<20

SELL SCRIPTS : Stochastic RSI >80

No alerts on Pi Scanner>>
I have added the following code for BUY and SELL

  1. BUY Script
    REF(CLOSE,1)/REF(CLOSE,5)>=1.003 OR

  2. SELL Script
    REF(CLOSE,5)/REF(CLOSE,1)>1.003 OR

But there are no ALERTS generated on the SCANNER… The Alert Time is same for all the STOCKS symbol selected…
Why is the Pi Scanner not Generating Alerts? but when I BACKTEST this same script is workdin…
This is for 1min Bar Interval