netarchitech
Well-known member
@Svanoy : Thank you for your latest reply and continuing guidance...The label functionality works great...
The last remaining issue is the plotting of the arrows...as illustrated below...
I got it! If you bang your head against the wall long enough, you either find the answer you were looking for or you pass out
One more thing...how about coloring the appropriate candles to show when the signal is valid, so you can keep your eyes on the price action...
@Nich76 @jay2 : Below please find the final code complete with working Arrows, Labels and Alerts...
Good Luck and Good Trading
The last remaining issue is the plotting of the arrows...as illustrated below...
I got it! If you bang your head against the wall long enough, you either find the answer you were looking for or you pass out
One more thing...how about coloring the appropriate candles to show when the signal is valid, so you can keep your eyes on the price action...
@Nich76 @jay2 : Below please find the final code complete with working Arrows, Labels and Alerts...
Code:
declare lower;
def na = Double.NaN;
script normalizer {
input data = close;
input Min = 0;
input Max = 100;
input length = 50;
def hhData = Highest(data, length);
def llData = Lowest(data, length);
plot resized = (((Max - Min) * (data - llData)) /
(hhData - llData)) + Min;
}
### Relative Strength Index (RSI) ###
input length = 14;
input price = close;
def averageType = AverageType.WILDERS;
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);
plot x = normalizer(RSI);
x.SetDefaultColor(Color.GREEN);
x.SetLineWeight(3);
### True Strength Index (TSI) ###
input longLength = 25;
input shortLength = 13;
input averageType2 = AverageType.EXPONENTIAL;
def diff = close - close[1];
def doubleSmoothedAbsDiff = MovingAverage(averageType2, MovingAverage(averageType2, AbsValue(diff), longLength), shortLength);
def TSI;
TSI = if doubleSmoothedAbsDiff == 0 then 0
else 100 * (MovingAverage(averageType2, MovingAverage(averageType2, diff, longLength), shortLength)) / doubleSmoothedAbsDiff;
plot y = normalizer(TSI);
y.SetDefaultColor(Color.RED);
y.SetLineWeight(3);
AddCloud(x, y, Color.GREEN, Color.RED);
### Arrows, Labels, Alerts and Colored Price Action ###
def RSICrossAbove = x crosses above y;
def RSICrossBelow = x crosses below y;
def cross1 = if RSICrossAbove then x else Double.NaN;
def cross2 = if RSICrossBelow then x else Double.NaN;
plot x1 = cross1;
x1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
x1.SetLineWeight(3);
x1.SetDefaultColor(Color.YELLOW);
plot x2 = cross2;
x2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
x2.SetLineWeight(3);
x2.SetDefaultColor(Color.YELLOW);
AddLabel(if RSICrossAbove then yes else no, "RSI crossed above TSI" , Color.LIGHT_GREEN);
AddLabel(if RSICrossBelow then yes else no, "RSI crossed below TSI" , Color.PINK);
Alert(RSICrossAbove, "RSI crossed above TSI" , Alert.BAR, Sound.Bell);
Alert(RSICrossBelow, "RSI crossed below TSI" , Alert.BAR, Sound.Bell);
AssignPriceColor(if RSICrossAbove then Color.YELLOW else if RSICrossBelow then Color.YELLOW else Color.CURRENT);
Good Luck and Good Trading