```
##############################################################################################
input length = 7;
input over_Bought = 60;
input over_Sold = 40;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def BEAR = over_Sold;
def BULL = over_Bought;
def UpSignal = if RSI crosses above BEAR then BEAR else Double.NaN;
def DownSignal = if RSI crosses below BULL then BULL else Double.NaN;
#RSI ALERT
def Bearish = RSI crosses below 60;
def Bullish = RSI crosses above 40;
Alert(Bullish, ” EMA Possible SIGNAL UP ”, Alert.BAR, Sound.Ding);
Alert(Bearish, " EMA2 Possible SIGNAL DOWN ", Alert.BAR, Sound.Ding);
#For Orders
def TradeSize = 2;
def Ent = RSI("length" = 7)."RSI" crosses above 60 ;
def Ext = RSI("length" = 7)."RSI" crosses below 60 or RSI("length" = 7)."RSI" >= 85;
AddOrder(OrderType.BUY_TO_OPEN, Ent, close, TradeSize);
AddOrder(OrderType.SELL_TO_CLOSE, Ext, close, TradeSize);
#request by ykd2018x
#1. 5 MIN CHART time frame ,
#def TradeSize =2;
#def Ent= RSI("length" = 7)."RSI" crosses above 60 ;
#close condition , if/when rsi =85 close it /// OR cross below 60 close it
##############################################################################################
```