It must be late and I can't find it. It's in an indicator, that when loaded on a chart, it works fine. But when I call it from an EA I get Zero Divide. note: I have called this from 9 other EA's. Each call gives me the same result in the Journal for Strategy Tester.
Here's the code call in the EA:
Here's the indicator code:
Any ideas would be helpful! TIA!
Here's the code call in the EA:
Inserted Code
double varPercB=iCustom(NULL,0,"bb - Percent b",bbPeriod,bbDeviation,bbPrice,0,1);
Here's the indicator code:
Inserted Code
#property indicator_separate_window #property indicator_buffers 1 //---- input parameters extern int bbPeriod=20; extern int bbDeviation=2; extern int bbPrice=PRICE_CLOSE; double PercentB[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorShortName("%b - Period="+bbPeriod+" "); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Blue); IndicatorDigits(Digits+1); SetIndexBuffer(0,PercentB); SetIndexLabel(0,"%b"); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //Bar stuff int counted_bars=IndicatorCounted(); int limit; if(counted_bars<0) return(-1); limit=Bars-counted_bars-1; for(int shift=0; shift<limit; shift++) { double bbUpper=iBands(NULL,0,bbPeriod,bbDeviation,0,bbPrice,MODE_UPPER,shift); double bbLower=iBands(NULL,0,bbPeriod,bbDeviation,0,bbPrice,MODE_LOWER,shift); PercentB[shift]=((Close[shift]-bbLower)/(bbUpper-bbLower))*100; } return(0); } //+------------------------------------------------------------------+
Any ideas would be helpful! TIA!