Trading Stratergy with EMA and RSI in PI with Tradescript gives Error - Please Help

Written a code based on EMA & RSI , the logic is

if RSI > 50 and EMA(close,13) > EMA(close,21) we are in bullish mode

if RSI < 50 and EMA(close,13) < EMA(close,21) we are in bearish mode

now if you turn from bullish to bearish mode we “SELL” and

if you turn from bearish to bullish mode we “BUY” .

FOR BUY :

SET A=EMA(CLOSE,13)
SET B=EMA(CLOSE,21)
SET C=RSI(CLOSE,9)
SET D=A-B

SET A1=REF(EMA(CLOSE,13),1)
SET B1=REF(EMA(CLOSE,21),1)
SET C1=REF(RSI(CLOSE,9),1)
SET D1=A1-B1

SET BUYNOW=IF((D>0 AND C>50),1,0)
SET SELLNOW=IF((D<0 AND C<50),1,0)
SET BUYPAST=IF((D1>0 AND C1>50),1,0)
SET SELLPAST=IF((D1<0 AND C1<50),1,0)

BUYNOW=1 AND SELLPAST=1


FOR SELL :

SET A=EMA(CLOSE,13)
SET B=EMA(CLOSE,21)
SET C=RSI(CLOSE,9)
SET D=A-B

SET A1=REF(A,1)
SET B1=REF(B,1)
SET C1=REF(C,1)
SET D1=REF(D,1)

SET BUYNOW=IF((D>0 AND C>50),1,0)
SET SELLNOW=IF((D<0 AND C<50),1,0)
SET BUYPAST=IF((D1>0 AND C1>50),1,0)
SET SELLPAST=IF((D1<0 AND C1<50),1,0)

SELLNOW=1 AND BUYPAST=1


i am getting ERROR :

your buy script generated an error : undefined function ‘F’

Please tell me where am i doing wrong and change the code to work.

Thanking you

RR2607

As per the above query you can use below simple condition

Buy Script:

RSI(CLOSE,14)>50 AND EMA(CLOSE,13)> EMA(CLOSE,21)

Sell Script:

RSI(CLOSE,14)<50 AND EMA(CLOSE,13)< EMA(CLOSE,21)

AlgoGeek  above code is not working in PI :-(

THE ABOVE CODE IS WORKING ON PI IF WE BACK TEST BUT IT IS OF NO USE SAME ALL THE OTHER CODES

Ok I’ll check today

hi, can u please help me…

i want to scan scripts over sold and over brought with RSI and STOCASTIC indicators, for example if i want to scan stocks over brought/sold in 5min time frame according to STOCASTIC indicator. please help me with this scanner.