当前位置:网站首页>Using KDJ metrics on MT4
Using KDJ metrics on MT4
2022-06-22 08:06:00 【EA development - green shirt code customer】
KDJ Indicators are random indicators , from K Line 、D Line and J These three curves together form , By analyzing the chart , We can figure out ,K、D、J Use different color lines to represent , So-called K A line is a quick confirmation line ,D Line refers to the slow trunk line , and J The line is the light and dark line in the direction .K Values and D The floating range of the value is 0~100, and J Value can be less than 0 Or greater than 100, Can fluctuate in a wider range .KDJ In order to judge the short-term market trend .
KDJ The calculation formula of the index is :
RSV:=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))100;
K:SMA(RSV,M1,1);
D:SMA(K,M2,1);
J:3K-2*D;
KDJ General use of indicators :
1. indicators >80 when , High return probability ; indicators <20 when , The probability of rebound is high ;
2.K stay 20 Cross left and right D when , As a buying signal ;
3.K stay 80 Cross left and right D when , As a sell signal ;
4.J>100 when , Share prices are prone to reversals ;J<0 when , The share price is easy to reverse and rise ;
5.KDJ Fluctuate in 50 Any signal left or right , It has little effect .
MT4 load KDJ
MT4 in KDJ Indicator source code
#property copyright "Copyright 2020,fxMeter"
#property link "https://www.mql5.com/zh/users/fxmeter"
#property version "2.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;
input int M1=3;
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);
}
//+------------------------------------------------------------------+
A good workman does his work well , You must sharpen your tools first , The most important thing in trading is to follow the rules , Strictly carry out . Official account , Study MQL Beginner to master EA course , Learn more EA Programming , Write your own EA, Forge your own magic weapon .
KDJ How to download indicators , Official account , Get the download connection in the resource bar .
边栏推荐
- Windchill - how to start workflow through API
- MySQL query group by 1055 is the simplest and most convenient way to solve the problem perfectly
- MySQL view
- [Oracle database] mammy tutorial day14 conversion function
- Thoughts on the construction of data analysis platform for small and medium-sized enterprises (I)
- mysql查询group by 1055 问题完美解决,最简单最便捷的方法
- 计算水费问题
- The jdbcurl is configured correctly in the project, but the jdbcurl is the wrong path after the project is started
- XMIND 2022 mind map active resources?
- [Oracle database] wet nurse tutorial day15 DDL, DML, index, view, sequence and deadlock are enough
猜你喜欢
![[普通物理]波的能量与干涉](/img/fe/066aa9e8ed776b8f069b59b7123367.png)
[普通物理]波的能量与干涉

Seven challenges faced by CIO in 2022 and Solutions

LR 2022 ultra detailed installation tutorial "latest"

Node red sends wechat official account message (template message)

模电实验——实验二 JFET共源极放大电路

【Oracle 数据库】奶妈式教程 day12 字符函数

Mt4/mql4 getting started to mastering EA tutorial lesson 3 - common functions of MQL language (III) - common functions of K-line value taking
![[Oracle database] mammy tutorial day13 date function](/img/ca/90aaa682ec393b1531060377276ca6.png)
[Oracle database] mammy tutorial day13 date function

Mt4/mql4 getting started to mastering EA tutorial lesson 4 - common functions of MQL language (IV) - common functions of K-line value

Some problems caused by null data in MySQL
随机推荐
Design skills of common table structure in database design
【 Oracle database】 Nursery Mother Tutorial day13 date Function
Cocoapods problem record
KVO summary
QT 控件增加双击事件
[songhongkang MySQL database] [advanced chapter] [06] logical architecture of MySQL
Example of QT combox
Kotlin a simple Android program
IP address planning
Mt4/mql4 getting started to proficient in foreign exchange EA automatic trading tutorial - common functions of MQL language
Detailed explanation of subnet mask
Mt4/mql4 getting started to mastering EA tutorial lesson 4 - common functions of MQL language (IV) - common functions of K-line value
Mt4/mql4 getting started to mastering EA tutorial lesson 3 - common functions of MQL language (III) - common functions of K-line value taking
[Oracle database] mammy tutorial day13 date function
C语言双向链表实现图书管理系统 可读写文件
(9) Sequential queue and stack queue
Why redis is so fast:
Wechat applets will directly open the parent element when the child element of flex:1 is too long (the text is too long)
Mt4/mql4 getting started to mastering EA tutorial lesson 5 - common functions of MQL language (V) - common functions of account information
MySQL view