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
Ok! Now lets tackle the OnInit. I will ignore the general structure and parameter inputs for now, but will come back to it later. I am currently focused on routing out problem areas. I am not trying to find your "bug" yet. My aim is to systematically improve the logic and remove future problems. The cleaner the code, the easier it will be to spot the actual bug. So ...
Currently in your OnInit code, you are doing the following in this sequence:
Don't you think that something is wrong with that sequence?
Given that some of the operations will invalidate and force the indicator to terminate, don't you think you should follow a different sequence?
Ok! Now lets tackle the OnInit. I will ignore the general structure and parameter inputs for now, but will come back to it later. I am currently focused on routing out problem areas. I am not trying to find your "bug" yet. My aim is to systematically improve the logic and remove future problems. The cleaner the code, the easier it will be to spot the actual bug. So ...
Currently in your OnInit code, you are doing the following in this sequence:
Don't you think that something is wrong with that sequence?
Given that some of the operations will invalidate and force the indicator to terminate, don't you think you should follow a different sequence?
Ok, I see. Now, is this mainly a matter of efficiency? Like "Why have the computer do all this other work if it's possible that the tests might terminate the program anyway. Or is there a further reason aside from that?
New OnInit:
Yes, and no! Yes, it is mainly the reason, but there is a second part which I am going to address now.
What do you think happens to the Indicator handles that you obtain?
Surely they need to be released when you no longer need them. One would assume that the terminal takes care of them when you terminate the indicator, but what if it does not?
Then we better make sure that our code does a proper clean-up. And we have to do it in two places. So, the sequence we follow in OnInit can be quite important.
One part, which you have not implemented, is during the OnDeinit() event handler and the other, is when you test the handles, when maybe one of them is invalid and you exit the OnInit() with a failed attempt.
To release the handles, you have to use IndicatorRelease. Have a look at the example code there. Also have a look at the example code for iATR, for the OnDeinit section and then also use the logic in your "testing handles" section.
This time I will wait for your attempt before I give you mine.
Yes, and no! Yes, it is mainly the reason, but there is a second part which I am going to address now.
What do you think happens to the Indicator handles that you obtain?
Surely they need to be released when you no longer need them. One would assume that the terminal takes care of them when you terminate the indicator, but what if it does not?
Then we better make sure that our code does a proper clean-up. And we have to do it in two places. So, the sequence we follow in OnInit can be quite important.
One part, which you have not implemented, is during the OnDeinit() event handler and the other, is when you test the handles, when maybe one of them is invalid and you exit the OnInit() with a failed attempt.
To release the handles, you have to use IndicatorRelease. Have a look at the example code there. Also have a look at the example code for iATR, for the OnDeinit section and then also use the logic in your "testing handles" section.
This time I will wait for your attempt before I give you mine.
Alright, here is what I came up with.
And here is my rendition ...
What do you see that is different?
Do you understand the differences?
Do you agree with the differences?
Remember that I can make mistakes too!
And here is my rendition ...
What do you see that is different?
Do you understand the differences?
Do you agree with the differences?
Remember that I can make mistakes too!
Well, the first thing I notice that you didn't use the IndicatorRelease function at all in your code. I have to assume that there is a reason for this, but I can't say whether I agree or disagree with it since I don't know if there is some kind of advantage to doing it this way or not.
Otherwise, the function seems good. Easily expandable if new indicators where to be introduced later. Prevents the code from getting cluttered with lines and lines of the same error handling and such, replacing it with a simple function call.
I guess I would have to say that I agree with the differences. It's cleaner and more organized.
Tristen Shaw #: Well, the first thing I notice that you didn't use the IndicatorRelease function at all in your code.
Look again ... OnDeinit() calls ReleaseAllHandles(), which calls ReleaseHandle() which calls IndicatorRelease().
Ok, here is continuing our saga ...
Next, some test code to simply copy and display the data obtained from iATR. Put up this indicator and the standard ATR indicator so as to compare the two.
Then look at the code and analyse, question and comment on it.
Don't worry. We will slowly build it up again to the full code you are developing.