Hi,
I have tried to integrate the RSI indicator to plot only the Up and Down Signals on the Stochastic indicator provided by TOS but no luck.
Can someone take a look and possible make it work? Thanks in advance.
declare lower;
input length = 20;
input over_Bought_RSI = 70;
input over_Sold_RSI = 30;
input bullish_dash_rsi = 80;
input bearish_dash_rsi = 20;
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 OverSold_RSI = over_Sold_RSI + if IsNaN(close) then Double.NaN else 0;
def OverBought_RSI = over_Bought_RSI + if IsNaN(close) then Double.NaN else 0;
def bullish_zone = bullish_dash_rsi + if IsNaN(close) then Double.NaN else 0;
def bearish_zone = bearish_dash_rsi + if IsNaN(close) then Double.NaN else 0;
def MidLine = 50 + if IsNaN(close) then Double.NaN else 0;
def OverSold = over_Sold_RSI + if IsNaN(close) then Double.NaN else 0;
def OverBought = over_Bought_RSI + if IsNaN(close) then Double.NaN else 0;
######################################################
input over_bought = 50.0;
input over_sold = -50.0;
input over_bought_dash = 40.0;
input over_sold_dash = -40.0;
input percentDLength = 5;
input percentKLength = 50;
input colorNormLength = 12;
def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
#smi.setDefaultColor(getColor(1));
SMI.DefineColor("High", Color.CYAN);
SMI.DefineColor("Low", Color.MAGENTA);
SMI.AssignNormGradientColor(colorNormLength, SMI.Color("Low"), SMI.Color("High"));
plot AvgSMI = ExpAverage(SMI, percentDLength);
AvgSMI.SetDefaultColor(GetColor(5));
plot overbought_S = over_bought + if IsNaN(close) then Double.NaN else 0;
overbought_S.SetDefaultColor(GetColor(5));
plot overbought_dash = over_bought_dash + if IsNaN(close) then Double.NaN else 0;
overbought_S.SetDefaultColor(GetColor(5));
plot oversold_S = over_sold + if IsNaN(close) then Double.NaN else 0;
oversold_S.SetDefaultColor(GetColor(5));
plot oversold_dash = over_sold_dash + if IsNaN(close) then Double.NaN else 0;
oversold_S.SetDefaultColor(GetColor(5));
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN + SMI;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN + SMI;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Any updates on this will be highly appreciated. Thanks.
Can someone help fixing this script please?
I have tried to integrate the RSI indicator to plot only the Up and Down Signals on the Stochastic indicator provided by TOS but no luck.
Can someone take a look and possible make it work? Thanks in advance.
declare lower;
input length = 20;
input over_Bought_RSI = 70;
input over_Sold_RSI = 30;
input bullish_dash_rsi = 80;
input bearish_dash_rsi = 20;
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 OverSold_RSI = over_Sold_RSI + if IsNaN(close) then Double.NaN else 0;
def OverBought_RSI = over_Bought_RSI + if IsNaN(close) then Double.NaN else 0;
def bullish_zone = bullish_dash_rsi + if IsNaN(close) then Double.NaN else 0;
def bearish_zone = bearish_dash_rsi + if IsNaN(close) then Double.NaN else 0;
def MidLine = 50 + if IsNaN(close) then Double.NaN else 0;
def OverSold = over_Sold_RSI + if IsNaN(close) then Double.NaN else 0;
def OverBought = over_Bought_RSI + if IsNaN(close) then Double.NaN else 0;
######################################################
input over_bought = 50.0;
input over_sold = -50.0;
input over_bought_dash = 40.0;
input over_sold_dash = -40.0;
input percentDLength = 5;
input percentKLength = 50;
input colorNormLength = 12;
def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diff = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
#smi.setDefaultColor(getColor(1));
SMI.DefineColor("High", Color.CYAN);
SMI.DefineColor("Low", Color.MAGENTA);
SMI.AssignNormGradientColor(colorNormLength, SMI.Color("Low"), SMI.Color("High"));
plot AvgSMI = ExpAverage(SMI, percentDLength);
AvgSMI.SetDefaultColor(GetColor(5));
plot overbought_S = over_bought + if IsNaN(close) then Double.NaN else 0;
overbought_S.SetDefaultColor(GetColor(5));
plot overbought_dash = over_bought_dash + if IsNaN(close) then Double.NaN else 0;
overbought_S.SetDefaultColor(GetColor(5));
plot oversold_S = over_sold + if IsNaN(close) then Double.NaN else 0;
oversold_S.SetDefaultColor(GetColor(5));
plot oversold_dash = over_sold_dash + if IsNaN(close) then Double.NaN else 0;
oversold_S.SetDefaultColor(GetColor(5));
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN + SMI;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN + SMI;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Any updates on this will be highly appreciated. Thanks.
Can someone help fixing this script please?
Last edited by a moderator: