int limit = rates_total - (prev_calculated > 0 ? prev_calculated : 1); for(int i = limit; i >= 0 && !_StopFlag; i--) { PRatio[i] = Price_Ratio(i, symb_1, symb_2); } if(IsFirstScan_MA) { for(int i = limit - Period_MA; i >= 0 && !_StopFlag; i--)
It's not repainting, it's not computing. After the first run you compute limit=rt-rt=0 and i=limit-Period_MA
means you don't do anything.
How
to do your lookbacks correctly.
Because the calculations are being performed on the current bar. Add a '+1' to the 'i' in all the calculations and it won't repaint.
Thanks
Frederick Langemark
But I need the indicator to show me the value of current bar too, which is the only bar in which the value one the chart can be variable.
Thanks
It's not repainting, it's not computing. After the first run you compute limit=rt-rt=0 and i=limit-Period_MA
means you don't do anything.
How
to do your lookbacks correctly.
Thanks William Roeder
You are right
I printed the " i " int the first loop and saw what you are talking about.
Thanks
All indicators repaint. The only indicator that doesn’t repaint is the naked chart. Price action trading is the way to go.
Most indicators continuously update the forming bar; that is not repainting. Older bars don't change and neither should the indicator.
Bingo.
Anybody can please help me understand why my indicator repaints.
It firstly fill an Array (PRatio) and then has to fill another Array (MA) with the MA of PRatio[]. Then filles the 3rd Array (DV) with Standard Deviation of PRatio[].
And After all fills the Main Buffer (ZScore) with : (PRatio- MA) / DV.
I didn't find out why it repaints.
Any help would be appreciated.
MA[i] = iMAOnArray(PRatio, 0, Period_MA, 0,Method_MA, i);
double Price_Ratio(int bar, string _sym_1, string _sym_2) { double symb_1_NC, symb_2_NC; //NC = Net Change //double symb_1_Curr = MarketInfo(_sym_1,MODE_BID); //double symb_2_Curr = MarketInfo(_sym_2,MODE_BID); double symb_1_Curr = iClose(_sym_1, TF, bar); <--- variable when bar = 0 double symb_2_Curr = iClose(_sym_2, TF, bar); double symb_1_Prev = iClose(_sym_1, TF, bar + 1); <--- non variable when bar = 0 double symb_2_Prev = iClose(_sym_2, TF, bar + 1); //--- symb_1_NC = symb_1_Curr - symb_1_Prev; symb_2_NC = symb_2_Curr - symb_2_Prev; //--- return symb_1_NC - symb_2_NC; }
You're using the close price. In MT, the close price is the last price until bar (1) has closed and new bar (0) opened.
You're using the close price. In MT, the close price is the last price until bar (1) has closed and new bar (0) opened.
Hi Icham Aidibe
Thanks , I appreciate your help.
But actually I know that and did it by purpose. That's not the problem. I want the indicator to be
variable in the current bar, but not on the previous bars.
I think the problem is solved by the new loop I made as described on William Roeder's link.
Regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Anybody can please help me understand why my indicator repaints.
It firstly fill an Array (PRatio) and then has to fill another Array (MA) with the MA of PRatio[]. Then filles the 3rd Array (DV) with Standard Deviation of PRatio[].
And After all fills the Main Buffer (ZScore) with : (PRatio- MA) / DV.
I didn't find out why it repaints.
Any help would be appreciated.