移动平均数 - 页 105

 
person77:
妙不可言--效果非常好,Mladen!非常感谢你。

如果不是太麻烦的话,我有几个要求。

1. 当4个MA都在同步时,价格回撤并触及一个指定的MA

(在这种情况下,第二条最短的MA,红色的15 EMA),我希望有一个箭头和警报产生。

然后我将改变到较小的1M时间框架,在那里寻找空头信号。

我插入水平线和垂直线,这样就很容易发现在较小的1M时间框架回测中要看的地方(A点)。

2. 我可以要求4ma同步indy只寻找两到三个ma的同步,以显示柱状图吗?(请看1米条件附件,了解我在这里要做的事情)

人77

恐怕这个指标的设计或预测不是为了显示价格触动。而且我很肯定,现在已经有很好的指标在做这种工作了。

至于2个和3个mas的版本:只需将代码中的""替换成 "if (ma1<ma2 && ma2<3" ... "等等,然后将2个mas设置为3个不同mas的相同值,或者将2对mas设置为相同的值,就可以让指标显示2个mas。

 

mladen

谢谢你的建议。

我的编码几乎是无用的!

我把>和<改成了=,但在编译时出现了一些错误。

我需要做什么不同的事情呢?

//------------------------------------------------------------------

#property copyright "www.forex-tsd.com"

#property link "www.forex-tsd.com"

//------------------------------------------------------------------

#属性 indicator_separate_window

#属性 indicator_buffers 2

#属性 indicator_color1 LimeGreen

#属性 indicator_color2 DarkOrange

#属性 indicator_width1 2

#属性 indicator_width2 2 2

#属性 indicator_minimum 0

#属性 indicator_maximum 1

extern int Ma1Period = 5;

extern int Ma1Price = PRICE_CLOSE;

extern int Ma1Method = MODE_EMA;

extern int Ma1Shift = 0;

外置 int Ma2Period = 15;

外置 int Ma2Price = PRICE_CLOSE;

外部int Ma2Method = MODE_EMA;

外置int Ma2Shift = 0;

外置 int Ma3Period = 28;

外置 int Ma3Price = PRICE_CLOSE;

外部int Ma3Method = MODE_EMA;

外置int Ma3Shift = 0;

外置 int Ma4Period = 45;

外置 int Ma4Price = PRICE_CLOSE;

外置int Ma4Method = MODE_EMA;

外置int Ma4Shift = 0;

//

//

//

//

//

双重histu[]。

double histd[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

SetIndexBuffer(0,histu); SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexBuffer(1,histd); SetIndexStyle(1,DRAW_HISTOGRAM);

return(0);

}

int deinit() { return(0); }

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int start()

{

int counted_bars = IndicatorCounted()。

如果(counted_bars < 0)返回(-1)。

如果(counted_bars > 0)counted_bars--。

int limit = MathMin(Bars-counted_bars,Bars-1);

//

//

//

//

//

for(int i = limit; i >=0; i--)

{

double ma1 = iMA(NULL,0,Ma1Period,Ma1Shift,Ma1Method,Ma1Price,i);

double ma2 = iMA(NULL,0,Ma2Period,Ma2Shift,Ma2Method,Ma2Price,i);

double ma3 = iMA(NULL,0,Ma3Period,Ma3Shift,Ma3Method,Ma3Price,i);

double ma4 = iMA(NULL,0,Ma4Period,Ma4Shift,Ma4Method,Ma4Price,i);

histu =EMPTY_VALUE;

histd = EMPTY_VALUE;

if(ma1=ma2 && ma2=ma3&& ma3>ma4) histu = 1;

if(ma1=ma2 && ma2=ma3&& ma3<ma4) histd = 1;

}

return(0);

}

 

使用MA的Renko图表2min怎么样?

谢谢你的建议

 
person77:
mladen

谢谢你的建议。

我的编码几乎是无用的!

我把>和<改为=,但在编译时出现了一些错误。

我需要做什么不同的事情呢?

//------------------------------------------------------------------

#property copyright "www.forex-tsd.com"

#property link "www.forex-tsd.com"

//------------------------------------------------------------------

#属性 indicator_separate_window

#属性 indicator_buffers 2

#属性 indicator_color1 LimeGreen

#属性 indicator_color2 DarkOrange

#属性 indicator_width1 2

#属性 indicator_width2 2 2

#属性 indicator_minimum 0

#属性 indicator_maximum 1

extern int Ma1Period = 5;

extern int Ma1Price = PRICE_CLOSE;

extern int Ma1Method = MODE_EMA;

extern int Ma1Shift = 0;

外置 int Ma2Period = 15;

外置 int Ma2Price = PRICE_CLOSE;

外部int Ma2Method = MODE_EMA;

外置int Ma2Shift = 0;

外置 int Ma3Period = 28;

外置 int Ma3Price = PRICE_CLOSE;

外部int Ma3Method = MODE_EMA;

外置int Ma3Shift = 0;

外置 int Ma4Period = 45;

外置 int Ma4Price = PRICE_CLOSE;

外置int Ma4Method = MODE_EMA;

外置int Ma4Shift = 0;

//

//

//

//

//

双重histu[]。

double histd[];

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

SetIndexBuffer(0,histu); SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexBuffer(1,histd); SetIndexStyle(1,DRAW_HISTOGRAM);

return(0);

}

int deinit() { return(0); }

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int start()

{

int counted_bars = IndicatorCounted()。

如果(counted_bars < 0)返回(-1)。

如果(counted_bars > 0)counted_bars--。

int limit = MathMin(Bars-counted_bars,Bars-1);

//

//

//

//

//

for(int i = limit; i >=0; i--)

{

double ma1 = iMA(NULL,0,Ma1Period,Ma1Shift,Ma1Method,Ma1Price,i);

double ma2 = iMA(NULL,0,Ma2Period,Ma2Shift,Ma2Method,Ma2Price,i);

double ma3 = iMA(NULL,0,Ma3Period,Ma3Shift,Ma3Method,Ma3Price,i);

double ma4 = iMA(NULL,0,Ma4Period,Ma4Shift,Ma4Method,Ma4Price,i);

histu = EMPTY_VALUE;

histd = EMPTY_VALUE;

if(ma1=ma2 && ma2=ma3&& ma3>ma4) histu = 1;

if(ma1=ma2 && ma2=ma3&& ma3<ma4) histd = 1;

}

返回(0)。

}

人77

你应该用">="替换"<"(而不仅仅是"=")。

_____________________

PS:忘了告诉大家,2个MAs总是同步的

 

那是完美的工作!

谢谢mladen。

 

考夫曼自适应移动平均线

考夫曼自适应移动平均线(作者:Alexander Gettinger)

考夫曼自适应移动平均线(KAMA)是由佩里-考夫曼创造的,并在他的《更聪明的交易》(1995)一书中首次提出。

Formulas:

KAMA = KAMA+sc*(价格-KAMA),其中

sc = (er*0.6015+0.0645)*(er*0.6015+0.0645)。

er = Abs(Price-Price)/Sum1。

Sum1 = 从(i-Length+1)到i的Sum(Abs(Price-Price))。

附加的文件:
kama.mq4  2 kb
 

线性回归 的两个版本(来自同一作者)

 

考夫曼AMA预过滤

为其他一些事情准备考夫曼AMA(自适应移动平均线),这里有一个版本,有一个非常简化的使用方法(现在ama计算被做成了一个函数)。它也可以有每个过滤的价格(而不是使用原始价格,可以使用过滤的价格(要打开过滤,将PriceFilter设置为1)。

附加的文件:
 

MA28 (Alexander Gettinger著)

附加的文件:
ma28.mq4  4 kb
ma28.png  83 kb
 

能否将该指标做成多时间框架? 谢谢

mladen:
为其他一些事情准备考夫曼AMA(自适应移动平均线),这里有一个版本,有一个非常简化的使用方法(ama计算现在被做成一个函数)。它也可以有每个过滤的价格(而不是使用原始价格,可以使用过滤的价格(要打开过滤,将PriceFilter设置为1)。