NOTE (Jan 31, 2014): Any indicators or EAs that I've contributed to this thread will probably no longer work in the latest MT4 build that is (if I understand correctly) due to be rolled out on Feb 3. If you want to ensure that these indicators/EAs continue to work correctly, do NOT upgrade your MT4 beyond the current build (509). I don't know how to re-code them to make them run correctly in the new look MT4, and I've no desire to re-educate myself to learn the new programming language that MetaQuotes is forcing upon everybody. Personally I think that their short-sighted development policy totally stinks, but there's nothing I can do about it. So if you decide to upgrade, you're on your own. Please note the Terms and Conditions below.
______________________
In the James16 chart thread (http://www.forexfactory.com/showpost...postcount=3522) I expressed the possibility of creating more pin bars, BUOBs, BEOBs, etc, to increase possible trading opportunities, by aggregating price bars into new timeframes (e.g. H1 into H2, H3, H6, H8, etc; D1 into D2, D3 etc), and also possibly with ‘shifted’ starting times (e.g. H4 bars at 1:00, 2:00, 3:00, 5:00 etc, instead of the usual 0:00, 4:00, 8:00, etc).
The attached CandleAggregator.MQ4 indicator is my attempt to facilitate this. I’m afraid the coding is a little rough; I’m fairly new to MQL4 programming.
Install in the usual manner, i.e. unzip into the \experts\indicators\ folder.
Attach the indicator to your chart (there are no DLL imports), and set the parameters to suit, as explained below. Like Heiken-Ashi, the aggregated candles display over the top of the OHLC candles on your chart. To see the aggregated candles more clearly, first press F8 and change the ‘Line graph’ color to None, then switch to a line chart (press Alt-3). Press Alt-2 to restore the component OHLC candles.
The parameters work as follows:
AggrFactor: the number of component candles to be aggregated into a single one. For example, if you want H3 candles, move to an H1 chart and set the AggrFactor to 3.
TimeShift: This is the number of bars to the left to ‘shift’ the start of the aggregation process. The default is zero which means no shift. Obviously, to be meaningful, this value should be less than AggrFactor. Can also be used to perform a timezone shift of a standard chart (AggrFactor = 1). Experiment to suit.
AggrBackward: default is ‘false’, which causes the aggregated candle to be displayed over the leftmost candle in the group being aggregated. ‘True’ means that the aggregated candle will display over the rightmost candle in the group. The size and the shape of the candle is not affected by this setting, just the place where it is plotted on the chart.
InterCandles: ‘true’ causes all of the intermediate candles to be displayed, i.e. component candles are being aggregated into multiple consecutive candles. Probably not very useful!
SwitchOff: ‘true’ suppresses the plotting of the aggregate candles, allowing you to view the component OHLC candles, without having to remove the indicator from the chart.
A green candle means the Close is higher than the Open; a red candle, vice versa.
If the aggregated candles are spaced too far apart for your liking, press the minus key to ‘zoom in’, as required.
There seems to be a small problem when a new tick causes the chart to start plotting a new OHLC candle. (Seems to be an MT4 quirk; perhaps a more experienced programmer could suggest a fix?). Meantime, editing the indicator (Ctrl-I etc) redraws the aggregate candles correctly.
Screenshot in attached ZIP.
David
______________________
In the James16 chart thread (http://www.forexfactory.com/showpost...postcount=3522) I expressed the possibility of creating more pin bars, BUOBs, BEOBs, etc, to increase possible trading opportunities, by aggregating price bars into new timeframes (e.g. H1 into H2, H3, H6, H8, etc; D1 into D2, D3 etc), and also possibly with ‘shifted’ starting times (e.g. H4 bars at 1:00, 2:00, 3:00, 5:00 etc, instead of the usual 0:00, 4:00, 8:00, etc).
The attached CandleAggregator.MQ4 indicator is my attempt to facilitate this. I’m afraid the coding is a little rough; I’m fairly new to MQL4 programming.
Install in the usual manner, i.e. unzip into the \experts\indicators\ folder.
Attach the indicator to your chart (there are no DLL imports), and set the parameters to suit, as explained below. Like Heiken-Ashi, the aggregated candles display over the top of the OHLC candles on your chart. To see the aggregated candles more clearly, first press F8 and change the ‘Line graph’ color to None, then switch to a line chart (press Alt-3). Press Alt-2 to restore the component OHLC candles.
The parameters work as follows:
AggrFactor: the number of component candles to be aggregated into a single one. For example, if you want H3 candles, move to an H1 chart and set the AggrFactor to 3.
TimeShift: This is the number of bars to the left to ‘shift’ the start of the aggregation process. The default is zero which means no shift. Obviously, to be meaningful, this value should be less than AggrFactor. Can also be used to perform a timezone shift of a standard chart (AggrFactor = 1). Experiment to suit.
AggrBackward: default is ‘false’, which causes the aggregated candle to be displayed over the leftmost candle in the group being aggregated. ‘True’ means that the aggregated candle will display over the rightmost candle in the group. The size and the shape of the candle is not affected by this setting, just the place where it is plotted on the chart.
InterCandles: ‘true’ causes all of the intermediate candles to be displayed, i.e. component candles are being aggregated into multiple consecutive candles. Probably not very useful!
SwitchOff: ‘true’ suppresses the plotting of the aggregate candles, allowing you to view the component OHLC candles, without having to remove the indicator from the chart.
A green candle means the Close is higher than the Open; a red candle, vice versa.
If the aggregated candles are spaced too far apart for your liking, press the minus key to ‘zoom in’, as required.
There seems to be a small problem when a new tick causes the chart to start plotting a new OHLC candle. (Seems to be an MT4 quirk; perhaps a more experienced programmer could suggest a fix?). Meantime, editing the indicator (Ctrl-I etc) redraws the aggregate candles correctly.
Screenshot in attached ZIP.
David
Attached File(s)