LoopParticipant
Senior
Dear All,
would it be possible to code on prorealtime the following stocastic / macd recently published on “Stock & Commodities”?
“Stochastic EMA12 = (12-day EMA – Lowest low) / (Highest high – Lowest low)
Stochastic EMA26 = (26-day EMA – Lowest low) / (Highest high – Lowest low)
STMACD = (Stochastic EMA12 – Stochastic EMA26) *100
Signal line: 9-day EMA of STMACD
where:
Lowest low = Lowest low for the lookback period
Highest high = Highest high for the lookback period
The STMACD is multiplied by 100 to move the decimal point two places
The default setting for the lookback period is 45″
Thanks a lot in advance for your reply
ML
There you go:
LookBack = 20
LL = lowest[LookBack](low)
HH = highest[LookBack](high)
StEMA12 = (Average[12,1](close) - LL) / (HH - LL)
StEMA26 = (Average[26,1](close) - LL) / (HH - LL)
StMACD = (StEMA12 - StEMA26) * 100
SigLine = Average[9,1](StMACD)
RETURN StEMA12 AS "Ema12",StEMA26 AS "Ema26",StMACD AS "Macd",SigLine AS "Signal",0 AS "Zero"
you can remove unwanted RETURN data or make it invisible with the indicator’s properties.
LoopParticipant
Senior
Thanks a lot for your extremly quick reply!
ML
LoopParticipant
Senior
Sorry… one more question… being a stochastic oscillator, shouldn’t have 100 as maximun value?
ML
It’s a combination of Stochastic and Macd. Each indicator/oscillator has different characteristics. Stochastic ranges from 0 to 100, Macd doesn’t.
Neither does this one.
Roberto code added as Log 216 here …
Snippet Link Library
Here is a version of Roberto’s code that normalizes the result between the highest ever result and the lowest ever result and returns it as a percentage of that range so it is between 0 and 100.
LookBack = 20
if barindex >= 26 then
LL = lowest[LookBack](low)
HH = highest[LookBack](high)
StEMA12 = (Average[12,1](close) - LL) / (HH - LL)
StEMA26 = (Average[26,1](close) - LL) / (HH - LL)
StMACD = (StEMA12 - StEMA26) * 100
SigLine = Average[9,1](StMACD)
hhmacd = max(sigline,max(hhmacd,stmacd))
llmacd = min(sigline,min(llmacd,stmacd))
macdperc = ((stmacd-llmacd)/(hhmacd-llmacd))*100
sigperc = ((sigline-llmacd)/(hhmacd-llmacd))*100
endif
RETURN macdperc as "StMACD" ,Sigperc AS "Signal",0 as "0",100 as "100"
Dear All
Useful posts and indicator, Do we have a screener available to use with this indicator?
Thanks