[MT4指标]请问T3MA指标是考虑成交量的因素了吗?(附源码)
最近看了一个模板用这个指标,看指标参数的英文好像是成交量的意思,把源码发上,请懂程序的给看看(能解释一下指标算法最好了,哈哈)
//+------------------------------------------------------------------+
//| T3MA.mq4 |
//| Copyright ?2005, Nick Bilak |
//| http://www.forex-tsd.com/ |
//| modified for VolumeFactor by: ben |
//| thanks to Bilak |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, Nick Bilak"
#property link "http://www.forex-tsd.com/"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Olive
//---- indicator parameters
extern string note1 = "Moving Average";
extern int Periods = 3; //12
extern double VolumeFactor = 0.7; //0.8
extern string note4 = "change color in the Colors area too";
extern color MAcolor1 = Olive;
extern string note5 = "Display the info in what corner?";
extern string note6 = "Upper left=0; Upper right=1";
extern string note7 = "Lower left=2; Lower right=3";
extern int WhatCorner=1;
extern string note8 = "Y distance; add 10 to each MA";
extern int ydistance1=10;
//---- indicator buffers
double e1;
double e2;
double e3;
double e4;
double e5;
double e6;
double e7;
string objectma1;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string IntToStr(int X)
{
return (DoubleToStr(X, 0));
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int ydistance2;
IndicatorBuffers(7);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexDrawBegin(0,Periods);
if(
!SetIndexBuffer(0,e7) &&
!SetIndexBuffer(1,e2) &&
!SetIndexBuffer(2,e3) &&
!SetIndexBuffer(3,e4) &&
!SetIndexBuffer(4,e5) &&
!SetIndexBuffer(5,e6) &&
!SetIndexBuffer(6,e1)
)
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("T3MA("+Periods+")");
//---- initialization done
if ((WhatCorner == 2) || (WhatCorner == 3))
{
ydistance2 = 50+ydistance1;
}
else
{
ydistance1 = 20+ydistance1;
}
objectma1 = "banzaiT3"+IntToStr(Periods);
ObjectCreate(objectma1, OBJ_LABEL, 0, 0, 0);
ObjectSetText(objectma1, "T3 ("+Periods+")", 8, "Arial", MAcolor1);
ObjectSet(objectma1, OBJPROP_CORNER, WhatCorner);
ObjectSet(objectma1, OBJPROP_XDISTANCE, 2);
ObjectSet(objectma1, OBJPROP_YDISTANCE, ydistance1);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete(objectma1);
return(0);
}
//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{
int i,limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
//limit=Bars-Periods-1-counted_bars;
limit=Bars-counted_bars;
//---- main loop
for(i=limit; i>=0; i--)
{
e1=iMA(NULL,0,Periods,0,MODE_EMA,PRICE_CLOSE,i);
}
for(i=limit; i>=0; i--)
{
e2=iMAOnArray(e1,0,Periods,0,MODE_EMA,i);
}
for(i=limit; i>=0; i--)
{
e3=iMAOnArray(e2,0,Periods,0,MODE_EMA,i);
}
for(i=limit; i>=0; i--)
{
e4=iMAOnArray(e3,0,Periods,0,MODE_EMA,i);
}
for(i=limit; i>=0; i--)
{
e5=iMAOnArray(e4,0,Periods,0,MODE_EMA,i);
}
double a= VolumeFactor; //0.8;
double c1=-a*a*a;
double c2=3*a*a+3*a*a*a;
double c3=-6*a*a-3*a-3*a*a*a;
double c4=1+3*a+a*a*a+3*a*a;
//T3MA=c1*e6+c2*e5+c3*e4+c4*e3;
for(i=limit; i>=0; i--)
{
e6=iMAOnArray(e5,0,Periods,0,MODE_EMA,i);
e7=c1*e6+c2*e5+c3*e4+c4*e3;
}
//---- done
return(0);
}
/*
e1:= Mov(Pr,tPr,mt);
e2:= Mov(e1,tPr,mt);
e3:= Mov(e2,tPr,mt);
e4:= Mov(e3,tPr,mt);
e5:= Mov(e4,tPr,mt);
e6:= Mov(e5,tPr,mt);
c1:= -b*b*b;
c2:= 3*b*b+3*b*b*b;
c3:= -6*b*b-3*b-3*b*b*b;
c4:= 1+3*b+b*b*b+3*b*b;
T3MA:= c1*e6+c2*e5+c3*e4+c4*e3;
*/
//+------------------------------------------------------------------+
[ 本帖最后由 soaring00 于 2008-10-5 18:16 编辑 ]
发表于:2008-10-07 06:03只看该作者
2楼
这个指标中不涉及成交量。
计算过程很复杂,公式如下:
e1=EMA(Close,3);
e2=EMA(e1,3);
e3=EMA(e2,3);
e4=EMA(e3,3);
e5=EMA(e4,3);
e6=EMA(e5,3);
a= VolumeFactor;
c1=-a*a*a;
c2=3*a*a*a +3*a*a;
c3=-3*a*a*a -6*a*a -3*a;
c4=3*a+a*a*a +3*a*a +1;
最后显示出来的的指标线为e7:
e7=c1*e6 +c2*e5 +c3*e4 +c4*e3;
[ 本帖最后由 秃鹫 于 2008-10-7 14:17 编辑 ]
顺势
3楼
谢谢您的回复!!
韬客社区www.talkfx.co
发表于:2016-12-07 08:10只看该作者
4楼
感谢分享
韬客社区www.talkfx.co