PMA derives the length of its rendered SMA from the number of periods (example: 5 days) and the length of the period (example: 390 minutes)
The result is an indicator that should be the same across different time-frames of the same type. Allowing for the simple calculation and generation of a Daily Moving Average like the 5 Day SMA (the default for minute based time-frames).
Catatan Rilis
⋅
Change-list:
Now allows for targeting varying moving average types. Now SMA, WMA, and EMA are options.
A float value is now used to allow for more fine tuning.
I want to combine the 50 Periodical Average with a 21 Exponential Moving Average. I inserted this code, but it is not working. It only shows the 21 EMA and not the periodical. Can you help?
//@version=4
study(shorttitle = "50 PMA vs. 21 EMA", title="50 PMA vs. 21 EMA", overlay=true)
//@version=4
study(shorttitle = "50 PMA vs. 21 EMA", title="50 PMA vs. 21 EMA", overlay=true)
src = input(close, title="Source")
periods = input(5.0, minval=0.01, title="Periods")
mode = input(title="Mode", defval="EMA", options=["SMA", "WMA", "EMA"])
plen = input(390, minval=1, title="Period Length")
len = ceil(periods * plen / timeframe.multiplier)
ma =
mode=="EMA" ? ema(src, len) :
mode=="WMA" ? wma(src, len) :
sma(src, len)
plot(ma, color=color.red, linewidth=2, title="PMA")
MAPeriod1 = input(21, title="MA Period 1")
MA1 = ema(close, MAPeriod1)
plot(MA1, color=color.green, linewidth=2)