诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

价格通道指标 CandleStop.mq4

CandleStop指标创建价格通道。

图表:CandleStop指标

源码:

//+------------------------------------------------------------------+
//|                                                   CandleStop.mq4 |
//|                                                           CrushD |
//+------------------------------------------------------------------+
#property copyright "CrushD"
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Lime

extern int TrailPeriods=5;

double LongTrailBuffer[];
double ShortTrailBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE, STYLE_DASH);
   SetIndexLabel(0, "Short Trail Stop");
   SetIndexBuffer(0,ShortTrailBuffer);
   SetIndexStyle(1,DRAW_LINE, STYLE_DASH);
   SetIndexLabel(1, "Long Trail Stop");
   SetIndexBuffer(1,LongTrailBuffer);
   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 counted_bars=IndicatorCounted();
   int i;
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;

   for(i=0; i<=limit; i++)
   {
      ShortTrailBuffer[i] = High[Highest(NULL, 0, MODE_HIGH, TrailPeriods, i+TrailPeriods)];
      LongTrailBuffer[i] = Low[Lowest(NULL, 0, MODE_LOW, TrailPeriods, i+TrailPeriods)];
   }
   return(rates_total);
  }
//+------------------------------------------------------------------+
打赏
版权所有转载请注明标题及链接:峰汇在线 » 价格通道指标 CandleStop.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏