mt4平台3线kdj指标_三线tⅹt下载
2023-06-13 09:13:00 时间
在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 parameters
input int N =9;//%K 周期
input int M1=3;//%D 周期
input int M2=3;//慢速
//--- indicator buffers
double 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[i]=0;
hhv[i]=0;
if(i>rates_total-N)
continue;
int shift = iLowest(NULL,0,MODE_LOW,N,i);
llv[i] = low[shift];
shift = iHighest(NULL,0,MODE_HIGH,N,i);
hhv[i] = high[shift];
}
for(i=limit; i>=0; i--)
{
rsv[i] = 0;
if(hhv[i]>0 && llv[i]>0 && (hhv[i]-llv[i])!=0)
rsv[i] = (close[i]-llv[i])/(hhv[i]-llv[i])*100;
}
for(i=limit; i>=0; i--)
{
if(i==rates_total-1)
KBuffer[i]=0;
else
{
KBuffer[i] = rsv[i]*p + KBuffer[i+1]*p1;
}
}
for(i=limit; i>=0; i--)
{
if(i==rates_total-1)
DBuffer[i]=0;
else
{
DBuffer[i] = KBuffer[i]*f + DBuffer[i+1]*f1;
}
}
for(i=limit; i>=0; i--)
{
JBuffer[i] = 3*KBuffer[i] - 2*DBuffer[i];
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/170487.html原文链接:https://javaforall.cn
相关文章
- 如何在EasyGBS平台上利用宇视SDK实现录像下载?
- Adobe2023年全家桶最新版本,附下载地址!
- Adobe Acrobat 9 Pro安装破解法(附下载地址)-所有版本的Acrobat PDF编辑器
- AI智能安防平台EasyCVR告警预案可支持播放告警录像视频及下载录像文件
- Rhino软件怎么下载?建筑建模软件Rhino犀牛软件7.4中文版下载
- 物理场仿真研究 Comsol 软件安装包下载,Comsol 安装激活
- Java开源生鲜电商平台-优惠券设计与架构(源码可下载)详解编程语言
- Java 从FTP下载.上传文件详解编程语言
- 安装Linux:从RPM软件包中下载(linuxrpm下载)
- Java MySQL数据库安装步骤指南(javamysql下载)
- 安装在Linux平台上快速安装IDL(idllinux下载)
- linux下载百度云文件:一步到位(linux下载百度云文件)
- Linux下VNC安全下载指南(vnclinux下载)
- 使用Linux平台快速搭建Java应用,加速下载与部署——基于Java镜像的部署实践(linuxjava镜像)
- StarDict(星际译王)是利用GTK(GIMP TOOLKIT)开发的国际化的、跨平台的自由的桌面字典软件。它并不包含字典档,使用者须自行下载配合使用。它可以运行于多种不同的平台,如 Linux, Microsoft Windows , FreeBSD及Solaris,并使用GPL授权。
- Linux平台上可靠的DHCP下载指南(linuxdhcp下载)
- 安装ADB工具Linux下快速安装ADB工具:快进快出(adb linux 下载)
- 安卓平台MySQL下载指南(mysql下载安卓)
- 如何下载MySQL寻找合适的下载平台(mysql下载到哪里)
- 使用MYSQL技术打造高效电影App下载平台(MYSQL下载电影app)
- Oracle下载完成,安装开启新的旅程(oracle下载完安装)