Well guys, the first part is done ( reading all pairs rates ).
Now i need use the rates of all paris copied with the function ArrayCopyRates to pot some graphic indicators like an RSI... as i draw in the image below:
In my initial question i intend know how to do this... and not about reading rates. I do not think i will need to copy rates before to draw it, but was good to know how to do... now i just need to discover a way to split the indicator area to plot all pairs...
There is no way to split the indicator area. Everything must be drawn separately, no buffers, no auto scaling. See
Did you see such a picture? (MetaQuotes Software Corp.) - MQL4 forum - Page 12Did you see such a picture? (MetaQuotes Software Corp.) - MQL4 forum - Page 14Did you see such a picture? (MetaQuotes Software Corp.) - MQL4 forum - Page 36
This is a Indicator I picked up somewhere, I never tried to decipher it. I shows a representation of 3 timeframes of the current chart. The crazy thing is the candles are drawn with Histograms. Pretty neat but not what I am into right now.
An update to those following this thread!
I have been helping the OP via PM fix his code as he has difficulty with English and we both speak Portuguese. In our testing we came across another "funny" that is happening with the "ArrayCopyRates()" function. When using an MqlRates array with "ArrayCopyRates()" in an EA, the data array is a virtual one that always reports the current status of things, so data is always fresh.
However, in an Indicator, this does not seem to be the case. The array is not a virtual copy but instead a static copy set in time at the moment that the "ArrayCopyRates()" was called. The data does not update when the Symbol is different to the chart symbol. When it is the same symbol as the chart, then the array data is "live" and updates as expected, but when it is of another symbol, it is a static copy.
So, in order for it to work in an Indicator, one must call the"ArrayCopyRates()" function on every call to OnCalculate() event if fresh data is needed.
Just to expand your findings Fernando - even if symbol is the same as chart symbol, if the timeframe is different then the array is static.
So in order to have a virtual copy, in an indicator, it must be the same symbol AND the same timeframe. Anything else is static.
Assuming it is mid week to find the high and low of previous day I simply use:
That's fine, but now I need to find on the previous day what time was the high and the low. I decided to aproximate the time to the 1h candle at high and low using iHighest and iLowest. And that's when the problems begun.
After a few ticks the data is partially loaded and the piece of code above will detect that the lines have been plotted on a previous day, delete the fib and trigger a recalculation of the ranges and redraw of the objects (i.e. fib, trendlines, etc).
CurrDayBegin = iTime(NULL, PERIOD_D1, 0); while(TimeDayOfWeek(iTime(NULL, PERIOD_H1, iBarShift(NULL, PERIOD_H1, CurrDayBegin))) != TimeDayOfWeek(TimeCurrent()))
// If iBarShift can't find the 0am candle and returns the 11pm candle of prev day.
These are screenshots of the indicator:
(1) Calculated using incomplete history (please notice the horizontal lines don't start at the beginning of the day)
(2) Recalculated using the complete history (horizontal lines starting at the beginning of the day)