Hi, my objective is to get the current aggregation of the chart, and then based on what the chart aggregation is, do conditional actions. In the first code example below I am getting the current aggregation with getAggregationPeriod() and feed it into a swich block and case compare with aggregationPeriod, but that gives an error.
I also tried just using a string for the case compare and that gives fewer errors, but still shows as an error for the switch statement. This is shown in the below code block.
Any ideas on why this is an error and how to use getCurrentAggregation() in a conditional?
Code:
def currentAggregation;
def trendAggregation;
def stopAggregation;
currentAggregation = getAggregationPeriod();
switch (currentAggregation) {
case aggregationPeriod.FIVE_MIN:
trendAggregation = aggregationPeriod.HOUR;
stopAggregation = aggregationPeriod.FIFTEEN_MIN;
}
plot Data = close;
I also tried just using a string for the case compare and that gives fewer errors, but still shows as an error for the switch statement. This is shown in the below code block.
Code:
def currentAggregation;
def trendAggregation;
def stopAggregation;
currentAggregation = getAggregationPeriod();
switch (currentAggregation) {
case "5m":
trendAggregation = aggregationPeriod.HOUR;
stopAggregation = aggregationPeriod.FIFTEEN_MIN;
}
plot Data = close;
Any ideas on why this is an error and how to use getCurrentAggregation() in a conditional?