As far as I know, MetaTrader only uses minute charts. The best solution depends on your case:
(a) You can calculate the MACD values for a multiple of the original chart period (for example if you have a 5-minute chart, you can calculate the MACD for 10-minute, 15-minute, bars etc. , or if you have a 233-tick chart, you can calculate the MACD based on 466-tick bars, 699-tick bars. Those values can be calculated from the original bar series.
(b) To speed up the indicator you can use a different MACD formula to calculate them from the original bar series only. I have already coded such an indicator.
(c) A real multi-timeframe indicator is more difficult to code and needs to load a secondary bar series. There are some limitations to its use, when being called by a strategy. However you are very flexible, you can for example display an MACD calculated from 1000-volume bars on 8-Renko chart.
(a) requires synthetic bars, indicator coding is difficult
(b) fastest indicator, as there is a specific solution for the MACD (which is itself a derivative of EMAs)
(c) more work to code it properly
The difficulty is the treatment of the unstable period. To understand this imagine a MACD calculated from hourly bars displayed on a 5-min chart. When the hour is not closed, all hourly MACD values are preliminary, so if price moves up or down you would eventually need to repaint until the beginning of the hour, unless you accept to use the value at the end of the prior hour.
The solution (b) is a special approach which will work without repainting.
So you would need to explain, what you really need, and what you don't.
The one of I have uses minute charts which is fine for me.
I can have open any timeframe chart, and can choose what 'macd timeframe' I want (which colours the background of my current chart, based on whether it's crossed up or down)
The issue of the unstable period is sometimes apparent. Yesterday my chart was light green as if the bigger timeframe MACD was crossed up, although if you went to the bigger timeframe, the macd was actually crossed down.
This I assume is because it was waiting for the bigger timeframe's bar to end. It later re-painted the indicator which I didn't much like.
In an ideal world, there'd maybe be a setting to be able to choose how it handles the unstable period, although for now, whilst playing around with some ideas, I'd be happy with anything.
The problem with the unstable period can be handled if you tweak the MACD formula. The MACD is based on a few EMAs and each of the EMAs has a smoothing constant k. All you need to do is to calculate a new smoothing constant for the higher timeframe. For example if your larger timeframe MACD is N times the bar period, then you can calculate the new smoothing constant k_new as 1 - Nth root of (1-k). This will not get you the original MACD, but something that comes very close, and you will benefit from two huge advantages
-> unstable period reduced to the last bar of the smaller timeframe
-> lower CPU load
I have already once tweaked a MACDOverlay, which is shown in the chart attached. However, this is not what you look for, as the four MACDs below are normalized to allow for the overlay. The classic MACD does not have any normalization.
Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).
NinjaTrader does not store historical bid and ask data. The VisualSMA also works with historical data, and does not use bid or ask data. Basically no moving average does.
The Visual SMA loads a secondary bar series (minute, tick, volume, range or Renko) and calculates the moving average by using that bar series. All calculations use the last price traded either historical data from the historical data base, or real-time data when connected to a datafeed or replay data.
The result is then displayed on the chart with the primary bars. The main advantage of the VisualSMA is that you can calculate a moving average from a secondary bar series without paying the price of non-equidistant bar spacing. If you do not mind unevenly spread bars, then you do not need the VisualSMA.
The following user says Thank You to Fat Tails for this post:
I 'm trying to use "VisualSMA" with displacement (positive number) and there is small issue with line plot color (last bar only) that paints with default gray color instead the selected rising/falling colors.
I've noticed that this behavior exist in all indicators that use "PlotColors[x]"
And my way to solve this in my indicators, is to use the inverse displacement value in "PlotColors"
I hope you will have time to check this issue.
The following user says Thank You to Erez for this post: