iCustom giving unexpected values - page 7

 
Tristen Shaw #: Here is a ss on the H1 timeframe with the datawindow. Shows -1

So now it is showing some activity.


 

Add the ATR to the chart with a level for the same ATR threshold value you are using for the Indicator's input, so you can compare.

Also, adjust the threshold on both for more activity.

 
Fernando Carreiro #:

Add the ATR to the chart with a level for the same ATR threshold value you are using for the Indicator's input, so you can compare.

Also, adjust the threshold on both for more activity.

Ok, I more or less get everything except this part.

for( int iIndex = nPrevCalc; iIndex < rates_total; iIndex ++ ) {
            double atrValue = atrBuffer[ iIndex ];
            atrThresholdBuffer[ iIndex ]
               =   atrValue > inpAtrTheshold ? +1
               : ( atrValue < inpAtrTheshold ? -1
               : ( iIndex   > 0              ? atrBuffer[ iIndex - 1 ]
               : 0 ) );
            /* The above short-hand logic can be difficult to understand
               so here is the long version ...
               
               if( atrValue > inpAtrTheshold )
                  atrThresholdBuffer[ iIndex ] = +1;
               else {
                  if( atrValue < inpAtrTheshold )
                     atrThresholdBuffer[ iIndex ] = -1;
                  else {
                     if( iIndex > 0 )
                        atrThresholdBuffer[ iIndex ] = atrThresholdBuffer[ iIndex - 1 ];
                     else
                        atrThresholdBuffer[ iIndex ] = 0;
                  };
               }; */
         };

I'm not quite sure what the atrThresholdBuffer is and what it's values represent. My first assumption was that 1 was standing for a bar that was above the threshold while -1 was a bar below the threshold. But then I was confused because it checks for a value above 0 and changes the current value to the value of the prev index.

 
Tristen Shaw #: Ok, I more or less get everything except this part. I'm not quite sure what the atrThresholdBuffer is and what it's values represent. My first assumption was that 1 was standing for a bar that was above the threshold while -1 was a bar below the threshold. But then I was confused because it checks for a value above 0 and changes the current value to the value of the prev index.

That buffer is what is being plotted as shown in the screenshots. It simply plots +1 when the ATR is above the threshold level and -1 when it is below.

However, there will be uncertainty when the ATR value is the same as the threshold. If the difference is 0, then is it above or is below? It is neither, so it is best to just continue with the previous signal until we are certain that it actually crosses the threshold and not just touching it. Hence it uses the value of "atrBuffer[ iIndex - 1 ]" instead.

However, if this is the first bar of data, then there will be no previous plot, and in this only case, we set it to 0 instead of +1 or -1. This is the reason it checks the "iIndex > 0", to see if it is the first bar or not.

 
Fernando Carreiro #:

That buffer is what is being plotted as shown in the screenshots. It simply plots +1 when the ATR is above the threshold level and -1 when it is below.

However, there will be uncertainty when the ATR value is the same as the threshold. If the difference is 0, then is it above or is below? It is neither, so it is best to just continue with the previous signal until we are certain that it actually crosses the threshold and not just touching it. Hence it uses the value of "atrBuffer[ iIndex - 1 ]" instead.

However, if this is the first bar of data, then there will be no previous plot, and in this only case, we set it to 0 instead of +1 or -1. This is the reason it checks the "iIndex > 0", to see if it is the first bar or not.

Ok, that makes sense. I think I'm getting it all.

 

Alright, I've got it. Did I have homework on this step besides asking questions?

 
Tristen Shaw #: Alright, I've got it. Did I have homework on this step besides asking questions?

Just questions! Do you think you can now solve your original query of this thread, or are you still stuck on something?

 
Fernando Carreiro #:

Just questions! Do you think you can now solve your original query of this thread, or are you still stuck on something?

Being completely honest. I have learned a lot from your lessons, but I haven't yet figured out what was causing the original problem.

Please slap me and correct me if I'm wrong, but it seems like we have put together a program that does what I was doing, just doing it in a more efficient way.

I'm still not sure why I was getting values returned that I was not expecting.

If there was a part of this that should have stood out to me as being the solution, feel free to give me a hint and see if I can figure it out. I'm all for working for my payout. I would far rather learn how to do it right than just be told what I am doing wrong.

 
Tristen Shaw #: Being completely honest. I have learned a lot from your lessons, but I haven't yet figured out what was causing the original problem. Please slap me and correct me if I'm wrong, but it seems like we have put together a program that does what I was doing, just doing it in a more efficient way. I'm still not sure why I was getting values returned that I was not expecting. If there was a part of this that should have stood out to me as being the solution, feel free to give me a hint and see if I can figure it out. I'm all for working for my payout. I would far rather learn how to do it right than just be told what I am doing wrong.

When I looked at original post, I considered the code somewhat too convoluted for my taste, so I decided to only start picking out those aspects I knew to be problematic, and somehow, along the way, it turned into a tutoring session. So in honesty I did not really address the original cause of the problem, because I ended up just rebuilding it from scratch.

Can you however take my current code which you have been analysing (and hopefully understand fully) and build on it to achieve your original goal?

 
Fernando Carreiro #:

When I looked at original post, I considered the code somewhat too convoluted for my taste, so I decided to only start picking out those aspects I knew to be problematic, and somehow, along the way, it turned into a tutoring session. So in honesty I did not really address the original cause of the problem, because I ended up just rebuilding it from scratch.

Can you however take my current code which you have been analyzing (and hopefully understand fully) and build on it to achieve your original goal?

I will give it a try.

I will use the framework we built in this post and try to redo what I was initially attempting. Then I'll post back with what happens.