If you want that the index 1 array value would return you the previous bar you have to turn your MA arrays to series first, otherwise (by default) it will return you the 2nd oldest bar.
Put it into OnInit() function:
ArraySetAsSeries(maArray1, true); ArraySetAsSeries(maArray2, true); ArraySetAsSeries(maArray3, true);
If you want that the index 1 array value would return you the previous bar you have to turn your MA arrays to series first, otherwise (by default) it will return you the 2nd oldest bar.
Put it into OnInit() function:
Thanks for the response Kristian, Ive just tried it and it worked. Thank you.
Steve
-
Please edit your (original) post and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) -
Perhaps you should read the manual, especially the examples.
How To Ask Questions The Smart Way. (2004)
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
How to call indicators in MQL5 - MQL5 Articles (2010) -
In MT5, you must set the direction.
To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5
I've a problem with a custom indicator in MT5 EA.
It's working fine up to the date that starts testing (october 11th 2024).
Attached a screenshot that gives good dots on october 10th. But then???
Anyone that can give me a clue?
I've a problem with a custom indicator in MT5 EA.
It's working fine up to the date that starts testing (october 11th 2024).
Attached a screenshot that gives good dots on october 10th. But then???
Anyone that can give me a clue?
do you really expect an answer?
no code, no error message, a custom indicator that nobody knows what it should be doing, etc.....
I thought somebody recocnizes what's happening. But now attached the source codes.
In the mean time I've seen that not every copybuffer gives results. Sometimes up to 10 times the result is 0.
I hope you can catch me on my errors!!
Thanks.
I have seen no such bug, and I have used both builds, currently using 4620. You must be using the function incorrectly.
Can you please describe the details, preferably with sample code and log output so that the issue can be reproduced by others?
- 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 Guys
Im having my first crack at an EA but am getting some strange results. If someone could have a look and point me in the right direction Id appreciate it.
I am calling the function "GetThreeMAValues" with the following line "GetThreeMAValues(_Symbol, PERIOD_CURRENT);". The three arrays are declared in the Global Scope.
Anyway the issue is when the following print statements are run
My understanding is that it should be printing out the three MA's on the bar prior to the current one (Index 1). However, the MA's being displayed are 8 bars earlier and I cant work out why.