i have the following code but couldn't figure out why the error is generated.
Trying to label the value based on the input selection.
Any help will be appreciated
Trying to label the value based on the input selection.
Any help will be appreciated
Code:
#Moving Average of 8/50/200 EMA/SMA (6 different combination)
#AverageType.SIMPLE = 0 averageType.EXPONENTIAL = 1 AverageType.WEIGHTED = 2 AverageType.WILDERSAverage = 3 AverageType.HULL = 4
input Period = AggregationPeriod.DAY;
input AvgType = AverageType.EXPONENTIAL;
### input Tag = {default SMA , EMA};
#input Length = {default 8, 50, 200}; #Error
input Length = {default "8", "50", "200"}; # NO Error. this integer or text?
input priceclose = close;
def tag;
#Both block of code generate error.
if AvgType = 0 {
tag = "SMA";
} else if AvgType = 1{
tag = "EMA";
}
switch AvgType{
case 0:
tag = "SMA";
case 1:
tag = "EMA";
case 2:
tag = "WGHT";
}
def AVG = MovingAverage(AvgType, close(period = Period), Length); #Error
AddLabel(yes, Length + " " + tag + ": " + Round(AVG, 2), if close > AVG then Color.GREEN else Color.RED);
#
Last edited by a moderator: