CopyBuffer returns -1

 

The following script return -1 (instead of 2) if the graph period is different from 10 minutes

void OnStart()
{ 
  double handBoll=iBands(_Symbol,PERIOD_M10,20,0,2.0,PRICE_CLOSE);
  double Boll[];
  Print(CopyBuffer(handBoll,0,0,2,Boll);
  return;
}
especially when I just changed timeframe
 
danielth posted  :

The following script return -1 (instead of 2) if the graph period is different from 10 minutes

especially when I just changed timeframe

 

It's possible that a handle of type double could cause that problem because it gets stored as NNN.999999999 and gets truncated down to NNN.  It should be type int.

Paul

http://paulsfxrandomwalk.blogspot.com/ 

Regularly emailing the status of an account
  • 2012.06.14
  • Paul
  • paulsfxrandomwalk.blogspot.com
Prompted by a query, I thought I'd post a useful little utility that I have used for ages which emails the status of the account every hour.  After lengthy deliberation I decided to call it .... EmailStatus.  With only a small modification it could be used to log the status to a file, and the time...
 

Hello¨Paul,

Thanks for your remark

I changed the handle declaration to Int instead of Double.

But it makes no difference (still returns -1) when I change to a time frame different from 10 minutes (at least until a new candle shows up)

Daniel 

 

 

You need to wait for indicator calculating.

while(!IsStopped())
  {
   if(BarsCalculated(handBoll)>0) break;
   Sleep(5);
  }