I am new to ThinkScript and trying to print a label for chart that says for e.g.
I want: $diff Close - EDMA21 = 4.50
I get: $diff 0-50 = 4.50
The challenge is, how do I create the string to display? Seems like I need some advanced conditional statements. If I try to concat the variables it just prints numbers?
I want: $diff Close - EDMA21 = 4.50
I get: $diff 0-50 = 4.50
The challenge is, how do I create the string to display? Seems like I need some advanced conditional statements. If I try to concat the variables it just prints numbers?
Code:
input price = close;
input Aggregation = AggregationPeriod.DAY;
input AvgType = AverageType.SIMPLE;
input Length = 50;
def diff = price - MovingAverage(AvgType, close(period = Aggregation), Length);
#def lname = concat(price, Aggregation + AvgType + Length );
#Labels
AddLabel(diff, Concat("$diff " ,AvgType + "-" + Length + " = " + Round(diff, 2)), CreateColor(107, 180, 4));
#AddLabel(diff, Concat("$diff " ,concat(price, Aggregation + AvgType + Length ) + " = " + Round(diff, 2)), CreateColor(107, 180, 4));