指标名称:趋势波动跟踪
版本:MT4 ver. 1.16
这个指标是一个综合性的 趋势波动跟踪指标,结合了多种技术分析方法和滤波器,用于捕捉市场趋势并识别潜在的趋势反转信号。其核心思路是利用多种类型的移动平均线(如 JMA、SMA、EMA)以及自定义的平滑和过滤技术来对市场价格数据进行处理,从而生成准确的趋势信号。
这个指标适用于任何趋势跟踪策略,尤其在市场存在明显趋势时,它能帮助交易者捕捉到价格的趋势变化,并在趋势反转时给出明确的信号。
设置与参数说明:
- Length1, Length2:这些参数控制了 JMA 的平滑深度,值越大,趋势线的反应越慢,越小则反应越灵敏。一般来说,适合用较小的值来快速反应短期市场变化,较大的值则有助于识别长期趋势。
- Phase1, Phase2:控制 JMA 的灵敏度。正值提高灵敏度,负值则使其更为平滑。根据市场的波动性调整这些参数,能够更好地适应市场的不同情况。
- Input_Price_Customs1, Input_Price_Customs2:选择用于计算的价格类型(如收盘价、开盘价等),可以根据市场情况选择不同的价格类型,进行灵活调整。
- Ndot_Cool2_JMA_1, Ndot_Cool2_JMA_2:这些参数控制了滤波器的平滑度,影响 CFL1 和 CFL2 的灵敏度。
趋势识别:
- JMA 曲线提供了市场的长期趋势,通过观察两条 JMA 曲线的交叉点,能够识别潜在的趋势反转。
- CMA 结合了 JMA 和 CF 等多种平滑技术,确保在趋势发生反转时能够及时捕捉。
信号生成:
- 当趋势变化时,CMA 会在图表上显示箭头,指示趋势的变化。UpBuffer 表示买入信号,DnBuffer 表示卖出信号。
- 可以通过这些箭头来捕捉趋势反转时的最佳进出场时机。
应用场景:
- 趋势跟踪:适用于中长期的趋势跟踪策略,能够帮助交易者在市场趋势较为清晰时捕捉到趋势的持续性。
- 波动性市场:在市场波动较大时,JMA 和 CFL 可以有效消除噪声,捕捉到有用的趋势信号。
- 配合其他指标使用:该指标可以和其他技术分析工具(如 RSI、MACD 等)结合使用,增加交易策略的准确性。
建议使用方式:
在图表中将此指标与价格数据配合使用,观察 JMA 的走向以及箭头信号的出现。通常,趋势方向与箭头信号配合使用能带来较好的效果。
当箭头显示 UpBuffer 时,表明市场处于上升趋势,适合考虑做多;当箭头显示 DnBuffer 时,市场处于下降趋势,适合考虑做空。
部分代码展示:
//+——————————————————————+
//| 趋势波动跟踪指标.mq4 |
//| Copyright © 2009-2024, http://www.QChaos.com |
//| https://www.qchaos.com/ |
//+——————————————————————+
property copyright "Copyright © 量化混沌, http://www.qchaos.com"
property link "https://www.qchaos.com"
property version "2.01"
property strict
property description "———————————————"
property description "EA、指标公式分享"
property description "EA、指标编写业务承接"
property description "———————————————"
property description "———————————————"
property indicator_chart_window
property indicator_buffers 16
property indicator_color1 clrYellow
property indicator_color12 clrAqua
property indicator_color13 clrRed
property indicator_color15 clrAqua
property indicator_color16 clrRed
property indicator_width1 2
property indicator_width12 2
property indicator_width13 2
property indicator_width15 2
property indicator_width16 2
property strict
//—- 输入参数
extern int Length1=30;
// 平滑深度
extern int Phase1 =100;
// 参数,范围在 -150 到 +150 之间,影响过渡过程的质量
extern int Shift1 =0;
// 指标沿时间轴的偏移
extern int Input_Price_Customs1=0;
// 选择用于计算指标的价格 (0-"收盘价", 1-"开盘价", 2-"(最高价+最低价)/2", 3-"最高价", 4-"最低价")
extern int Length2=20;
// 平滑深度
extern int Phase2 =100;
// 参数,范围在 -150 到 +150 之间,影响过渡过程的质量
extern int Shift2 =0;
// 指标沿时间轴的偏移
extern int Input_Price_Customs2=0;
// 选择用于计算指标的价格 (0-"收盘价", 1-"开盘价", 2-"(最高价+最低价)/2", 3-"最高价", 4-"最低价")
extern int Ndot_Cool2_JMA_1=7;
extern int Ndot_Cool2_JMA_2=7;
extern int CCF_MA=2;
extern int CJCF_MA=2;
extern int Ndot_CJCF_1=20;
extern int Ndot_CJCF_2=20;
extern int CountBars=1000;
extern int Ma_PeriodStd = 20;
extern int Ma_Method = 0;
extern int Ma_Price = 1;
extern bool CMA2Colors=true;
//—- buffers
double CA[];
double DIR[];
double UpBuffer[];
double DnBuffer[];
double K=0;
double V1=0;
double V2=0;
int LastDir=0;
//—- buffers
double cfl[];
double cfl1[];
double ExtBuffer_CF1[];
double ExtBuffer_MA[];
double ExtBuffer_EMA[];
double ExtBuffer_CF[];
double cool21[];
double cool22[];
//—- indicator buffers
double JMA_Buf1[];
double JMA_Buf2[];
double arrow_up[];
double arrow_down[];
datetime Top=0;
double Kg1,Dr1,Ds1,Dl1,Pf1,Kg2,Dr2,Ds2,Dl2,Pf2;
double Pp;
int dig;
//+——————————————————————+
//| |
//+——————————————————————+
int init()
{
Pp = _Point;
dig = Digits;
if(NormalizeDouble(Pp,dig)==NormalizeDouble(0.00001,dig) || NormalizeDouble(Pp,dig)==NormalizeDouble(0.001,dig))
Pp*=10;
SetIndexStyle(0,DRAW_LINE);
if(CMA2Colors)
{
SetIndexStyle(11,DRAW_LINE);
SetIndexStyle(12,DRAW_LINE);
}
else
{
SetIndexStyle(11,DRAW_NONE);
SetIndexStyle(12,DRAW_NONE);
}
SetIndexBuffer(0,CA);
SetIndexBuffer(11,UpBuffer);
SetIndexBuffer(12,DnBuffer);
SetIndexBuffer(13,DIR);
SetIndexStyle(13,DRAW_NONE);
//—- indicator line
SetIndexStyle(10,DRAW_NONE);
SetIndexBuffer(10,cfl);
SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(1,cfl1);
SetIndexBuffer(2,ExtBuffer_CF1);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(3,ExtBuffer_MA);
SetIndexBuffer(4,ExtBuffer_EMA);
SetIndexBuffer(5,ExtBuffer_CF);
SetIndexStyle(3,DRAW_NONE);
SetIndexStyle(4,DRAW_NONE);
SetIndexStyle(5,DRAW_NONE);
ArraySetAsSeries(ExtBuffer_MA,true);
ArraySetAsSeries(ExtBuffer_EMA,true);
ArraySetAsSeries(ExtBuffer_CF,true);
ArraySetAsSeries(ExtBuffer_CF1,true);
SetIndexStyle(6,DRAW_NONE);
SetIndexShift(6,Shift1);
SetIndexStyle(8,DRAW_NONE);
SetIndexShift(8,Shift2);
//—- 1 indicator buffers mapping
SetIndexBuffer(6,JMA_Buf1);
SetIndexBuffer(8,JMA_Buf2);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(7,DRAW_NONE);
SetIndexBuffer(7,cool21);
SetIndexStyle(9,DRAW_NONE);
SetIndexBuffer(9,cool22);
SetIndexBuffer(14,arrow_up);
SetIndexStyle(14,DRAW_ARROW);
SetIndexArrow(14,233);
SetIndexEmptyValue(14,0);
SetIndexBuffer(15,arrow_down);
SetIndexStyle(15,DRAW_ARROW);
SetIndexArrow(15,234);
SetIndexEmptyValue(15,0);
//—-
IndicatorShortName("趋势波动跟踪指标");
// IndicatorDigits((int)MarketInfo(Symbol(),MODE_DIGITS));
//—- initial part