|
20160317修改后,可用无误版
- #property indicator_separate_window
- extern int Ma_period=60;
- extern int RangeValue=5;
- double Slopebuffer[];
- double Mabuffer[];
- double prevbuffer[];
- int init()
- {
- IndicatorBuffers(3);
- SetIndexBuffer(0,Slopebuffer);
- SetIndexStyle(0,1,EMPTY,2,DarkGreen);
- SetIndexBuffer(1,Mabuffer);
- SetIndexBuffer(2,prevbuffer);
- SetIndexDrawBegin(0, Ma_period);
- return(0);
- }
- int deinit()
- {
- return(0);
- }
- int start()
- {
- int counted_bars=IndicatorCounted();
- int limit;
- if(counted_bars > 0)
- counted_bars--;
- limit = Bars - counted_bars;
- static int PrevSignal = 0, PrevTime = 0;
-
- for(int i = 0; i < limit; i++)
- {
- Mabuffer[i]=iMA(NULL,0,Ma_period,0,1,PRICE_CLOSE,i);
- }
- for(i = 0; i < limit; i++)
- {
- Slopebuffer[i]=(Mabuffer[i]-Mabuffer[i+1])/0.0001;
- }
- return(0);
- }
复制代码 |
|