MT4指标三线KDJ指标下载

2022-6-7 21:56| 发布者: admin| 查看: 311| 评论: 0

在MT4上,是没有三线KDJ指标的,分享KDJ指标源码:
#property copyright "Copyright 2020"#property link      "https://www.mql5.com"#property version   "1.00"#property strict#property indicator_separate_window#property indicator_buffers 3#property indicator_plots   3//--- plot KLine#property indicator_label1  "KLine"#property indicator_type1   DRAW_LINE#property indicator_color1  clrWhite#property indicator_style1  STYLE_SOLID#property indicator_width1  1//--- plot DLine#property indicator_label2  "DLine"#property indicator_type2   DRAW_LINE#property indicator_color2  clrGold#property indicator_style2  STYLE_SOLID#property indicator_width2  1//--- plot JLine#property indicator_label3  "JLine"#property indicator_type3   DRAW_LINE#property indicator_color3  clrDarkViolet#property indicator_style3  STYLE_SOLID#property indicator_width3  1#property indicator_levelstyle STYLE_DOT#property indicator_levelcolor clrSilver#property indicator_level1  0#property indicator_level2  20#property indicator_level3  50#property indicator_level4  80#property indicator_level5  100//---- input parametersinput int N =9;//%K 周期input int M1=3;//%D 周期input int M2=3;//慢速//--- indicator buffersdouble         KBuffer[];double         DBuffer[];double         JBuffer[];double llv[],hhv[],rsv[];double p=0,p1=0;double f=0,f1=0;//+------------------------------------------------------------------+//| Custom indicator initialization function                         |//+------------------------------------------------------------------+int OnInit()  {//--- indicator buffers mapping   IndicatorBuffers(6);   SetIndexBuffer(0,KBuffer);   SetIndexBuffer(1,DBuffer);   SetIndexBuffer(2,JBuffer);   SetIndexBuffer(3,llv,INDICATOR_CALCULATIONS);   SetIndexBuffer(4,hhv,INDICATOR_CALCULATIONS);   SetIndexBuffer(5,rsv,INDICATOR_CALCULATIONS);   for(int i=0; i<6; i++)     {      SetIndexDrawBegin(i,N+M1+M2);     }   SetLevelValue(0,0);   SetLevelValue(1,20);   SetLevelValue(2,50);   SetLevelValue(3,80);   SetLevelValue(4,100);   string name = "KDJ("+ (string)N+","+(string)M1+","+(string)M2+")";   IndicatorShortName(name);   IndicatorDigits(2);   if(N<=0||M1<=0||M2<=0)      return(INIT_FAILED);   p = 1.0/M1;   p1 = 1-p;   f = 1.0/M2;   f1 = 1-f;//---   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 i,limit=0;   if(rates_total<=0)      return(0);   if(prev_calculated<=0)      limit=rates_total-1;   else      limit = rates_total - prev_calculated +1;   for(i=limit; i>=0; i--)     {      llv=0;      hhv=0;      if(i>rates_total-N)         continue;      int shift = iLowest(NULL,0,MODE_LOW,N,i);      llv =  low[shift];      shift = iHighest(NULL,0,MODE_HIGH,N,i);      hhv = high[shift];     }   for(i=limit; i>=0; i--)     {      rsv = 0;      if(hhv>0 && llv>0 && (hhv-llv)!=0)         rsv = (close-llv)/(hhv-llv)*100;     }   for(i=limit; i>=0; i--)     {      if(i==rates_total-1)         KBuffer=0;      else        {         KBuffer = rsv*p + KBuffer[i+1]*p1;        }     }   for(i=limit; i>=0; i--)     {      if(i==rates_total-1)         DBuffer=0;      else        {         DBuffer = KBuffer*f + DBuffer[i+1]*f1;        }     }   for(i=limit; i>=0; i--)     {      JBuffer = 3*KBuffer - 2*DBuffer;     }//--- return value of prev_calculated for next call   return(rates_total);  }//+------------------------------------------------------------------+
回复

使用道具 举报

上一篇:真实校园灵异事件之校园鬼魂!

下一篇:《我叫mt4》里最弱的三个职业,大神单手操作,菜鸟却被各种虐!

sitemap.txt | sitemap.xml | sitemap.html |Archiver|手机版|小黑屋|创业那点事 ( 湘ICP备2022005879号-1 )

GMT+8, 2024-5-8 09:19 , Processed in 0.261199 second(s), 42 queries .

快速回复 返回顶部 返回列表