Verify that you are reading the buffers (index) correctly
Hey, thanks for the hint. I do not really understand what you mean by that. I definitely named the right buffers and i do get the right result. But only if I put the function call before the if statement... That is the only thing I do not get
Okay I think I got it now.. For anybody who is interested or facing the same problem. This post kinda helped me to understand the iCustom: https://stackoverflow.com/questions/26491213/mql4-icustom-returns-always-the-same-wrong-value-0x7fffffff
Looks like the problem in my case was that I did not call the iCustom often enough. So when I really needed the current value it was not available in the buffer and I received an old one while the indicator started to update. In my case the difference between the first code (checkTrend() above the if statement) and the second one was that the code did not reach the function call in the if statement every time. Makes sense to me and I hope someone find this useful.
- stackoverflow.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey programmers,
I have a super weird problem and do not find a solution. Maybe you can help. I am working with a custom indicator and calculate it´s value in the following function:
In my OnTick() I use the function above in an if statement to check weather the trend is long or short. The whole code block is only executed once per bar whenever a new bar appears.
When I run a test I can visually see (in the chart) that the signal is "buy" on 2018.01.02 06:52:00. Unfortunately the function returns "sell" as you can see here:
If i add another function call above the if statement, the code looks like this:
Then i run the exact same backtest and the result is as follows. Now both function calls return the right string value which is the buy signal...
This gives me a big headache and I hope that someone can help me here.
Greetings,
René