Hello Members,
This is the standard view of the indicator
Back Testing with Speed 32 shows something like this,
There is a big Gap, Trendline get drawn only for current few bars, not for previous one, is it normal with backtest? Or there is a problem with the coding?
Regards
Hi Here is the code structure: Can you please help?
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+1;
//---------------------
long CI = ChartID();
counter = 0;
counter2 = 0;
for(int i=0; i<= limit; i++)
{
if(Condition)
{
if(showdata == true && counter2 != 0 )
{
// calculation of data //
Range = Calculation;
Data = Calculation;
Obj_Name=IntegerToString(i)+ "step1";
ObjectCreate(Obj_Name,OBJ_TEXT,0,Time[i],Low[i]);
//Object Create properly got removed here on the post//
ObjectMove(CI,Obj_Name,0,Time[i],Low[i]);
ObjectMove(CI,Obj_Name,1,Time[i],Low[i]);
}
if(counter2 != 0)
{
Obj_Name=IntegerToString(i)+ "step2";
ObjectCreate(Obj_Name,OBJ_TREND,0,Time[i-counter2],iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,counter2,i)),Time[i-counter2],Low[i-counter2]);
//Object Create properly got removed here on the post//
}
//---------------------
counter2 = 0;
counter++;
WindowRedraw();
ChartRedraw();
}
else if(Condition)
{
if(showdata == true && counter != 0 )
{
// calculation of data //
Range2 = Calculation;
Data = Calculation;
Obj_Name=IntegerToString(i)+ "step1";
ObjectCreate(Obj_Name,OBJ_TEXT,0,Time[i],Low[i]);
ObjectSetString(CI,Obj_Name,OBJPROP_TEXT,Data);
// Objectcreat properly got removed here in the post//
ObjectMove(CI,Obj_Name,0,Time[i],Low[i]);
ObjectMove(CI,Obj_Name,1,Time[i],Low[i]);
}
if(counter != 0 )
{
Obj_Name=IntegerToString(i)+ "step3";
ObjectCreate(Obj_Name,OBJ_TREND,0,Time[i-counter],High[i-counter],Time[i-counter],iLow(Symbol(),0,iLowest(Symbol(),0,MODE_LOW,counter,i)));
// Objectcreat properly got removed here in the post//
ObjectMove(CI,Obj_Name,0,Time[i-counter],High[i-counter]);
ObjectMove(CI,Obj_Name,1,Time[i-counter],iLow(Symbol(),0,iLowest(Symbol(),0,MODE_LOW,counter,i)));
}
//---------------------
counter = 0;
counter2++;
WindowRedraw();
ChartRedraw();
}
else { counter = 0; counter2 = 0;}
}
WindowRedraw();
ChartRedraw();
RefreshRates();
Code your indicator so that it does not need graphical objects but indicator buffers or (global) variables. The tester does not 'like' (your) objects as the slow down the calculation!
I have tried that before with buffer.
counter = 0;
counter2++;
bear_buffer[i] = iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,counter2,i));
buffer[i] = iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,counter2,i));
WindowRedraw();
ChartRedraw();
But that didn't worked.
This is original
This is with backtest 32 speed.
Hope you now see the difference.
In case buffer I use following loop:
Is there any to auto refresh buffer setup & indicator reinsert codes available ?
I tried refreshrates, chartredraw, windowredraw etc.
No because they are not needed.
Your code is broken. | counter = 0; counter2++; bear_buffer[i] = iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,counter2,i)); |
First time you process all bars and it works. Second time you only reprocess bar zero, but counter2 has already been changed by the previous update of bar zero and now you change it again.
If you are going to use static variables, you must not update bar zero. Otherwise, put them in an extra buffer.
No because they are not needed.
Your code is broken. | counter = 0; counter2++; bear_buffer[i] = iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,counter2,i)); |
First time you process all bars and it works. Second time you only reprocess bar zero, but counter2 has already been changed by the previous update of bar zero and now you change it again.
If you are going to use static variables, you must not update bar zero. Otherwise, put them in an extra buffer.
I used your coding suggestion, in following way,
bull_buffer[i] = iLow(Symbol(),0,iLowest(Symbol(),0,MODE_LOW,(int)C1[i],i));
That fetched me a chart like this:
Not Working.
Forum on trading, automated trading systems and testing trading strategies
How To Create RSI TL as Indicator and The EA about RSI-TL breakout on Sub Window
Fernando Carreiro, 2017.01.20 04:59
No problem at all and very easy to solve!
Just head on over to the Freelance section and place a new job request to the community! Remember to properly define all your requirements and the amount you have on budget!
I am sure you will get many applicants in no time at all! Then just pick one that satisfies your conditions!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Members,
This is the standard view of the indicator
Back Testing with Speed 32 shows something like this,
There is a big Gap, Trendline get drawn only for current few bars, not for previous one, is it normal with backtest? Or there is a problem with the coding?
Regards