declare upper; #--- Inputs input length = 5; input tradetype = { default "long", "short", "both" }; input paintbars = yes; input showVerticalLines = yes; input sharesize = 1; #--- End Inputs #--- RSI and Smoothed Inverse RSI Calculation def R = reference RSI(length, close) - 50; def AvgRSI = MovingAverage(AverageType.Exponential,R,9); def iRSI = (Power(Double.E, 2 * AvgRSI) - 1) / (Power(Double.E, 2 * AvgRSI) + 1); def Inverse_RSI = iRSI; #--- End RSI and Smoothed Calculation #--- Add VerticalLine def sqzAlert = reference TTM_Squeeze().SqueezeAlert; #Hint -Used for candle price color # and sqzAlert == 1 AddVerticalLine(showVerticalLines and (tradetype == tradetype.long or tradetype == tradetype.both) and (iRSI > 0) and (iRSI[1] < 0), "Entry BUY", Color.GRAY); AddVerticalLine(showVerticalLines and (tradetype == tradetype.short or tradetype == tradetype.both) and (iRSI[1] > 0) and (iRSI < 0), "Entry SELL", Color.YELLOW); AssignPriceColor(if paintbars and (tradetype == tradetype.long or tradetype == tradetype.both) and iRSI > 0 then Color.GREEN else if paintbars and (tradetype == tradetype.short or tradetype == tradetype.both) and iRSI < 0 then Color.RED else if paintbars then Color.GRAY else Color.Current); AddOrder(OrderType.BUY_TO_OPEN, iRSI > 0 and iRSI[1] < 0 and (tradetype == tradetype.long or tradetype == tradetype.both), open, tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "LONG",tradeSize = sharesize); AddOrder(OrderType.SELL_TO_CLOSE, iRSI < 0 and iRSI[1] > 0 and (tradetype == tradetype.long or tradetype == tradetype.both),open, tickcolor = GetColor(9), arrowcolor = GetColor(9), name = "LONG_EXIT", tradeSize = sharesize); AddOrder(OrderType.SELL_TO_OPEN,iRSI < 0 and iRSI[1] > 0 and (tradetype == tradetype.short or tradetype == tradetype.both),open, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "SHORT", tradeSize = sharesize); AddOrder(OrderType.BUY_TO_CLOSE, iRSI > 0 and iRSI[1] < 0 and (tradetype == tradetype.short or tradetype == tradetype.both),open, tickcolor = GetColor(8), arrowcolor = GetColor(8), name = "SHORT_EXIT", tradeSize = sharesize);; def Buy = (iRSI > 0) and (iRSI[1] < 0); def Sell = (iRSI[1] > 0) and (iRSI < 0); # Alerts Alert(Buy, "UP arrow alert", Alert.Bar, Sound.Chimes); Alert(Sell, "DOWN arrow alert", Alert.Bar, Sound.Chimes);