Buffer contains a single value for a bar. How do you suggest to pack OHLC (4 values) and direction (+1 value) into a single buffer element? If you want OHLC (4) + direction mark (1) for every M1 in M15 bar, then you need 15*5 buffers.
No problem, limit is 512
Yes lot's of data stored but I think that it won't exceed the limit. 15 bar of 1M needs 7 slot (date,time, open,close,low,high,direction) + 1 bar of 15M needs other 7 lslot = so total of 16*7 = 112 buffers.
To have it a little bit simpler, maybe 5 arrays, as below, that store the previous 1M minute data would be good + 1 array that stores the data for the 15M candle.
double close_data[]; double open_data[]; double high_data[]; double low_data[]; double direction_data[]; int OnInit() { IndicatorBuffers(5); SetIndexBuffer(0, close_data); SetIndexBuffer(1, open_data); SetIndexBuffer(2, high_data); SetIndexBuffer(3, low_data); SetIndexBuffer(4, direction_data); ArraySetAsSeries(close_data,true); ArraySetAsSeries(open_data,true); ArraySetAsSeries(high_data,true); ArraySetAsSeries(low_data,true); ArraySetAsSeries(direction_data,true); return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { CopyClose(Symbol(),PERIOD_M1,1,15,close_data); CopyOpen(Symbol(),PERIOD_M1,1,15,open_data); CopyHigh(Symbol(),PERIOD_M1,1,15,high_data); CopyLow(Symbol(),PERIOD_M1,1,15,low_data); for (int i=1;i<=15;i++) { if (close_data[i]> open_data[i]) { direction_data[i]=0; } if (close_data[i]<= open_data[i]) { direction_data[i]=1; } } return(0); }
I have tried to re-write it in mql4 but results are not good...
No problem, limit is 512
The problem was that OP did not reserve and use these buffers in the initial source code, while his explanation in the pseudo-code implied this.
Ok, if it's simplified to 5 buffers, and if I understand correctly, you need to copy only one M1 value into i-th bar on M15 for every OHLC+D slot. On i+1 bar you'd copy from another M1 bar corresponding to the next M15 bar and so on. Currently you copy M1 into M15 flatly, i.e. display M1 bars in M15 chart.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have started to look at MQL5, which is quite hard even if I have some informations about MQL4.
What I would like to do is to have in the data window (as an indicator), for each 15M candle, buffers of the 1M candles data that composed the 15M candle.
At the same time have the direction of the candle: 1 (open>close), 0 (close>open) for both the series of 1M candles and the 15M candle.
For example:
So in this way I will be able to use the information collected by the indicator in a concise way.
I have tried something like this, using the CopyRates but I don't exactly have an idea and it is clearly wrong:
Please have a look at this, thaks for your attention