分享

均线

 weewas 2011-05-28

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Silver
#property  indicator_color2  Red
#property  indicator_color3  Lime
#property  indicator_width1  2
//---- indicator parameters
//extern int FastEMA=3;
//extern int FastEMA1=5;
extern int SlowEMA=24;
extern int SlowEMA1=408;
//---- indicator buffers
double     DxdnBuffer[];
double     DxdcnSlowBuffer[];
double     DxdcnFastBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+  
int init()
{
   SetIndexStyle(0,DRAW_LINE);//DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,DxdnBuffer); 
   SetIndexBuffer(1,DxdcnSlowBuffer);
   SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,4);
   SetIndexDrawBegin(1,SlowEMA1);
   SetIndexBuffer(2,DxdcnFastBuffer);
  return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
{
   SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 4);
   int limit;
   limit = Bars - 50;
   int SlowEMAA = SlowEMA;
   int SlowEMAB = SlowEMA1;
   double opD, opD1;
   //---- macd counted in the 1-st buffer
   double hhh, lll;
   for(int i = limit; i >= 0; i--)
     {
       //寻找某范围内高低的差值点数
       SlowEMAA = (High[iHighest(NULL, 0, MODE_HIGH, SlowEMA, i)] -
                   Low[iLowest(NULL, 0, MODE_HIGH, SlowEMA, i)]) / Point;
       SlowEMAB = (High[iHighest(NULL, 0, MODE_HIGH, SlowEMA1, i)] -
                   Low[iLowest(NULL, 0, MODE_HIGH, SlowEMA1, i)]) / Point;
       //用此点数做MA
       DxdnBuffer[i] = iMA(NULL, 0, SlowEMAA, 0, MODE_SMMA, PRICE_CLOSE, i)-;
       DxdcnSlowBuffer[i] = iMA(NULL, 0, SlowEMAB, 0, MODE_SMMA, PRICE_CLOSE, i);
     }
   //判断交叉
   /*for(i = limit; i >= 0; i--)
     {
       if(((DxdnBuffer[i] - DxdcnSlowBuffer[i]) > 0) &&
          ((DxdnBuffer[i+2] - DxdcnSlowBuffer[i+2]) < 0) &&
          ((DxdnBuffer[i] - DxdnBuffer[i+2]) > 0))
           DxdcnFastBuffer[i]=DxdnBuffer[i];
       if(((DxdnBuffer[i] - DxdcnSlowBuffer[i]) < 0) &&
          ((DxdnBuffer[i+2] - DxdcnSlowBuffer[i+2]) > 0) &&
          ((DxdnBuffer[i] - DxdnBuffer[i+2]) < 0))
           DxdcnFastBuffer[i] = DxdnBuffer[i];
     }*/
  }

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多