What do you define as a round number ? when price crosses (or touches ? ) this "round number" what do you want the Indicator to display ?
Wow, you're friendly :-)
Thank you for putting up with my crap questions. I'm doing my best and I think I got a step further. It will hopefully answer your question too.
What is a round number? Well it's supposed to be (say in the case of AUDNZD 1.29000 or 1.30000 or 1.31000). But it turns out that since the prices are calculated to 5 acct digits, my formula didn't work as I wanted it too. See the picture.
Also, you've asked what I want the indicator to display? I simply need to to say 'yes' or 'no' for each bar, so I though I was very clever using the new bar thingy in the book, but I'm still thinking about how I can store this stuff. This is because at any one time I may need to refer to the 'round' boolean array for say 5 or 10 bars ago. Does this make sense?
Wow, you're friendly :-)
Thank you for putting up with my crap questions. I'm doing my best and I think I got a step further. It will hopefully answer your question too.
What is a round number? Well it's supposed to be (say in the case of AUDNZD 1.29000 or 1.30000 or 1.31000). But it turns out that since the prices are calculated to 5 acct digits, my formula didn't work as I wanted it too. See the picture.
Also, you've asked what I want the indicator to display? I simply need to to say 'yes' or 'no' for each bar, so I though I was very clever using the new bar thingy in the book, but I'm still thinking about how I can store this stuff. This is because at any one time I may need to refer to the 'round' boolean array for say 5 or 10 bars ago. Does this make sense?
It's probably something like this ...
#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red double round[]; int scale=1; #define ROUNDNESS 1000 //-------------------------------------------------------------------- int init(){ SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,round); SetIndexLabel (1,"Round"); IndicatorShortName("Round"); IndicatorDigits(1); int factor[]={1,10,100,1000,10000,100000,1000000}; scale = factor[Digits]; return(0); } //-------------------------------------------------------------------- int deinit(){ return(0); } //-------------------------------------------------------------------- bool CrossedRound(int bar){ int high = scale * High[bar]; // scale takes the floating point value and makes it an INT without loss of precision int low = scale * Low[bar]; high /= ROUNDNESS; low /= ROUNDNESS; if( high==low ) return( false ); return( true ); } //-------------------------------------------------------------------- int start(){ int counted_bars=IndicatorCounted(); for( int n=Bars-counted_bars; n>=0; n-- ){ if( CrossedRound(n) ) round[n] = 1.0; else round[n] = 0.0; } return(0); }
It's probably something like this ...
You just wrote it! (Yes!!) Thanks heaps. But since I'm new I don't understand all of it immediately. So I'm going to read it again and again and I'll come back if i have questions. If you don't hear from me it will be cos I've worked it out. M
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
Another newbee question if I may.
I want to write a custom indicator that will track for each bar in the chart whether price crosses a round number.
I can do the round number bit because I just go to the textbook and use the MathMod formula, but I don't know how to store this for each bar in an array... if that's even what I need to do.
Can someone suggest an approach pls?
Thank you.