SDC: Well ok but now you are recalculating the entire indicator history on every new bar too is that what you wanted ?
No you are not. Bars -1 -counted will be 1 ONLY on a new bar Bars -1 -counted will normally be zero. Only initially or new history will Bars -1 -Counted be Bars-1
WHRoeder:
There is no need to check for new bars in indicators. It is handled by the indicatorCounted and the for loop.
Then don't count down to zero (count down to one)
Thanks. I wasn't sure if there is much of an unnecessary hit on performance to constantly update bar 0 with each tick when the indy is used just for end of bar signals. Counting just to 1 makes perfect sense and is of course more elegant than my NewBar() idea.
This is how the count is now coded.
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recountedif(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
double Value;
for(int i=1; i<limit; i++)
PowerBuffer[i] = Value(i);
return(0);
}
WHRoeder:
No you are not. Bars -1 -counted will be 1 ONLY on a new bar Bars -1 -counted will normally be zero. Only initially or new history will Bars -1 -Counted be Bars-1
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I don't want or need for bar 0 to update every tick, that's why I insert NewBar().
Well ok but now you are recalculating the entire indicator history on every new bar too is that what you wanted ?
There is no need to check for new bars in indicators. It is handled by the indicatorCounted and the for loop. Then don't count down to zero (count down to one)
Thanks. I wasn't sure if there is much of an unnecessary hit on performance to constantly update bar 0 with each tick when the indy is used just for end of bar signals. Counting just to 1 makes perfect sense and is of course more elegant than my NewBar() idea.
This is how the count is now coded.
No you are not. Bars -1 -counted will be 1 ONLY on a new bar Bars -1 -counted will normally be zero. Only initially or new history will Bars -1 -Counted be Bars-1
Yes, you are right, I misread the OP's code