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
Yeah that's what I thought.
This is what return 0 does in OnCalculate, it tells the program to successfully complete its operation and it calls OnDeInit gracefully. This isn't explained in the docs, however "return 0" was always known to indicate completion of a program in C programming. You would expect it to keep calculating, but this will end the program. They could flesh out the docs a bit more for OnCalculate explanation.
All these statements are incorrect.
Is the code in post #9 the last version ? I would check it.
All these statements are incorrect.
Explain why please. Returning 0 will prevent OnCalculate to continue. It's not the same as MT4
No. Returning 0 will just lead to the next OnCalculate call using prev_calculated=0.
Please provide code to show your issue if you need more explanation.
No. Returning 0 will just lead to the next OnCalculate call using prev_calculated=0.
Please provide code to show your issue if you need more explanation.
as discussed in this topic, return 0 leads to OnDeInit returning code 1 to say that the indicator is now removed. So if this is not meant to be, perhaps it's a bug, or what? Keep in mind the documentation is vague to explain OnCalculate, so we can't know for sure
This is complete non sense. Vladislav already asked you to post code to prove your claim, I asked you to do it too and still you don't want to cooperate.
OnCalculate() behaviour is perfectly known. The documentation is perfectly clear.
If there is an issue it's something specific on your side. If you don't want to post code so we can investigate about what you saw, I will remove all this sequence of posts which is pointless without code.
This is complete non sense. Vladislav already asked you to post code to prove your claim, I asked you to do it too and still you don't want to cooperate.
OnCalculate() behaviour is perfectly known. The documentation is perfectly clear.
If there is an issue it's something specific on your side. If you don't want to post code so we can investigate about what you saw, I will remove all this sequence of posts which is pointless without code.
What do you mean? Why is it difficult to take any code and replace return rates_total?
How come he could do it, but you couldn't do it? What is the need to provide code?
What is the need to provide code?
I thought the return value didn't affect anything at all except prev_calculated.
But, it turned out that the terminal does not update the indicator when the indicator returns 0. In this context, you are right - it is better not to return 0.
But returning 0 does not lead to a crash or deinitialization - in this context, you are wrong (at least I cannot reproduce it).
[edit]
the terminal does not update the indicator when the indicator returns 0
I meant that the terminal will not update the indicator buffers. I only considered indicator buffers.
But returning 0 does not lead to a crash or deinitialization - in this context, you are wrong (at least I cannot reproduce it).
well, that is just what I got
(post #21)
via the code I posted in post #9
Let's keep it productive guys. In my mind, someone shouldn't yell "nonsense" without reason. We're all wishing to know certainties here.
If any of you want to understand more:
https://www.geeksforgeeks.org/return-0-vs-return-1-in-c/
well, that is just what I got
(post #21)
I don't know any other way to get the REASON_REMOVE code other than manually removing the indicator from the chart. I don't see any relationship between returning 0 and REASON_REMOVE. Most likely, you simply removed the indicator from the chart (this was the reason for REASON_REMOVE).
I have run your indicator many times in the strategy tester, returning 0 and returning rates_total. I was unable to get an indicator crash or unexpected deinitialization. The order history was empty, so the indicator displayed uninitialized values. Sometimes it didn't display anything (objects were visible in the object list, but not in the chart). But there was no crash or deinitialization - the indicator continued to work.
I didn't study how your indicator works, I didn't try to understand if there are any errors there, I just wanted to get deinitialization in the middle of testing or crash. And I didn't get it.
Of course, there is a possibility that you have encountered some kind of terminal bug or something similar.
But so far only you have seen it.