回馈论坛,公布私人指标!
在论坛里下了很多EA学到了不少东西,所以公布一下私人用的指标源码,回馈大家!
指标是根据考夫曼的自适应均线稍微修改了一下,提升了对盘整和趋势的判断
在盘整的时候完全一条直线,在趋势的时候是陡峭的斜线。
extern int PriceMode=0;//0-MID;1-HIGH;2-LOW;3-CLOSE;
extern int NoisePeriod=5;//越短对变化越敏感,越长,对短期上下急速波动的反应也越弱
extern int a=8;
extern double c=0.4;//调节噪声率的数值,数值越大对变化越迟钝,越小,对变化越敏感;
extern double Pow=2;//越大,平滑系数的脱敏度也越大
extern double DigitsAdjuster=10;//过滤小的变动
extern double Fastest=2;//最短周期
extern double Slowest=89;//最长周期
double AMA_Buffer[];
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,AMA_Buffer);
SetIndexDrawBegin(0,NoisePeriod);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int CountedBars=IndicatorCounted();
int i,Position=Bars-CountedBars;
double AppliedPrice=0;
double AMA_0=0;
string Price=
if (CountedBars 0)//重算倒数第二根K线
{
CountedBars--;
}
if (CountedBars==0)
{
i=Position-NoisePeriod;
}
else
{
i=Position;
}
while (i =0)
{
if (PriceMode==0)
{
AppliedPrice=(High+Low)/2;
Price= MID
}
if (PriceMode==1)
{
AppliedPrice=High;
Price= H
}
if (PriceMode==2)
{
AppliedPrice=Low;
Price= L
}
if (PriceMode==3)
{
AppliedPrice=Close;
Price= C
}
if (i==Position-NoisePeriod)
{
AMA_Buffer=AppliedPrice;
}
else
{
AMA_0=AMA_Buffer[i+1]+Calculater(i)*(AppliedPrice-AMA_Buffer[i+1]);
AMA_0=MathRound(AMA_0/(DigitsAdjuster*Point))*DigitsAdjuster*Point;
AMA_Buffer=AMA_0;
}
i--;
}
return(0);
}
double Calculater(int Position)
{
double Fast=2/(Fastest+1);
double Slow=2/(Slowest+1);
double Smooth=NoiseRate(Position)*(Fast-Slow)+Slow;
double C=MathPow(Smooth,Pow);
return(C);
}
double NoiseRate(int Position)
{
double H_Shift=iHighest(Symbol(),0,PRICE_HIGH,NoisePeriod,Position);
double H_Price=iHigh(Symbol(),0,H_Shift);
double L_Shift=iLowest(Symbol(),0,PRICE_LOW,NoisePeriod,Position);
double L_Price=iLow(Symbol(),0,L_Shift);
double Noise=NoiseAccumulator(Position);
double NoiseRate=(H_Price-L_Price)/Noise;
NoiseRate=a*NoiseRate-(a-1)*c;
if (NoiseRate 1)
{
NoiseRate=1;
}
if (NoiseRate 0)
{
NoiseRate=0;
}
return(NoiseRate);
}
double NoiseAccumulator(int Position)
{
double NoiseTotal=0.0000000001;
double TR1,TR2,TR3,TR4;
for (int i=Position;i Position+NoisePeriod;i++)
{
TR1=High-Low;
TR2=MathAbs(Low-Low[i+1]);
TR3=MathAbs(High-High[i+1]);
TR4=MathMax(TR2,TR3);
NoiseTotal+=MathMax(TR1,TR4);
}
return(NoiseTotal);
}
oxp 发表于 2012-4-16 15:46 nload="thumbImg(this)" border="0" alt="" />
楼主 你东西呢忘记了,不好意思
楼主,你好!
你公布的盘整和趋势判断指标源码,我觉得很好。我把源码用MQ语言编辑器编制指标时,系统提示有两处错误、9处警告,不能编制成功,不知何故?(不好意思,我编程技术很菜)不知你能不能把把该指标直接发给我?在此先谢了。
我的邮箱:261815133@qq.com
天乙初一 2012.11.08
指标是根据考夫曼的自适应均线稍微修改了一下,提升了对盘整和趋势的判断
在盘整的时候完全一条直线,在趋势的时候是陡峭的斜线。
extern int PriceMode=0;//0-MID;1-HIGH;2-LOW;3-CLOSE;
extern int NoisePeriod=5;//越短对变化越敏感,越长,对短期上下急速波动的反应也越弱
extern int a=8;
extern double c=0.4;//调节噪声率的数值,数值越大对变化越迟钝,越小,对变化越敏感;
extern double Pow=2;//越大,平滑系数的脱敏度也越大
extern double DigitsAdjuster=10;//过滤小的变动
extern double Fastest=2;//最短周期
extern double Slowest=89;//最长周期
double AMA_Buffer[];
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,AMA_Buffer);
SetIndexDrawBegin(0,NoisePeriod);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int CountedBars=IndicatorCounted();
int i,Position=Bars-CountedBars;
double AppliedPrice=0;
double AMA_0=0;
string Price=
if (CountedBars 0)//重算倒数第二根K线
{
CountedBars--;
}
if (CountedBars==0)
{
i=Position-NoisePeriod;
}
else
{
i=Position;
}
while (i =0)
{
if (PriceMode==0)
{
AppliedPrice=(High+Low)/2;
Price= MID
}
if (PriceMode==1)
{
AppliedPrice=High;
Price= H
}
if (PriceMode==2)
{
AppliedPrice=Low;
Price= L
}
if (PriceMode==3)
{
AppliedPrice=Close;
Price= C
}
if (i==Position-NoisePeriod)
{
AMA_Buffer=AppliedPrice;
}
else
{
AMA_0=AMA_Buffer[i+1]+Calculater(i)*(AppliedPrice-AMA_Buffer[i+1]);
AMA_0=MathRound(AMA_0/(DigitsAdjuster*Point))*DigitsAdjuster*Point;
AMA_Buffer=AMA_0;
}
i--;
}
return(0);
}
double Calculater(int Position)
{
double Fast=2/(Fastest+1);
double Slow=2/(Slowest+1);
double Smooth=NoiseRate(Position)*(Fast-Slow)+Slow;
double C=MathPow(Smooth,Pow);
return(C);
}
double NoiseRate(int Position)
{
double H_Shift=iHighest(Symbol(),0,PRICE_HIGH,NoisePeriod,Position);
double H_Price=iHigh(Symbol(),0,H_Shift);
double L_Shift=iLowest(Symbol(),0,PRICE_LOW,NoisePeriod,Position);
double L_Price=iLow(Symbol(),0,L_Shift);
double Noise=NoiseAccumulator(Position);
double NoiseRate=(H_Price-L_Price)/Noise;
NoiseRate=a*NoiseRate-(a-1)*c;
if (NoiseRate 1)
{
NoiseRate=1;
}
if (NoiseRate 0)
{
NoiseRate=0;
}
return(NoiseRate);
}
double NoiseAccumulator(int Position)
{
double NoiseTotal=0.0000000001;
double TR1,TR2,TR3,TR4;
for (int i=Position;i Position+NoisePeriod;i++)
{
TR1=High-Low;
TR2=MathAbs(Low-Low[i+1]);
TR3=MathAbs(High-High[i+1]);
TR4=MathMax(TR2,TR3);
NoiseTotal+=MathMax(TR1,TR4);
}
return(NoiseTotal);
}
oxp 发表于 2012-4-16 15:46 nload="thumbImg(this)" border="0" alt="" />
楼主 你东西呢忘记了,不好意思
楼主,你好!
你公布的盘整和趋势判断指标源码,我觉得很好。我把源码用MQ语言编辑器编制指标时,系统提示有两处错误、9处警告,不能编制成功,不知何故?(不好意思,我编程技术很菜)不知你能不能把把该指标直接发给我?在此先谢了。
我的邮箱:261815133@qq.com
天乙初一 2012.11.08
打赏
最新创建圈子
- 新闻EA运行效果图圈 2020-01-02
圈主:admin 帖子:1