Hello all. I'm trying to cut and paste together a code that will show an up arrow on the bar where the MACD value, average are above 0, and the RSI is above 50. Also a down arrow for the opposite. One problem (of many) I have is that I would like the MACD to be exponential, and the RSI to be Wilders. Here is what I have put together, but does not work:
Code:
input fastLength = 3;
input slowLength = 6;
input MACDLength = 20;
input averageType = AverageType.EXPONENTIAL;
plot Value = MACD(fastLength, slowLength, MACDLength, averageType).Value;
plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;
plot ZeroLine = 0;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
#input averageType = AverageType.Exponential;
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;
plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot UpSignal = if RSI crosses above OverSold then OverSold else Double.NaN;
plot DownSignal = if RSI crosses below OverBought then OverBought else Double.NaN;
plot MidLine = 50;
plot BUYSignal = (Value > 0) and (Avg > 0) and (RSI crosses above 50);
plot SELLSignal = (Value < 0) and (Avg < 0) and (RSI crosses below 50);
BUYSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BUYSignal.SetDefaultColor(Color.Blue);
SELLSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SELLSignal.SetDefaultColor(Color.RED);
[CODE]
ANY help appreciated, thank you.