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

自定义指标 lagurre cross 01.mq4

lagurre cross 01 指标创建箭头信号。

图表:lagurre cross 01 指标

源码:

//+------------------------------------------------------------------+
//|                                             lagurre cross 01.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link      "http://www.125808047.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red

extern double gamma=0.5;

double Buffer1[];
double Buffer2[];
double L0 = 0;
double L1 = 0;
double L2 = 0;
double L3 = 0;
double L0A = 0;
double L1A = 0;
double L2A = 0;
double L3A = 0;
double LRSI = 0;
double CU = 0;
double CD = 0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int OnInit()
{ 
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexBuffer(0, Buffer1);
   SetIndexArrow(0,233);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1, Buffer2);
   SetIndexArrow(1,234);
   Comment("www.125808047.com");
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
   void OnDeinit(const int reason)
  {
   int i;
   for( i=0; i<Bars; i++ ) Buffer1[i]=0;
   for( i=0; i<Bars; i++ ) Buffer2[i]=0;
  }
  
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      pos=Bars-100; 
   int      ctr=0;

   bool     rising=false;
   bool    falling=false;
      
   double p=Point();
   
   double lpc, lpp;
   
   while(pos>=1)
     {
      lpc=lagurre(pos);
      if (lpp<0.5 && lpc>0.5){Buffer1[pos]=High[pos];}
      if (lpp>0.5 && lpc<0.5) {Buffer2[pos]=Low[pos];}
 	   pos--;
     }
   return(rates_total);
  }

double lagurre (int i)
  {
   L0A = L0;
   L1A = L1;
   L2A = L2;
   L3A = L3;
   L0 = (1 - gamma)*Open[i] + gamma*L0A;
   L1 = - gamma *L0 + L0A + gamma *L1A;
   L2 = - gamma *L1 + L1A + gamma *L2A;
   L3 = - gamma *L2 + L2A + gamma *L3A;

   CU = 0;
   CD = 0;
    
   if (L0 >= L1) CU = L0 - L1;      else CD = L1 - L0;
   if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1;
   if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2;

   if (CU + CD != 0) LRSI = CU / (CU + CD);
   return(LRSI);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 自定义指标 lagurre cross 01.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏