static datetime tLastCalcBar=-1; int sz,b,iBarToCalc,counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars-1; if ( tLastCalcBar != Time[0] ) { iBarToCalc = iBarShift(NULL, 0, tLastCalcBar); tLastCalcBar = Time[0];
- Drop your tLastCalcBar junk - unnecessary - as I previous posted.
- Drop your decrement - unnecessary - as I previous posted. Why did you start a new thead.
- Just do it like a normal indicator and add the buffer resize code - as I previous posted.
double indi[][20]; ... int start() { // static datetime tLastCalcBar=-1; int sz,b,iBarToCalc,counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted // if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars-1; // if ( tLastCalcBar != Time[0] ) { // iBarToCalc = iBarShift(NULL, 0, tLastCalcBar); // tLastCalcBar = Time[0]; // // if ( counted_bars == 0 ) {// initialize indi[][] // sz = shiftBuffer(iBarToCalc, indi, Bars); // => indi[Bars][20] sz = shiftBuffer(0, indi, Bars); // => indi[Bars][20] // b = Bars - 1; // iniIndi(indi, b); // => int iniIndi(double& i[][], int bar); set the initial values // iBarToCalc = b-2; // continue with the next empty bar // counted_bars = 1; // not to be caught in an endlessloop // } else { // normal shift of the array // sz = shiftBuffer(iBarToCalc, indi); // } // // for( b=iBarToCalc+1;b>0;b--){ // calc. one bar more (iBarToCalc+1) than necessary for( b=limit ;b>0;b--){ // calc. all bars.
- Drop your tLastCalcBar junk - unnecessary - as I previous posted.
- Drop your decrement - unnecessary - as I previous posted. Why did you start a new thead.
- Just do it like a normal indicator and add the buffer resize code - as I previous posted.
Hi, WHRoeder
I want to check the way to be able to have more buffers than an indicator allows and I want to be able to transfer them into an EA, that's why I choose this way!
add 1) may be you haven't looked carfully, instead of your
for(int iBar = iBarShift(NULL,0, rcsAnalyzed); iBar >= 0; iBar--){ ... } rcsAnalyzed = Time[0];
I use (rcsAnayzed => tLastBarCalc, iBar => b):
if ( tLastCalcBar != Time[0] ) { // calBr[0] iBarToCalc = intMin( BarsBack, iBarShift(NULL, 0, tLastCalcBar) ); for( b=iBarToCalc+1;b>0;b--){..} tLastCalcBar = Time[0];
it's pretty much the same - no?
add 2) Decremented is only b, the not-yet-calculated bars, this is exactly what you do yourself (..; iBar--) - so what do you mean?
add 3) Again I am using you suggestion!! Only that I added the option to have array-sizes less than Bars and to keep the size of the arrays constant.
Changing the size of an array cut or adds only at the end. I checked that and it worked.
So I did mainly what you proposed, I don' see your point.
Gooly
I want to check the way to be able to have more buffers than an indicator allows and I want to be able to transfer them into an EA, that's why I choose this way!
- More buffers is irrelevant. You rewrote my ResizeBuffer() routine. You have your buffers. Your way does not work.
- I've tried 1, twice You just won't listen. You need to fill them out properly.
- You can not access the additional indicator buffers in the EA via iCustom(). If you really need them you'll have to move indicator into the EA like I posted. Or split the indicator into pieces.
- 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,
my indicator show a strange behaviour as the values of the Data-Window and the curves that are shown are not what it has calculated??
The structure of my indicator is as follows:
So what happens?
During last night every 10 min it printed out the buffer values (s.b. under printed)
But this morning the values of the Data-Window and the curves of the buffer (s.b. under Data-Window pre) differ totally from what was printed during the night.
At least the curves correspond to the values of the Data-Window.
But when I force the indicator to re-calc all its values by "open properties" and "OK" the are exactly as the were printed during the night, s.b. under Data-Window post.
Here the value example of 5:40 and 5:50 this morning at about 9:00:
pre
pre
As you can see pre-recalc. at 5:40 buffer3=4.20, printed at that time was 1.03 and post-recalc. the Data-Windows now shows 1.03.
At least this tells me the calculation should be correct, but why mt4 (build 451) shows s.th. else?
Dos anybody has had similar experiences and knows what to do?
Thanks in advance,
Gooly