小飞鱼20123 发表于 2019-10-27 11:03:29

拉盖尔指标加上箭头指示

初学MT4编程,一直想在图上显示某指标的上穿和下穿箭头,今天终于成功了!


源码如下:
//+------------------------------------------------------------------+
#property copyright "Emerald King"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_level2 0.75
#property indicator_level3 0.45
#property indicator_level4 0.15

//---- input parameters
extern double gamma=0.66;
extern int CountBars=9999;

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;

double val1[];
double ExtMapBuffer1[];    //Fleche Haut
double ExtMapBuffer2[];    //Fleche Bas
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{
//---- indicators
//----
   SetIndexBuffer(0,val1);
   //---- Styles et couleur des Fleches      
   SetIndexStyle(1, DRAW_ARROW, 0, 1);    // LAGURRE 上0.15画红箭头233
   SetIndexArrow(1, 233);
   SetIndexBuffer(1, ExtMapBuffer1);
   SetIndexStyle(2, DRAW_ARROW, 0, 1);    // LAGURRE 下0.75画兰箭头234
   SetIndexArrow(2, 234);
   SetIndexBuffer(2, ExtMapBuffer2);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                     |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here

//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if (CountBars>Bars) CountBars=Bars;//已赋值的柱数等于图表中的柱数
   SetIndexDrawBegin(0,Bars-CountBars);

   int    i,j,limit;
   int    counted_bars=IndicatorCounted();//已计算过的柱数


//----      
   limit=Bars-counted_bars;

   //if(CountBars<=Lookback) return(0);
   //---- initial zero
   //if(counted_bars<1)
   //{
   //   for(i=1;i<=Lookback;i++) val1=0.0;
   //}

   i=CountBars-1;
   while(i>=0)
   {
      L0A = L0;
      L1A = L1;
      L2A = L2;
      L3A = L3;
      L0 = (1 - gamma)*Close + 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);
      val1 = LRSI;


      if(val1>0.15 && val1<0.15)// LAGURRE 上0.15
      {
         ExtMapBuffer1=val1;
      }

      if(val1<0.75 && val1>0.75)// LAGURRE 下0.75
      {
         ExtMapBuffer2=val1;
      }

          i--;
        }
               
   return(0);
}
//+------------------------------------------------------------------+


WEILIAN 发表于 2020-4-22 17:37:33

拉盖尔指标加上箭头指示

炒他妈的外汇 发表于 2020-7-13 21:02:27

帮你顶下哈!!

被遗忘 发表于 2020-7-20 21:02:14

学习了,不错

美女矜持点 发表于 2020-8-3 15:35:21

学习了,不错

voew8582 发表于 2020-8-7 11:38:29

帮你顶下哈!!

qq2395692593 发表于 2020-8-13 17:38:37

学习了,不错

臭不要脸的 发表于 2020-9-7 13:05:28

学习了,不错

卜袁冬伟 发表于 2020-11-7 18:31:55

{:1_186:}

hqdqxqbk 发表于 2021-7-27 15:38:08

顶下
页: [1] 2
查看完整版本: 拉盖尔指标加上箭头指示