You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You never update bar one (last received tick) when a new bar starts.
How to do your lookbacks correctly #9 — #14 & #19
No. The parameters passed by the OnCalculate are high[] and low[], not High[] nor Low[]. Why you ask?
Because the Indicator may be placed on an "Offline Chart" in the case of MT4 ("Custom Symbol" in the case of MT5) and in those cases iHigh, iLow, High[] and Low[] will ALL return the wrong data. Also, even if the indicator is on a normal chart, there is no guarantee that the data presented by the OnCalculate parameters are synchronised with the chart data. They may in fact be out of sync at certain times.
The correct way is to always to use the data passed by the event handler function.
Now for the code. Your logic seems suspect, so I changed it a little to what I believe you want, but you will have to review it to see if that is the case.
Thank's, now it work how it's supposed to, just needed to change the additions and differences operations inside if statement.
I've further question about coding, if you are ok with answering, of course.
Thank's for your guidance, I didn't knew I can create buffers and using their index instead of having to #define them every time.
Try to study more examples in the CodeBase you so can see the different ways people code their indicators.
And read William's post #11 and follow up on the links provided.
Try to study more examples in the CodeBase you so can see the different ways people code their indicators.
And read William's post #11 and follow up on the links provided.
ok, now I get it. Another question if you will.
Why sometimes you call variables "dbVariabileName" and other times "g_adbVariableName"? I get that "db" stands for double, why "g_a..."? Thank's, I was curious because i see this notation on several codes.
Edit:
Also, there is any difference between doing this:
And doing this:
Personally I find more convenient "my" method, but I saw in your code that you removed and did everything trought #property.. what the difference? Thank's.
So, that the user has the option of changing the colours, line width and style. If you do it in the code, it will be "hardwired" and the user will not be able to change it in the properties.
Forum on trading, automated trading systems and testing trading strategies
iCustom giving unexpected values
Fernando Carreiro, 2022.05.16 17:28
By the way, if you wondering why I use those "weird" prefixes in my variable names, it is to help identify them more easily.
I use "i_" for inputs and "g_" for global variables. I use "a" for arrays, "h" for handles, "n" for integer based numbers, "db" for double floating point, and several others not present in this code.
So "g_adbAtrBuffer" is a global variable of an array of double precision floating point for the ATR buffer, ...
and "i_nAtrPeriod" is a input variable of an integer numeric for the ATR period.
This is not necessary. It is just the coding style I am adopting. You should use what ever style you feel comfortable using that helps you read your code more easily.So, that the user has the option of changing the colours, line width and style. If you do it in the code, it will be "hardwired" and the user will not be able to change it in the properties.
Thank's very much Fernando, thank's to your help I was able to learn several new things.
Wish you a good day.
You are welcome!
You are welcome!
The best method is to build higher time-frame data from the current data provided by OnCalculate(). This will guarantee that it will work correctly with Offline Charts on MT4 (Custom Symbols on MT5).
However, if you choose to ignore the use of Offline Charts, then you can use iHigh() but you will also have to use iBarShift() to synchronise the indexing into the data.
The best method is to build higher time-frame data from the current data provided by OnCalculate(). This will guarantee that it will work correctly with Offline Charts on MT4 (Custom Symbols on MT5).
However, if you choose to ignore the use of Offline Charts, then you can use iHigh() but you will also have to use iBarShift() to synchronise the indexing into the data.