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

CyAn_2_Inst Trendline.mq4

CyAn_2_Inst Trendline指标绘制特定的价格均线。

图表:CyAn_2_Inst Trendline指标

源码:

//+------------------------------------------------------------------+
//|                                         CyAn_2_Inst Trendline.mq4|
//|                          Copyright @2006, Luis Guilherme Damiani |
//+------------------------------------------------------------------+
#property copyright "Copyright @2006, Luis Guilherme Damiani"
#property link      "http://www.125808047.com/"

#property indicator_buffers 2
#property indicator_chart_window

#property indicator_color1 Lime
#property indicator_color2 Red

extern double       alpha=0.07;
extern int       maxbars=2000;
extern string 
Price_Choice="-----  Typical or Median  --------------";
extern bool is_median=true;

double ind1[];
double ind2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ind1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ind2);
   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[])
  {
      double pr0,pr1,pr2=0;
      
      int    counted_bars=IndicatorCounted();

      if(counted_bars<0) return(-1);
      int limit=Bars-counted_bars;
      if(limit>maxbars)limit=maxbars;      

      for (int i = limit; i>=0;i--)
      {
         if(is_median)
         {
            pr0=(High[i]+Low[i])/2;
            pr1=(High[i+1]+Low[i+1])/2;
            pr2=(High[i+2]+Low[i+2])/2;      
         }
         else
         {
            pr0=(High[i]+Low[i]+Close[i])/3;
            pr1=(High[i+1]+Low[i+1]+Close[i+1])/3;
            pr2=(High[i+2]+Low[i+2]+Close[i+2])/3;      
         }
	      
	      ind1[i]=(alpha-MathPow(alpha/2,2))*pr0
	           +(MathPow(alpha,2)/2)*pr1
	           -(alpha-3*MathPow(alpha,2)/4)*pr2
	           + 2*(1-alpha)*ind1[i+1]
	           -MathPow(1-alpha,2)*ind1[i+2];
	      ind2[i]=2*ind1[i]-ind1[i+2];
       }
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » CyAn_2_Inst Trendline.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏