EMA Today Plots only

BayTrader_93

New member
Hey guys, I have this code which plots the EMA D reading on every time frame. I have it adjusted so each plot is just a flat line so I dont need to manually plot the lines from the Daily. How can I adjust the code so when it plots on the chart that its only displaying the plots for the current day? thanks!

input Period = aggregationPeriod.DAY;
input AvgType = averageType.EXPONENTIAL;
input Length = 15;
input priceclose = close;

plot AVG = MovingAverage(AvgType, close(period = Period), Length);

AVG.setdefaultcolor(color.yellow);
AVG.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 

BayTrader_93

New member
###

1. input Period = aggregationPeriod.DAY;
2. input AvgType = averageType.EXPONENTIAL;
3. input Length = 15;
4. input priceclose = close;
5. input showOnlyLastPeriod = yes;
6.
7. if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]){
8. AVG = Double.NaN;
9.
10. } else {
11. AVG = Highest(high(period = aggregationPeriod)[-1]);
12.
13. plot AVG = MovingAverage(AvgType, close(period = Period), Length);
14.
15. AVG.setdefaultcolor(color.yellow);
16. AVG.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

###

Having trouble piecing this block of code together. On think script, the "if" on line 7 and the "{" on line 10 is highlighting and displaying invalid. Any help would be much appreciated.
 

Similar threads

Top