- "iCustom" Alternative
- Can a function return more than just one value?
- Backtesting/Optimization
In my terminal I have "Max bar in chart" set to 7200. However, working with onCalculate function I have found that rates_amount sometimes is bigger that this value. Sometimes instead of 7200 there is 150.000 bars (full M1 history). It causes an issue to me because I work with MqlRates instead of open, high, low, close... arrays. Since the function CopyRates can not return bars more than TERMINAL_MAXBARS and indicator buffer size is larger than number of bars I have there is wrong indicator rendering. I can set unlimited amount of bars in chart but I think it is not rational to calculate unused history - I need only one working week.
If you are talking about mt5 is a bug. You don't expect solution because I sent ticket and they didn't give any answer
If you are talking about mt5 is a bug. You don't expect solution because I sent ticket and they didn't give any answer
I am. Is there a public link to this ticket? I am not familiar with their bug report system. Anyway, thank you.
I am. Is there a public link to this ticket? I am not familiar with their bug report system. Anyway, thank you.
Tickets to service desk are private. You can send them one for report bugs
In my terminal I have "Max bar in chart" set to 7200. However, working with onCalculate function I have found that rates_amount sometimes is bigger that this value. Sometimes instead of 7200 there is 150.000 bars (full M1 history). It causes an issue to me because I work with MqlRates instead of open, high, low, close... arrays. Since the function CopyRates can not return bars more than TERMINAL_MAXBARS and indicator buffer size is larger than number of bars I have there is wrong indicator rendering. I can set unlimited amount of bars in chart but I think it is not rational to calculate unused history - I need only one working week.
There's an easy solution... limit the indicator loop to total rates copied and index your buffers from right to left.
MqlRates rates[]; ArrayGetAsSeries(rates,true); ArraySetAsSeries(Volume_Buffer,true); int limit = CopyRates(Symbol(),Period(),0,Bars(Symbol(),Period()),rates); for(int i=limit-1;i>=0;i--) { Volume_Buffer[i] = rates[i].tick_volume; }
There's an easy solution... limit the indicator loop to total rates copied and index your buffers from right to left.
Thank you for idea, I completely forgot about array order. I will try to implement it.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use