Good evening, hope you are doing great.
I have been writing a code that involves labels with the "AddLabel()" function but I want to know if it's possible to use the function switch and select from a drop-down menu if I want for example 2 labels to appear, is this possible? I haven't been able to do it since the switch statement needs to define or plot something before and that can't be done with this function.
I attached the code for a better understanding of what I want, any help in order to do this from a single menu (not selecting which one I want and which one doesn't individually), will be greatly appreciated, thank you very much in advance.
I have been writing a code that involves labels with the "AddLabel()" function but I want to know if it's possible to use the function switch and select from a drop-down menu if I want for example 2 labels to appear, is this possible? I haven't been able to do it since the switch statement needs to define or plot something before and that can't be done with this function.
I attached the code for a better understanding of what I want, any help in order to do this from a single menu (not selecting which one I want and which one doesn't individually), will be greatly appreciated, thank you very much in advance.
Code:
input MovingAverages = {default "1", "2", "3", "4", "5"};
input Price = close;
input ma1Length = 10;
input AverageTypeMa1 = AverageType.EXPONENTIAL;
input ma2Length = 20;
input AverageTypeMa2 = AverageType.EXPONENTIAL;
input ma3Length = 30;
input AverageTypeMa3 = AverageType.EXPONENTIAL;
input ma4Length = 40;
input AverageTypeMa4 = AverageType.EXPONENTIAL;
input ma5Length = 50;
input AverageTypeMa5 = AverageType.EXPONENTIAL;
input Value = 100;
def MA1 = MovingAverage(AverageTypeMa1, Price, ma1Length);
def MA2 = MovingAverage(AverageTypeMa2, Price, ma2Length);
def MA3 = MovingAverage(AverageTypeMa3, Price, ma3Length);
def MA4 = MovingAverage(AverageTypeMa4, Price, ma4Length);
def MA5 = MovingAverage(AverageTypeMa5, Price, ma5Length);
AddLabel(MovingAverages, MA1);
plot Label;
switch (MovingAverages){
case "1":
Label = AddLabel(yes,MA1);
}