Is there a way to optimize the following onCalculate method? - page 2

 
angevoyageur:

I will explain my point with more details when I have some time...be patient.

I think there is some misunderstanding of concept. I assume that both symbols, of course, don't need to be synchronized! The synchronization you talk about will never occur in the current bar, I agree with you. But what is wrong with this? It is assumed that the last value of this indicator is a mere representation of the ratio.

However, Gold and Silver are synchronized once the bars of each frame are closed and known, once the bars are known. This is the reason why the graphics are plotted ok. I think this indicator is not bugged, angevoyager, you should argue your point of view I think. Thks anyway for your opinion, always welcome.

 
laplacianlab:

I think there is some misunderstanding of concept. I assume that both symbols, of course, don't need to be synchronized! The synchronization you talk about will never occur in the current bar, I agree with you. But what is wrong with this? It is assumed that the last value of this indicator is a mere representation of the ratio.

However, Gold and Silver are synchronized once the bars of each frame are closed and known, once the bars are known. This is the reason why the graphics are plotted ok. I think this indicator is not bugged, angevoyager, you should argue your point of view I think. Thks anyway for your opinion, always welcome.

Here is a screenshot to illustrate my point :

In your indicator you take data for both symbol and then simply calculate to quotient of both values with the same index :

         ratioBuffer[i]=MAGoldBuffer[i]/MASilverBuffer[i];

As you can see on the chart, there is no guarantees that the same index means the same candle (same opening time). So you are dividing for example MA of 07:00 candle for Silver with MA of 08:00 for Gold. One can argue that makes not much a difference, but in my opinion it's a bug sorry. 

 
angevoyageur:

Here is a screenshot to illustrate my point :

In your indicator you take data for both symbol and then simply calculate to quotient of both values with the same index :

As you can see on the chart, there is no guarantees that the same index means the same candle (same opening time). So you are dividing for example MA of 07:00 candle for Silver with MA of 08:00 for Gold. One can argue that makes not much a difference, but in my opinion it's a bug sorry. 

Thanks for your time and for your help.

Indeed, it was a matter of concept. We should note that this indicator works with moving averages, therefore, the exact time is not important here. That's not the idea of ​​this indicator. As I say, this indicator works with the data it receives from the server, it works with SMA data, not with rates.

For all this, the graphics plotted are correct. There is no bug. Please, compare the graphics plotted by this indicator with those that you can get at any website covering the Gold Silver ratio:

Gold Silver ratio 

http://www.goldmadesimplenews.com/silver/silver-price-remains-above-its-16-month-long-term-support-10030/ 

Best regards! 

Reason: