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

3676

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.

40798

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.

3676

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.