Price Ratio Index Indi help

 

Hi There,

So attached is a very simple price ratio indicator that plots bollinger bands around it.

Plot the ratio of two currency pairs and then plot 2 standard deviations via bollinger bands around the price ratio index.

Pretty simple concept and a pretty simple indicator to code.

However I'm having quite a bit of trouble coding it. For some reason it doesn't refresh correctly and I've tried coding this indicator in several different ways all resulting in the same problem. It would also repaint where as other indicators built in this manner do not at all.

Can anyone take a look and help find a solution to these problems? I've attached the simplest version of the indicator below.

Thanks

Files:
 
drgoodvibe:
Hi There,

So attached is a very simple price ratio indicator that plots bollinger bands around it.

Plot the ratio of two currency pairs and then plot 2 standard deviations via bollinger bands around the price ratio index.

Pretty simple concept and a pretty simple indicator to code.

However I'm having quite a bit of trouble coding it. For some reason it doesn't refresh correctly and I've tried coding this indicator in several different ways all resulting in the same problem. It would also repaint where as other indicators built in this manner do not at all.

Can anyone take a look and help find a solution to these problems? I've attached the simplest version of the indicator below.

Thanks

Hi Drgoodvibe,

Might try this version seems to be refreshing correctly.

Files:
 

Thansk mrTools!

but unfortunately there's some weird things that happen with this indicator when using different pairs.

LIke for example if you use AUDUSD and NZDUSD as the curreny pairs and put the indicator on an AUDUSD chart, everything seems to go blank or not draw with the indicator. it's very strange, would you mind please looking at it?

Thank you

 

...

drgoodvibe.

Answering instead of mrtools (hope you won't mind)

Try this version (as far as I see it works OK)

drgoodvibe:
Thansk mrTools!

but unfortunately there's some weird things that happen with this indicator when using different pairs.

LIke for example if you use AUDUSD and NZDUSD as the curreny pairs and put the indicator on an AUDUSD chart, everything seems to go blank or not draw with the indicator. it's very strange, would you mind please looking at it?

Thank you
Files:
 

Thank you mladen, that did the trick. Much appreciated.

If you have a moment (to help me be a better programmer) can you explain why using MathMax made the indicator work properly?

thanks

 

...

drgoodvibe,

The second part of MathMax() is what counts in this case. It could have been written differently, but since those averages can not be negative, MathMax() could be used as a shortest way to fix the problem. It avoids zero division (zero division was causing the problems you had)

drgoodvibe:
Thank you mladen, that did the trick. Much appreciated.

If you have a moment (to help me be a better programmer) can you explain why using MathMax made the indicator work properly?

thanks
 

Thanks very much for your answer. I had thought that zero division was my problem but didn't know the way to fix it.

Thanks again..

 

Adding capability to plot difference of two moving averages as Histogram

This is a great indicator. Could someone please add capability to plot difference of two moving averages of the ratio as Histogram (with color selection) and best to draw arrows on the price chart if and when histo crosses the zero line. BB can be eliminated if it will interfere with the histogram drawings. TIA

 

Price 1 : price 2 with 3 smas and bollinger bands is the formula.

Why is it repainting? Just on backtester? On backtester it shows different values if you add a second price ratio on the chart after letting visual mode run a while with first just one price ratio indicator.

 
Hi there, can someone adjust this indicator? in fact in the backtests it does not draw equal to the real graph, And can you also do the conversion to .mq5 of this indicator?
Thanks in advance
Ambrogio
Files:
Reason: