[MT4-EA]ADX交易量系统
ADX交易量系统
//+------------------------------------------------------------------+
//| ADX-StDev.mq4 |
//| Copyright 2011 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011"
//-----
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Gold
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 Aqua
//-----
extern int ADXPeriod = 5;// ADX
extern int ADXMode = 1;// 0=MODE_SMA; 1=MODE_EMA; 2=MODE_SMMA; 3=MODE_LWMA.
extern int StdPeriod = 3;// Standard Deviation
extern int StdMode = 0;// 0=MODE_SMA; 1=MODE_EMA; 2=MODE_SMMA; 3=MODE_LWMA.
//-----
double ADXBuffer;
double PlusDiBuffer;
double MinusDiBuffer;
double PlusSdiBuffer;
double MinusSdiBuffer;
double TempBuffer;
double subBuffer;
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(7);
//----
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexBuffer(0, ADXBuffer);
SetIndexBuffer(1, PlusDiBuffer);
SetIndexBuffer(2, MinusDiBuffer);
SetIndexStyle(3, DRAW_LINE, STYLE_DOT);
SetIndexBuffer(3, subBuffer);
SetIndexBuffer(4, PlusSdiBuffer);
SetIndexBuffer(5, MinusSdiBuffer);
SetIndexBuffer(6, TempBuffer);
//----
SetIndexLabel(0, "ADX");
SetIndexLabel(1, "+DI");
SetIndexLabel(2, "-DI");
SetIndexLabel(3, "StDev");
//----
SetIndexDrawBegin(0,ADXPeriod);
SetIndexDrawBegin(1,ADXPeriod);
SetIndexDrawBegin(2,ADXPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
int start()
{
double pdm,mdm,tr;
double price_high,price_low;
int starti,i,counted_bars=IndicatorCounted();
//----
i=Bars-2;
PlusSdiBuffer[i+1]=0;
MinusSdiBuffer[i+1]=0;
if(counted_bars >= i) i = Bars - counted_bars - 1;
starti = i;
//----
while(i>=0)
{
price_low=Low;
price_high=High;
//----
pdm=price_high-High[i+1];
mdm=Low[i+1]-price_low;
if(pdm<0) pdm=0; // +DM
if(mdm<0) mdm=0; // -DM
if(pdm==mdm) { pdm=0; mdm=0; }
else if(pdm 0) counted_bars--;
int limit = Bars - counted_bars;
//---- apply EMA to +DI
for(i = 0; i <= limit; i++)
{
PlusDiBuffer=iMAOnArray(PlusSdiBuffer, Bars, ADXPeriod, 0, ADXMode, i);
}
//---- apply EMA to -DI
for(i=0; i<=limit; i++)
MinusDiBuffer = iMAOnArray(MinusSdiBuffer, Bars, ADXPeriod, 0, ADXMode, i);
//---- Directional Movement (DX)
i = Bars - 2;
TempBuffer[i+1] = 0;
i = starti;
while(i >= 0)
{
double div=MathAbs(PlusDiBuffer + MinusDiBuffer);
if(div == 0.00) TempBuffer = 0;
else TempBuffer = 100 * (MathAbs(PlusDiBuffer - MinusDiBuffer) / div);
i--;
}
//---- ADX is exponential moving average and Standard Deviation
for(i = 0; i < limit; i++)
{
ADXBuffer = iMAOnArray(TempBuffer, Bars, ADXPeriod, 0, ADXMode, i);
subBuffer = iStdDevOnArray(TempBuffer, Bars, StdPeriod, 0, StdMode, i);
}
//----
return(0);
}
//+------------------------------------------------------------------+ADX-StDev.jpg
发表于:2015-06-08 07:46只看该作者
2楼
楼主无私的分享精神值得顶!!!!!
韬客社区www.talkfx.co
发表于:2015-06-21 05:55只看该作者
4楼
非常好的工具。
韬客社区www.talkfx.co
发表于:2015-08-28 10:51只看该作者
5楼
谢谢分享
韬客社区www.talkfx.co
发表于:2016-03-18 04:55只看该作者
6楼
非常好的工具。
韬客社区www.talkfx.co
7楼
辛苦啦楼主
韬客社区www.talkfx.co
发表于:2016-03-21 01:38只看该作者
8楼
支持 感謝分享
韬客社区www.talkfx.co
发表于:2016-03-23 07:33只看该作者
9楼
当然要支持,谢谢。好啊
韬客社区www.talkfx.co
发表于:2016-04-12 13:25只看该作者
10楼
謝謝分享。非常感謝樓主!
韬客社区www.talkfx.co
发表于:2017-08-26 15:57只看该作者
12楼
怎么用
韬客社区www.talkfx.co
发表于:2017-09-07 00:36只看该作者
13楼
几十个模版指标 总有一个适合你
韬客社区www.talkfx.co