最后由 akkk333 于 2020-6-21 09:48 编辑
- #property version "1.00"
- #property strict
- #property indicator_chart_window
- #property indicator_buffers 4
- #property indicator_plots 4
- //--- plot da
- //--- plot xiao
- #property indicator_label2 "xiao"
- #property indicator_type2 DRAW_LINE
- #property indicator_color2 clrYellow
- #property indicator_style2 STYLE_SOLID
- #property indicator_width2 1
- //--- plot up
- #property indicator_label3 "up"
- #property indicator_type3 DRAW_ARROW
- #property indicator_color3 clrWhite
- #property indicator_style3 STYLE_SOLID
- #property indicator_width3 1
- //--- plot down
- #property indicator_label4 "down"
- #property indicator_type4 DRAW_ARROW
- #property indicator_color4 clrAqua
- #property indicator_style4 STYLE_SOLID
- #property indicator_width4 1
- //--- input parameters
- input int 大周期=10;
- input int 小周期=30;
- //--- indicator buffers
- double daBuffer[];
- double xiaoBuffer[];
- double upBuffer[];
- double downBuffer[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- //--- indicator buffers mapping
- SetIndexBuffer(0,daBuffer);
- SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrRed);
- SetIndexLabel(0,"da");
- SetIndexBuffer(1,xiaoBuffer);
- SetIndexBuffer(2,upBuffer);
- SetIndexBuffer(3,downBuffer);
- SetIndexArrow(2,225);
- SetIndexArrow(3,226);
- //---
- return(INIT_SUCCEEDED);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int OnCalculate(const int rates_total,
- const int prev_calculated,
- const datetime &time[],
- const double &open[],
- const double &high[],
- const double &low[],
- const double &close[],
- const long &tick_volume[],
- const long &volume[],
- const int &spread[])
- {
- //---
- int i=0;
- for (i=0;i<600;i++)
- {
- daBuffer= iMA(NULL,0,大周期,0,MODE_SMA,PRICE_CLOSE,i);
- xiaoBuffer= iMA(NULL,0,小周期,0,MODE_SMA,PRICE_CLOSE,i);
- }
- for (i=0;i<600;i++)
- {
- if (xiaoBuffer>daBuffer && xiaoBuffer[i+1]<daBuffer[i+1]);
- {
- upBuffer=daBuffer;
- }
- if (xiaoBuffer<daBuffer && xiaoBuffer[i+1]>daBuffer[i+1]);
- {
- downBuffer=xiaoBuffer;
- }
- }
- //--- return value of prev_calculated for next call
- return(rates_total);
- }
-
复制代码
|