海龟交易-唐奇安通道 Donchian Channel.mq5-MT5指标-峰汇在线
诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 5 > MT5指标 > 正文

海龟交易-唐奇安通道 Donchian Channel.mq5

Donchian Channel 指标绘制通道线。

图表:Donchian Channel 指标

源码:

//+------------------------------------------------------------------+
//|                                             Donchian Channel.mq5 |
//|                   Copyright 2009-2017, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link      "http://www.125808047.com"
#property version   "1.00"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
input int 上轨周期=10;
input int 下轨周期=10;

//--- plot up
#property indicator_label1  "上轨"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot dn
#property indicator_label2  "下轨"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrLime
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//--- indicator buffers
double         upBuffer[];
double         dnBuffer[];

int OnInit()
  {
   SetIndexBuffer(0,upBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,dnBuffer,INDICATOR_DATA);
   
   ArraySetAsSeries(upBuffer,1);
   ArraySetAsSeries(dnBuffer,1);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
  }

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 limit=1000;
    if(prev_calculated>0) limit=10;
    for(int i=0;i<limit;i++)
     { upBuffer[i]=HHV(上轨周期,0,i+1);
       dnBuffer[i]=LLV(下轨周期,0,i+1);
     }
   
   return(rates_total);
  }

double HHV(int count,ENUM_TIMEFRAMES tf,int start=1)
  { double array[];
    CopyHigh(Symbol(),tf,start,count,array);
    ArraySetAsSeries(array,true);
    int i=ArrayMaximum(array);
    return(array[i]);
  } 
double LLV(int count,ENUM_TIMEFRAMES tf,int start=1)
  { double array[];
    CopyLow(Symbol(),tf,start,count,array);
    ArraySetAsSeries(array,true);
    int i=ArrayMinimum(array);
    return(array[i]);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 海龟交易-唐奇安通道 Donchian Channel.mq5
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏