Hi everyone
I am trying to write a basic indicator code that implement William% and RSI to find deep and top of the market this is the code that I was able to write, but it does not work so It is clearly wrong.
can anyone be so nice to check it and help me out?
thanks
I am trying to write a basic indicator code that implement William% and RSI to find deep and top of the market this is the code that I was able to write, but it does not work so It is clearly wrong.
can anyone be so nice to check it and help me out?
thanks
Code:
# buy the deep
input length = 14;
input oversold = 30;
input overbought = 70;
input WprPeriod = 24;
# WPR Indicator
def HH = highest(high, WprPeriod);
def LL = lowest(low, WprPeriod);
def WPR = (HH - close) / (HH - LL) * -100;
# RSI Indicator
def NetChgAvg = WildersAverage(close - close[1], length);
def TotChgAvg = WildersAverage(AbsValue(close - close[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
# Buy/Sell Signals
def buySignal = if RSI crosses above oversold and WPR > -20 then 1 else 0;
def sellSignal = if RSI crosses below overbought and WPR < -80 then 1 else 0;
# Plot Signals
plot buy = if buySignal then low - 2.5 else Double.NaN;
Buy.setdefaultColor(color.dark_GREEN);
Buy.hidetitle();
plot sell = if sellSignal then high + 2.5 else Double.NaN;
sell.setDefaultColor(color.red);
Sell.hidetitle();
buy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
sell.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);