 | |  | | 以下是转贴:
//+------------------------------------------------------------------+
//| Bolling b% .mq4 |
//| Copyright ?2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int BandPeriod=20;
extern int Deviation=2;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
//---- 3 additional buffers are used for counting.
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexBuffer(3, ExtMapBuffer4);
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- TODO: add your code here
int limit;
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//----
for(int i=0; i<limit; i++)
ExtMapBuffer2=Close;
for(i=0; i<limit; i++)
ExtMapBuffer3=iMAOnArray(ExtMapBuffer2,Bars,BandPeriod,0,MODE_SMA,i);
for(i=0; i<limit; i++)
ExtMapBuffer4=iStdDevOnArray(ExtMapBuffer2,Bars,BandPeriod,MODE_SMA,0,i);
for(i=0; i<limit; i++)
ExtMapBuffer1=(ExtMapBuffer2-(ExtMapBuffer3-Deviation*ExtMapBuffer4))/((ExtMapBuffer3+Deviation*ExtMapBuffer4)-(ExtMapBuffer3-Deviation*ExtMapBuffer4));
//----
return(0);
}
//+------------------------------------------------------------------+ |  |  |  |  |
|