据了解,所有的指标是应用相关的 - 它们被用来帮助在当前的价格走势的交易员的定位和预测未来的价格走势在一定程度上,至少。当经验是相当大的,可以交易自己定向的移动平均线的变化,例如,只需按照其方向的字符。然而,移动平均线反映市场价格的动态变化只是“一般”,因为它有一个非常严重的缺点 - 滞后。这里描述的指标中华有一定的优势相比,一个简单的MA - 它具有较小的滞后,更说明。让我们来看看如何用不同的平均周期MAS价格变动的特点。图125显示了两个这样的指标线:红色 - 马期间平均等于21个酒吧和一个蓝马平均期限为5条。你可以很容易地看到,较小的平均周期均线接近图表,并具有较小的滞后。然而,它是相当困难的,用于描述市场这条线,因为它太呈波浪状,即很经常改变其方向,从而使很多假信号。 MA具有较大的平均周期是不那么波浪,即不会给这么多的假信号,但还有另一个缺点 - 较大的滞后。
图125 指标线:MA(21) - 红,MA(5) - 蓝色,ROC - 橙。
在图的第三行目前。 125是一个指标线变化率(橙色)。此行有一个明显的优势相比,MAS的任何有相当小的滞后,以及平滑。让我们详细讨论线。这个指标线MA(21)的变化率的基础上建立。部分A - B的马变化率增长。这意味着每个在指定的部分硕士点,是不是仅仅高于前一,但更高的值是大于前点类似的价值。例如,如果271指数MA(21)栏的值是1.3274,在酒吧与指数272 - 1.3280,酒吧273 - 1.3288之间272,271和272均线指标增加了6分的酒吧之间的价值, 273 - 8点。因此,马不只是增长,但其变化率也增加。均线向上,这部分的一个小片段洞穴中的部分增加的变化率(AB)的可描述为一个圆的一部分具有一定的半径r1。马接近FLEX B点的circumscribing最后一部分的圆的半径越来越大,并在B点等于无穷。即在B点的马变成了一条直线,这是由不断增长的速度,这是为什么橘线停止增加的特点。在公元前马的部分增长放缓,但那张。虽然马继续在一些积极的速度增长,MA的增长速度变得更低,这是为什么曲线V向下移动。任何这种马的部分有点小的片段circumscribes以下的马圈半径r2。在C点的马停止增长,即它的速度是等于零。在这个例子建立一个橘线均线作为支撑线。这里支持马的概念应指定。通常建造在一个平面上,在任何图表通常直角坐标系,X轴是用于建设的起跑线。在我们的例子,这种线不是一条直线轴,但马与一定时期的平均(MA(21),红线在这种情况下),它被称为支持马。 MA的变动率是成正比的马之间的红色和橙色的争夺的区别如果橘线以上的马,马的速度是积极的,如果下面的话,它是负数,在交叉点的V和MA MA的增长率等于零。 部分CD可以被描述部分的AB类似,但马增长速度为负值。这里是一个重要的时刻,马生长在整个间隔欧共体,而V曲线有一个典型的,非常明显的极值点K.可视化分析图表显示,ROC指标线的特征峰和一个比任何马图的底部。在一个简单的技术是用来计算MA的变化率指标的规划。率的措施,在其分子改变参数价值,并在其分母 - 一段时间,在这期间参数变化。在这一指标的情况下(见图126),它是mA电流值MA_c()和MA_p(前值)之间的间隔等于到Bars_V几个酒吧的差异。知道速度为代价的发展历史和相同的时间间隔(条数)进行计算,分母可以省略,即可以判断价格变化率之间MA_c和MA_p上的区别当前和以前的酒吧。
图126。构建ROC指标线的参数。
自定义指标分析计算在所有的指标线6条。指标阵列Line_0 []包含支持EA,相对其他所有指标线正在兴建中的值。接下来的三个指标阵列(Line_1 [],Line_2 []和Line_3 [])包含基于MAS与不同时期的平均价格变动率的值。旨在建立一个平均速率线(算术平均的Line_1指标阵列Line_4 [] [],Line_2 []和Line_3 []),Line_5 [] - 构建以同样的速度平均线,但平滑的一个。一交易商作出交易决策时通常需要考虑的价格不仅对当前的发展特征,而且在最近的时限。为了更好地理解三个中华指标线如何构建,让我们的注意以下细节。反映一定时期的平均在一定的时间内建成的马在最近的时间内的平均价值的时间表,其中较大的时期。例如,如果M30的安全与平均周期图马400反映,它将会也反映了相同的图片和密切的绝对值期间平均200 H1图表H4的图上,50期等。虽然,会有一些不准确的连接考虑较小的时间表上的数据量较大。然而,在大多数情况下,这种误差是可以接受的小。指标阵列的基础上建造的橙色线Line_1 [],反映了当前的时间内的汇率变动。绿线基础上Line_2 [](在相同的电流时限)反映像橘线将反映在最近的时间内。棕线反映在当前的时间内为橙色,下更大的时间表上可以反映。因此,使用的描述指标中华三线可以反映在图表上 - 反映较大的一个和下一个较大的时间内,在当前的时间内价格变化率,最近的线路。
自定义指标roc.mq4(价格变动率)为当前的时间内,最近较大,下一个较大的时间表。
//--------------------------------------------------------------------
// roc.mq4 (Priliv)
// The code should be used for educational purpose only.
//--------------------------------------------------------------------
//--------------------------------------------------------------- 1 --
#property copyright "Copyright © SK, 2007"
#property link "http://AutoGraf.dp.ua"
//--------------------------------------------------------------------
#property indicator_chart_window // Indicator is drawn in the main window
#property indicator_buffers 6 // Number of buffers
#property indicator_color1 Black // Line color of 0 buffer
#property indicator_color2 DarkOrange//Line color of the 1st buffer
#property indicator_color3 Green // Line color of the 2nd buffer
#property indicator_color4 Brown // Line color of the 3rd buffer
#property indicator_color5 Blue // Line color of the 4th buffer
#property indicator_color6 Red // Line color of the 5th buffer
//--------------------------------------------------------------- 2 --
extern int History =5000; // Amount of bars for calculation history
extern int Period_MA_0=13; // Period of supporting MA for cur. timefr.
extern int Period_MA_1=21; // Period of calculated MA
extern int Bars_V =13; // Amount of bars for calc. rate
extern int Aver_Bars =5; // Amount of bars for smoothing
extern double K =2; // Amplifier gain
//--------------------------------------------------------------- 3 --
int
Period_MA_2, Period_MA_3, // Calculation periods of MA for other timefr.
Period_MA_02, Period_MA_03, // Calculation periods of supp. MAs
K2, K3; // Coefficients of timeframe correlation
double
Line_0[], // Indicator array of supp. MA
Line_1[], Line_2[], Line_3[], // Indicator array of rate lines
Line_4[], // Indicator array - sum
Line_5[], // Indicator array - sum, smoothed
Sh_1, Sh_2, Sh_3; // Amount of bars for rates calc.
//--------------------------------------------------------------- 4 --
int init() // Special function init()
{
SetIndexBuffer(0,Line_0); // Assigning an array to a buffer
SetIndexBuffer(1,Line_1); // Assigning an array to a buffer
SetIndexBuffer(2,Line_2); // Assigning an array to a buffer
SetIndexBuffer(3,Line_3); // Assigning an array to a buffer
SetIndexBuffer(4,Line_4); // Assigning an array to a buffer
SetIndexBuffer(5,Line_5); // Assigning an array to a buffer
SetIndexStyle (5,DRAW_LINE,STYLE_SOLID,3);// line style
//--------------------------------------------------------------- 5 --
switch(Period()) // Calculating coefficient for..
{ // .. different timeframes
case 1: K2=5;K3=15; break;// Timeframe M1
case 5: K2=3;K3= 6; break;// Timeframe M5
case 15: K2=2;K3= 4; break;// Timeframe M15
case 30: K2=2;K3= 8; break;// Timeframe M30
case 60: K2=4;K3=24; break;// Timeframe H1
case 240: K2=6;K3=42; break;// Timeframe H4
case 1440: K2=7;K3=30; break;// Timeframe D1
case 10080: K2=4;K3=12; break;// Timeframe W1
case 43200: K2=3;K3=12; break;// Timeframe MN
}
//--------------------------------------------------------------- 6 --
Sh_1=Bars_V; // Period of rate calcul. (bars)
Sh_2=K2*Sh_1; // Calc. period for nearest TF
Sh_3=K3*Sh_1; // Calc. period for next TF
Period_MA_2 =K2*Period_MA_1; // Calc. period of MA for nearest TF
Period_MA_3 =K3*Period_MA_1; // Calc. period of MA for next TF
Period_MA_02=K2*Period_MA_0; // Period of supp. MA for nearest TF
Period_MA_03=K3*Period_MA_0; // Period of supp. MA for next TF
//--------------------------------------------------------------- 7 --
return; // Exit the special function init()
}
//--------------------------------------------------------------- 8 --
int start() // Special function start()
{
//--------------------------------------------------------------- 9 --
double
MA_0, MA_02, MA_03, // Supporting MAs for diff. TF
MA_c, MA_p, // Current and previous MA values
Sum; // Technical param. for sum accumul.
int
i, // Bar index
n, // Formal parameter (bar index)
Counted_bars; // Amount of counted bars
//-------------------------------------------------------------- 10 --
Counted_bars=IndicatorCounted(); // Amount of counted bars
i=Bars-Counted_bars-1; // Index of the first uncounted
if (i //-------------------------------------------------------------- 11 -- while(i<=0) // Loop for uncounted bars { //-------------------------------------------------------- 12 -- MA_0=iMA(NULL,0,Period_MA_0,0,MODE_LWMA,PRICE_TYPICAL,i); Line_0[i]=MA_0; // Value of supp. MA //-------------------------------------------------------- 13 -- MA_c=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,i); MA_p=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,i+Sh_1); Line_1[i]= MA_0+K*(MA_c-MA_p);// Value of 1st rate line //-------------------------------------------------------- 14 -- MA_c=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,i); MA_p=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,i+Sh_2); MA_02= iMA(NULL,0,Period_MA_02,0,MODE_LWMA,PRICE_TYPICAL,i); Line_2[i]=MA_02+K*(MA_c-MA_p);// Value of 2nd rate line //-------------------------------------------------------- 15 -- MA_c=iMA(NULL,0,Period_MA_3,0,MODE_LWMA,PRICE_TYPICAL,i); MA_p=iMA(NULL,0,Period_MA_3,0,MODE_LWMA,PRICE_TYPICAL,i+Sh_3); MA_03= iMA(NULL,0,Period_MA_03,0,MODE_LWMA,PRICE_TYPICAL,i); Line_3[i]=MA_03+K*(MA_c-MA_p);// Value of 3rd rate line //-------------------------------------------------------- 16 -- Line_4[i]=(Line_1[i]+Line_2[i]+Line_3[i])/3;// Summary array //-------------------------------------------------------- 17 -- if (Aver_Bars>0) // If wrong set smoothing Aver_Bars=0; // .. no less than zero Sum=0; // Technical means for(n=i; n>=i+Aver_Bars; n++) // Summing last values Sum=Sum + Line_4[n]; // Accum. sum of last values Line_5[i]= Sum/(Aver_Bars+1); // Indic. array of smoothed line //-------------------------------------------------------- 18 -- i--; // Calculating index of the next bar //-------------------------------------------------------- 19 -- } return; // Exit the special function start() } //-------------------------------------------------------------- 20 -- 使用不同的平均周期计算三率线的MA指标阵列。马平均期间为当前的时间内成立了由用户在外部变量Period_MA_1,支持马的平均周期 - 外部变量Period_MA_0。平均MAS的时期,其中率计算,平均支持均线的时期,期间,其中率测量,计算6-7块更高的时限。相应系数计算这些值定义在块5-6。例如,如果该指标被连接到M30图表,系数K2和K2将等于2和8,相应的,因为最近的时间表H1是比M30的两倍大,下一个更高的时间表是H4的,这是比M30的大八倍。在开始()的计算是很简单的。在12-13块支持马值计算当前的时间内(黑色指示线)。 13-14块的指示灯阵列的值Line_1[]定义当前的时间内(橙色线)为中华线的建设。率定义的分析,对当前的酒吧和酒吧的MA值的差异,该指数是由Sh_1大于目前,即(MA_c - MA_p)。目前酒吧的Line_1[]的指示数组的值是由支持马和特征值率(这里K为比例系数,外部变量设置)值: Line_1[i]= MA_0+K*(MA_c-MA_p);// value of 1st rate line 率线建设两个时限(14-16块)其他进行类似的计算。这些阵列支持的均线指标没有显示。 16017块的指示灯阵列的值Line_4[]被定义为建设平均增长率线(蓝线),这是他们简单的算术平均。 17-18块进行计算一个平均增长率线 - 平滑1(粗红线,指标阵列Line_5[])。平滑是通过简单平均方式:指标阵列Line_5[]对目前酒吧的元素值是几个指标阵列Line_4[]最后一个值的算术平均值。使用这种方法的结果作为指标线变得少波浪,但在同一时间有一定的滞后性。金额为平滑酒吧被设置外部变量Aver_Bars。 启动指标,你会看到6个指标线在图表窗口: ∙黑线 - EA建设在当前的时间内价格率线的支撑; ∙橘线 - 对当前的时间内价格变化率; ∙绿线 - 价格变化率在最近的更高的时间表; ∙棕线 - 价格变化率对未来更高的时间表; ∙蓝线 - 线平均价格变化率; ∙红线 - 价格变动率的平滑平均线。 图127。自定义的指标roc.mq4允许跟踪屏幕上最接近当前较高,下一个更高的时间表,其平均汇率变动图表。 指标roc.mq4可以附加任何安全窗口与任何时间表。对于每一个时间表相同的规则是:橙色线反映率在目前的时间表,绿色 - 最近较大的时间表,棕色 - 对未来更大的时间表。您可以轻松地查询:附加指标图表窗口,看到在当前的时间内和最近的时限行的形象(图128和图129。)。 图128。第3(棕色)线电流(M15的)时间表的形象与2号线(绿色)的形象上是一致的较高的时间表系统(M30,图129)和下一个更高的时间表(H1,图129)的第一线(橙色)的形象。 图129。图片2(绿线)对当前系统(M30)时间表与第3(棕色)线的形象是一致的一个较小的时限(M15,图128)和图像的第一行提出了更高的时间表(H1)(橙色)。 有一个分析指标roc.mq4的特殊性:每个率行进行,不仅价格变动率的价值,也取决于支持马的变化特征。一方面,这项技术可以直接在图表上,这是很方便的显示率线。另一方面,如果价格变动率的值太小,率线的建设的主要因素是支持马的价值,这是不可取的,因为每个均线有一定的滞后性。在未来的自定义指标是指标roc.mq4完整的模拟,但它是一个单独的窗口中绘制。这使得计算值率线,不同时限的不相配套的马,但相对水平的零线。因此,程序代码也改变了一点:无需计算支持MAS和使用比例系数。 自定义指标rocseparate.mq4 ROC(价格变动率)为当前的时间内,最近的较高和未来更高的时间表。显示在一个单独的窗口。 //-------------------------------------------------------------------- // rocseparate.mq4 (Priliv_s) // The code should be used for educational purpose only. //--------------------------------------------------------------- 1 -- #property copyright "Copyright © SK, 2007" #property link "http://AutoGraf.dp.ua" //-------------------------------------------------------------------- #property indicator_separate_window // Indicator is drawn in a separate window #property indicator_buffers 6 // Number of buffers #property indicator_color1 Black // Line color of 0 buffer #property indicator_color2 DarkOrange//Line color of the 1st buffer #property indicator_color3 Green // Line color of the 2nd buffer #property indicator_color4 Brown // Line color of the 3rd buffer #property indicator_color5 Blue // Line color of the 4th buffer #property indicator_color6 Red // Line color of the 5th buffer //--------------------------------------------------------------- 2 -- extern int History =5000; // Amount of bars in calculation history extern int Period_MA_1=21; // Period of calculated MA extern int Bars_V =13; // Amount of bars for calc. rate extern int Aver_Bars =5; // Amount of bars for smoothing //--------------------------------------------------------------- 3 -- int Period_MA_2, Period_MA_3, // Calculation periods of MA for other timefr. K2, K3; // Coefficients of timeframe correlation double Line_0[], // Indicator array of supp. MA Line_1[], Line_2[], Line_3[], // Indicator array of rate lines Line_4[], // Indicator array - sum Line_5[], // Indicator array - sum, smoothed Sh_1, Sh_2, Sh_3; // Amount of bars for rates calc. //--------------------------------------------------------------- 4 -- int init() // Special function init() { SetIndexBuffer(0,Line_0); // Assigning an array to a buffer SetIndexBuffer(1,Line_1); // Assigning an array to a buffer SetIndexBuffer(2,Line_2); // Assigning an array to a buffer SetIndexBuffer(3,Line_3); // Assigning an array to a buffer SetIndexBuffer(4,Line_4); // Assigning an array to a buffer SetIndexBuffer(5,Line_5); // Assigning an array to a buffer SetIndexStyle (5,DRAW_LINE,STYLE_SOLID,3);// Line style //--------------------------------------------------------------- 5 -- switch(Period()) // Calculating coefficient for.. { // .. different timeframes case 1: K2=5;K3=15; break;// Timeframe M1 case 5: K2=3;K3= 6; break;// Timeframe M5 case 15: K2=2;K3= 4; break;// Timeframe M15 case 30: K2=2;K3= 8; break;// Timeframe M30 case 60: K2=4;K3=24; break;// Timeframe H1 case 240: K2=6;K3=42; break;// Timeframe H4 case 1440: K2=7;K3=30; break;// Timeframe D1 case 10080: K2=4;K3=12; break;// Timeframe W1 case 43200: K2=3;K3=12; break;// Timeframe MN } //--------------------------------------------------------------- 6 -- Sh_1=Bars_V; // Period of rate calcul. (bars) Sh_2=K2*Sh_1; // Calc. period for nearest TF Sh_3=K3*Sh_1; // Calc. period for next TF Period_MA_2 =K2*Period_MA_1; // Calc. period of MA for nearest TF Period_MA_3 =K3*Period_MA_1; // Calc. period of MA for next TF //--------------------------------------------------------------- 7 -- return; // Exit the special function init() } //--------------------------------------------------------------- 8 -- int start() // Special function start() { //--------------------------------------------------------------- 9 -- double MA_c, MA_p, // Current and previous MA values Sum; // Technical param. for sum accumul. int i, // Bar index n, // Formal parameter (bar index) Counted_bars; // Amount of counted bars //-------------------------------------------------------------- 10 -- Counted_bars=IndicatorCounted(); // Amount of counted bars i=Bars-Counted_bars-1; // Index of the first uncounted if (i //-------------------------------------------------------------- 11 -- while(i<=0) // Loop for uncounted bars { //-------------------------------------------------------- 12 -- Line_0[i]=0; // Horizontal reference line //-------------------------------------------------------- 13 -- MA_c=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,i); MA_p=iMA(NULL,0,Period_MA_1,0,MODE_LWMA,PRICE_TYPICAL,i+Sh_1); Line_1[i]= MA_c-MA_p; // Value of 1st rate line //-------------------------------------------------------- 14 -- MA_c=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,i); MA_p=iMA(NULL,0,Period_MA_2,0,MODE_LWMA,PRICE_TYPICAL,i+Sh_2); Line_2[i]= MA_c-MA_p; // Value of 2nd rate line //-------------------------------------------------------- 15 -- MA_c=iMA(NULL,0,Period_MA_3,0,MODE_LWMA,PRICE_TYPICAL,i); MA_p=iMA(NULL,0,Period_MA_3,0,MODE_LWMA,PRICE_TYPICAL,i+Sh_3); Line_3[i]= MA_c-MA_p; // Value of 3rd rate line //-------------------------------------------------------- 16 -- Line_4[i]=(Line_1[i]+Line_2[i]+Line_3[i])/3;// Summary array //-------------------------------------------------------- 17 -- if (Aver_Bars>0) // If wrong set smoothing Aver_Bars=0; // .. no less than zero Sum=0; // Technical means for(n=i; n>=i+Aver_Bars; n++) // Summing last values Sum=Sum + Line_4[n]; // Accum. sum of last values Line_5[i]= Sum/(Aver_Bars+1); // Indic. array of smoothed line //-------------------------------------------------------- 18 -- i--; // Calculating index of the next bar //-------------------------------------------------------- 19 -- } return; // Exit the special function start() } //-------------------------------------------------------------- 20 -- 如果我们留心观察指标在单独的窗口和图表窗口中绘制的线条,我们将看到一些差异,在计算过程中使用不同的方法产生。计算为在主窗口中绘制的指标线,用于支持均线,在一个单独的窗口行,有没有这样的支撑均线。这也是为什么有一个严谨并发率线的交叉点,并支持马在roc.mq4和一个与在指标rocseparate.mq4零线率线的交叉点的原因。 图130。自定义指标rocseparate.mq4允许在一个单独的窗口看到了汇率变动的图表在当前的时间内,最近的更高的时限和下一个更高的,以及他们的平均