诚信为本
量力而为
当前位置:首页MetaTrader 4MT4指标双重平滑随机振荡器 DSS_Bressert.mq4

双重平滑随机振荡器 DSS_Bressert.mq4

DSS_Bressert 指标用法继承KD指标的用法,80以上超买,20以下超卖。

图表:DSS Bressert 指标

源码:

//+------------------------------------------------------------------+
//|                                                 DSS Bressert.mq4 |
//|                       Copyright @2008, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright @2008, MetaQuotes Software Corp."
#property link      "http://www.125808047.com"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 DarkBlue
#property indicator_level1 20
#property indicator_level2 80

extern int       EMA_period=8;
extern int       Stochastic_period=13;
double DssBuffer[];
double MitBuffer[];
double smooth_coefficient;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,DssBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,MitBuffer);
   
   SetIndexEmptyValue(0, 0.0);
   SetIndexLabel(0, "DSS");
   SetIndexEmptyValue(1, 0.0);
   SetIndexLabel(1, "MIT");
   IndicatorShortName ("DSS("+EMA_period+","+Stochastic_period+")");
   smooth_coefficient = 2.0 / (1.0 + EMA_period);
   Comment("www.125808047.com");
   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, limit, counted_bars=IndicatorCounted();
   if (counted_bars == 0)   limit = Bars - Stochastic_period;
   if (counted_bars > 0)   limit = Bars - counted_bars;
   
   double HighRange, LowRange;
   double delta, MIT;
   for (i = limit; i >= 0; i--)
      {
      HighRange = High[iHighest(NULL,0,MODE_HIGH,Stochastic_period,i)];
      LowRange = Low[iLowest(NULL,0,MODE_LOW,Stochastic_period,i)];
      delta = Close[i] - LowRange;
      MIT = delta/(HighRange - LowRange)*100.0;
      MitBuffer[i] = smooth_coefficient * (MIT - MitBuffer[i+1]) + MitBuffer[i+1];
      }

   double DSS;
   for (i = limit; i >= 0; i--)
      {
      HighRange = MitBuffer[ArrayMaximum(MitBuffer, Stochastic_period, i)];
      LowRange = MitBuffer[ArrayMinimum(MitBuffer, Stochastic_period, i)];
      delta = MitBuffer[i] - LowRange;
      DSS = delta/(HighRange - LowRange)*100.0;
      DssBuffer[i] = smooth_coefficient * (DSS - DssBuffer[i+1]) + DssBuffer[i+1];
      }
   return(rates_total);
  }
版权所有转载请注明标题及链接:峰汇在线 » 双重平滑随机振荡器 DSS_Bressert.mq4
上一篇:
下一篇:
分享到: 更多 (0)