指标值无法实时变动,一定要页面间切换才计算,不知道问题出在哪?望高手指教!~感激不尽!附:从MT4市场中购买的有这个指标,可以实时变动,但无法看到源码。MT4市场此指标是免费的。
代码如下:
extern int bbPeriod=20;
extern int bbDeviation=2;
extern int bbPrice=0;
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.0;
}
return(0);
}
|