Calculate EMA on the median ((high+low/2)) ?
-
Where can I change the data point from the close to the median price? Also, how can I increase the decimal's displayed for an indicator? For example, a TRIX indicator that shows x.xx values default and be able to display x.xxxx. Thanks!!
-
To get a line for ema as you ask...
self.myema = bt.ind.EMA((self.datas[0].high / self.datas[0].low) /2 )
When printing use the format
:.4f
-
@run-out said in Calculate EMA on the median ((high+low/2)) ?:
To get a line for ema as you ask...
self.myema = bt.ind.EMA((self.datas[0].high / self.datas[0].low) /2 )
Thanks, so I am getting an error:
"....bt.indicators.ExponentialMovingAverage((self.datas[0].high / self.data[0].low) /2, period=100)
AttributeError: 'float' object has no attribute 'low' "Original code for the EMA: bt.indicators.ExponentialMovingAverage(self.datas[0], period=100)
Updated to do the median: bt.indicators.ExponentialMovingAverage((self.datas[0].high / self.data[0].low) /2, period=100)
and getting that error.
Thanks for your help!
-
it should be:
bt.indicators.ExponentialMovingAverage((self.datas[0].high / self.datas[0].low) /2, period=100)
-
@ab_trader Thank! Rookie mistake....ok, so it complies with no errors but gives the wrong value. I'm running it on the SPY daily, which the 100EMA(close) plots fine (305ish), but the new code for the 100EMA(median), gives a value way low (0.51). Ideas?
-
This should fix your issues:
bt.indicators.ExponentialMovingAverage((self.datas[0].high + self.datas[0].low) /2, period=100) -
@ab_trader Thanks for all your help here and a few other posts! !