Problems found during the back testing and can't find the root cause! - page 4

 
GumRai:

 will allow different calculations on the first run on closed bars to what it does on the current bar.

What it will do on the first tick of a new bar is 

 On subsequent ticks of the same bar it will calculate

 Which is a sort of compounding

 

 

Dear GumRai,

 

Current bar, Bar[0] is necessary for re-painting. So the topic is about the issue that historical bars were observed with re-painting, maybe Bar[8],..Bar[3],.., or Bar[1].

You can see it's only about 10 lines of codes for the main content of the indicator. 

However, it's still so difficult for us to find the root cause for re-painting of historical bars.  

It's so strange and I'm confused how the historical bars can be re-painted with that code.

 

As I said, the indicator is recalculating bar[0] every tick using a value that was calculated in the previous tick of the same bar

While the tester is running, the indicator will be calculating in pseudo real time even if the indicator is not actually on the chart

When the tester is finished, the indicator is added to the chart and I believe doesn't take into account all the ticks as it is only calculated once per bar.

Try it by putting the indicator on the chart in visual mode. 

 
jollydragon:

 

Dear ffoorr, I can't open the pages and can't access the site, www.forex-tsd.com. Maybe my internet configuration has some problem.

Please let's focus on my code. It's only about 10 lines of codes for the main content. 

However, it's still so difficult for us to find the root cause for re-painting of historical bars. 


 decrease the zoom to access the page number on TSD,


 the indicator is better

 
GumRai:

As I said, the indicator is recalculating bar[0] every tick using a value that was calculated in the previous tick of the same bar

Try it by putting the indicator on the chart in visual mode.  

 

 

GumRai, please refer to my previous posts:

. It's no problem for bar[0] to be re-painted as it's necessary.

. For this thread, the topic or issue is exactly why the historical bars to the left of bar[0] were re-painted and it's not expected. I observed it in charts already and pasted screenshots already.

 

Dear all, please let's focus on my codes and improve ourselves together by digging out the root cause. I don't need any better indicator, but want to know the root cause! 

Thanks for understanding and support. 

 

You don't seem to be understanding what I am telling you.

I don't know if it is because I am not explaining myself well or if you are just not reading my posts properly.

When you re-initialize the indicator, the whole indicator is re-calculated based on one tick per bar whereas in real time it is based on multiple ticks in one bar.

So if the indicator is drawn in real time and then re-initialized, there will be differences. 

 
GumRai:

You don't seem to be understanding what I am telling you.

I don't know if it is because I am not explaining myself well or if you are just not reading my posts properly.

When you re-initialize the indicator, the whole indicator is re-calculated based on one tick per bar whereas in real time it is based on multiple ticks in one bar.

So if the indicator is drawn in real time and then re-initialized, there will be differences. 

 

Sorry to tell English isn't my native language.

No matter if it's  drawn at re-initialization or in real time, every historical bar is calculated based on the last tick.

Therefore, the historical bar should be frozen as same. Correct? How can the difference or re-painting be observed if you watch the indicator in a live chart with M1 for a period? 

 
It seems this isn't a simple issue and out of the capability of many coding experts. 
 

Well, it seems to be a simple issue to me, it's just that you don't understand the answer.

Try the attached code, in which I hope you are able to see what happens

I've just changed the indicator drawing loop to

   for(i=limit-1; i>=0; i--)
     {
      ExtBuffer1[i]=1.1*Fish1;
      Fish1=ExtBuffer1[i];
      if(Fish1>=EMPTY_VALUE)
         Fish1=1;
     }

 and the initial value for Fish1

Fish1=0.00001;

Run it on a M1 chart with regular ticks . You will see various peaks forming.

Re-initialise the indicator and you will see all those peaks disappear.

Also, if you have a not-so-good internet connection and it misses a bar, the whole indicator is re-calculated, so the peaks will disappear

Do you see why? 

Files:
 
GumRai:

Well, it seems to be a simple issue to me, it's just that you don't understand the answer.

Try the attached code, in which I hope you are able to see what happens

I've just changed the indicator drawing loop to

 and the initial value for Fish1

Run it on a M1 chart with regular ticks . You will see various peaks forming.

Re-initialise the indicator and you will see all those peaks disappear.

Also, if you have a not-so-good internet connection and it misses a bar, the whole indicator is re-calculated, so the peaks will disappear

Do you see why? 

 

Dear GumRai,

 

It seems you catch my point.

Please refer to the screenshots below. After I right clicked on your indicator and select "refresh", the location of peaks changed. 

 

However, I still can't see why. That is why I can't find the root cause in my re-painting indicator.

. According to the indicator you modified, I understand it should draw a exponential line. Why does it draw peaks with intervals? Is it because there is "empty value"?

. Why do the location of peaks change after refreshing? 

. I still can't see the disappearing of the peaks. How to "re-initialise" it?

 

Before refreshing: 

 

After refreshing: 

 

 
jollydragon: However, I still can't see why. That is why I can't find the root cause in my re-painting indicator.

   for(i=limit-1; i>=0; i--)
     {
      ExtBuffer1[i]=1.1*Fish1;
      Fish1=ExtBuffer1[i];
      if(Fish1>=EMPTY_VALUE)
         Fish1=1;
     }

For every iteration, (except the first,) Fish1 is the value of the previous buffer element, but you don't initialize it to ExtBuffer1[limit].

So for the initial iteration (when limit == bars) you set ExtBuffer1[0] = 1.1*ExtBuffer1[1].

But for subsequent ticks (when limit == 1) you set ExtBuffer1[0] = 1.1*0.00001.

Reason: