Greetings,
Below is the code I'm using for showing EMA 13 along with a bubble.
I want to be able to specify an aggregation period to use for the EMA, regardless of my chart timeframe.
I usually watch 3 or 5 min chart, but, I'd like to use the 13 daily EMA. How would I add that aggregation period into this code.
I tried to add
into my plot statement, but I could get it right.
Any assistance would be greatly appreciated
Below is the code I'm using for showing EMA 13 along with a bubble.
I want to be able to specify an aggregation period to use for the EMA, regardless of my chart timeframe.
I usually watch 3 or 5 min chart, but, I'd like to use the 13 daily EMA. How would I add that aggregation period into this code.
I tried to add
Code:
(period = AggregationPeriod.Day)
Any assistance would be greatly appreciated
Code:
#
input price = close;
input length = 13;
input displace = 0;
input location = {default OffSet, LastBar, RightEdge};
input BubbleOffset = 5;
def bar = BarNumber();
def lb = if !IsNaN(close) and IsNaN(close()[-1]) then bar else Double.Nan;
def lastBar = highestAll(lb);
def position;
switch (location) {
case RightEdge:
position = bar == HighestAll(bar);
case LastBar:
position = bar == lastBar;
CASE Offset:
position = bar == lastbar + BubbleOffset;
}
plot ma1 = MovingAverage(AverageType.EXPONENTIAL, price, length);
ma1.SetDefaultColor(Color.CYAN);
def data2 = if !IsNaN(ma1) then ma1 else data2[1];
AddChartBubble(position, data2, length + " EMA", Color.CYAN);