[MT4指标]fAMA指标
通过快慢均线得到一个稳定的均线系统指标
主图指标
mt4指标类型:趋势指标
是否能用在mt4手机版上:否
是否含有未来函数:否
//+------------------------------------------------------------------+
//| fAMA.mq4 |
//| Copyright ? 2005, Profi_R |
//+------------------------------------------------------------------+
#property copyright "Copyright ? 2005, Profi_R"
#property link "[email protected]"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Crimson
//---- input parameters
extern int Range=10;
extern int FastMA=2;
extern int SlowMA=30;
extern int filter=50;
extern int n=4;
extern int h=10;
//---- buffers
double fAMA;
double mAMA;
double AMA;
double k1,k2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name; //钺?怆屙桢 镥疱戾眄铋 short_name 蜩镟 "耱痤觐恹?"
//---- indicators
IndicatorBuffers(3);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(0,fAMA);
SetIndexBuffer(1,mAMA);
SetIndexBuffer(2,AMA);
//---- name for DataWindow and indicator subwindow label
//镥疱戾眄铋 short_name 镳桉忄桠噱? 耱痤觐忸? 珥圜屙桢 疣忭铄 恹疣驽龛?
short_name="AMA("+Range+","+FastMA+","+SlowMA+","+filter+","+n+","+h+")";
//潆? 铗钺疣驽龛? 磬 沭圄桕? 镳桉忸桁 桧滂赅蝾痼 牮囹觐? 磬桁屙钼囗桢
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);//玉蜞眍忤? 戾蜿? 潆? 狍翦疣
//----
SetIndexDrawBegin(0,Range); //篑蜞眍怅? 磬鬣朦眍? 蝾麝? 镳铕桉钼觇 潆? 0 狍翦疣
k1=2.0/(SlowMA+1);
k2=2.0/(FastMA+1)-k1;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//---- TODO: add your code here
int cb,i,limit;
double Noise,ER,SSC,sdAMA,dAMA;
if (counted_bars==0) limit=Bars-Range;
if (counted_bars>0) limit=Bars-counted_bars;
limit--;
if(Bars<=Range) return(0);
else
{
AMA[Bars-Range]=Close[Bars-Range];
mAMA[Bars-Range]=Close[Bars-Range+1];
//for(cb=Bars-counted_bars-Range-1;cb>=0;cb--)
for(cb=limit;cb>=0;cb--)
{
Noise=0;
for(i=cb;i<=cb+Range-1;i++)
{
Noise=Noise+MathAbs(Close-Close[i+1]);
}
if(Noise!=0.0) ER=MathAbs(Close[cb]-Close[cb+Range])/Noise; else ER=0;
SSC=(ER*k2+k1);
AMA[cb]=AMA[cb+1]+NormalizeDouble(SSC*SSC*(Close[cb]-AMA[cb+1]),Digits);
mAMA[cb]=AMA[cb];
if(filter<1)
{
fAMA[cb]=mAMA[cb];
}
else
{
for(i=cb;i<=cb+SlowMA-1;i++)
{
sdAMA=sdAMA+MathAbs(mAMA-mAMA[i+1]);
}
dAMA=mAMA[cb]-mAMA[cb+1];
if(dAMA>=0)
{
if(dAMA=0;cb--)
//ObjectsRedraw();
//----
return(0);
}
//+------------------------------------------------------------------+
AMA%20Trend%20Line%20wo%20Range.jpg
