kevanjj 发表于 2025-6-30 22:00:00

【交叉趋势带】趋势信号,适合做大趋势

指标名称:交叉趋势带
版本:MT4 ver. 2.01(指标)
交叉趋势带指标是一种技术分析工具,用于识别市场趋势的变化。该指标通过交叉来生成买入和卖出信号。指标的设计旨在帮助交易者识别潜在的买入和卖出机会,并通过声音和邮件提醒功能提供实时通知。特别扩大了信号箭头。参数说明

[*]TimeFrame: 时间框架,单位为分钟。默认值为当前图表的时间框架。
[*]FastMA: 快速移动平均线的设置。
[*]FastPrice: 价格模式(0...10)。
[*]FastLength: 平滑周期,默认值为21。
[*]FastMode: 移动平均线模式,默认值为10。
[*]FastShift: 快速移动平均线的位移。
[*]SlowMA: 慢速移动平均线的设置。
[*]SlowPrice: 价格模式(0...10)。
[*]SlowLength: 平滑周期,默认值为34。
[*]SlowMode: 移动平均线模式,默认值为10。
[*]SlowShift: 慢速移动平均线的位移。
[*]ShowFilled: 是否显示填充区域,默认值为true。
[*]CountBars: 计算的柱数,0表示所有柱。
[*]Alerts: 警报和邮件设置。
[*]AlertMode: 警报模式。
[*]AlertShift: 警报位移,0表示当前柱,1表示前一柱。
[*]SoundsNumber: 信号后声音的次数。
[*]SoundsPause: 声音之间的暂停时间(秒)。
[*]UpSound: 上升趋势声音文件。
[*]DnSound: 下降趋势声音文件。
[*]EmailMode: 邮件模式,0表示开启,1表示关闭。
[*]EmailsNumber: 邮件发送次数。
使用方法
[*]将指标加载到图表中,选择合适的时间框架。
[*]根据交易策略调整快速和慢速移动平均线的参数。
[*]观察图表上的买入和卖出信号箭头。
[*]启用声音和邮件提醒功能,以便在信号出现时获得通知。
指标功能
[*]买入信号: 白色,生成买入信号。
[*]卖出信号: 红色,生成卖出信号。
[*]声音提醒: 在信号生成时播放指定的声音文件。
[*]邮件提醒: 在信号生成时发送邮件通知。

部分代码展示:
[*]//+------------------------------------------------------------------+//|                                                               交叉趋势带.mq4 |//|                              Copyright © 2009-2024, www.QChaos.com |//|                                          https://www.qchaos.com/ |//+------------------------------------------------------------------+#property copyright "Copyright © 量化混沌, www.qchaos.com"#property link      "https://www.qchaos.com"#property version   "2.01"#property indicator_chart_window#property indicator_buffers 6#property indicator_color1clrRed#property indicator_color2clrWhite#property indicator_color3clrDeepSkyBlue#property indicator_color4clrRed#property indicator_color5clrBlue#property indicator_color6clrRed#property indicator_width112#property indicator_width212#property indicator_width31#property indicator_width41#property indicator_width515 #property indicator_width615//---- extern int   TimeFrame             =    0;   // 时间框架,以分钟为单位extern stringFastMA                = "--- Fast MA ---"; // 快速移动平均线extern int   FastPrice             =    0;   // 价格模式 (0...10)extern int   FastLength            =    21;// 平滑周期extern int   FastMode            =    10;// 参见上面的列表extern int   FastShift             =    0;   // 快速移动平均线位移extern stringSlowMA                = "--- Slow MA ---"; // 慢速移动平均线extern int   SlowPrice             =    0;   // 价格模式 (0...10)extern int   SlowLength            =   34;   // 平滑周期extern int   SlowMode            =    10;// 参见上面的列表extern int   SlowShift             =    0;   // 慢速移动平均线位移extern bool    ShowFilled            = true;// 是否显示填充extern int   CountBars             =    0;   // 计算的柱数:0-所有柱extern stringAlerts                = "--- Alerts & E-Mails ---"; // 警报和电子邮件extern int   AlertMode             =    0;   // 警报模式extern int   AlertShift            =    1;   // 警报位移:0-当前柱,1-前一柱extern int   SoundsNumber          =    5;   // 信号后的声音次数extern int   SoundsPause         =    5;   // 声音之间的暂停时间(秒)extern stringUpSound               = "alert.wav"; // 上升趋势声音extern stringDnSound               = "alert2.wav"; // 下降趋势声音extern int   EmailMode             =    0;   // 电子邮件模式:0-开,1-关extern int   EmailsNumber          =    1;   // 电子邮件数量double uptrend[];double dntrend[];double fast[];double slow[];double buy[];double sell[];double trend[];double fastshift[];double slowshift[];double fastprice[];double slowprice[];double   tmp[], ma;int      cBars, draw_begin, fastsize, slowsize;datetime prevtime, preTime, ptime;string   IndicatorName, TF, fast_name, slow_name;//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+int init(){   if(TimeFrame <= Period()) TimeFrame = Period();   TF = tf(TimeFrame);   if(TF== "N/A") TimeFrame = Period();      IndicatorDigits(Digits);//----       IndicatorBuffers(11);   SetIndexBuffer( 0,uptrend); SetIndexStyle(0,DRAW_HISTOGRAM);    SetIndexBuffer( 1,dntrend); SetIndexStyle(1,DRAW_HISTOGRAM);    SetIndexBuffer( 2,   fast); SetIndexStyle(2,   DRAW_LINE);    SetIndexBuffer( 3,   slow); SetIndexStyle(3,   DRAW_LINE);    SetIndexBuffer( 4,      buy); SetIndexStyle(4,    DRAW_ARROW); SetIndexArrow(4,233);       SetIndexBuffer( 5,   sell); SetIndexStyle(5,    DRAW_ARROW); SetIndexArrow(5,234);       SetIndexBuffer( 6,    trend);   SetIndexBuffer( 7,fastshift);    SetIndexBuffer( 8,slowshift);   SetIndexBuffer( 9,fastprice);   SetIndexBuffer(10,slowprice);//----         fast_name   = averageName(FastMode,fastsize);   slow_name   = averageName(SlowMode,slowsize);         IndicatorName = WindowExpertName();      IndicatorShortName(IndicatorName+"["+TF+"]("+FastPrice+","+FastLength+","+fast_name+","+SlowPrice+","+SlowLength+","+slow_name+")");      SetIndexLabel(0,fast_name+"("+FastLength+")");   SetIndexLabel(1,slow_name+"("+SlowLength+")");   SetIndexLabel(2,"buySignal");   SetIndexLabel(3,"sellSignal");//----            if(CountBars == 0) cBars = iBars(NULL,TimeFrame)*TimeFrame/Period() - MathMax(FastLength,SlowLength); else cBars = CountBars*TimeFrame/Period();   draw_begin = Bars - cBars;      SetIndexDrawBegin(0,draw_begin);   SetIndexDrawBegin(1,draw_begin);   SetIndexDrawBegin(2,draw_begin);   SetIndexDrawBegin(3,draw_begin);   SetIndexDrawBegin(4,draw_begin);   SetIndexDrawBegin(5,draw_begin);   //----      ArrayResize(tmp,MathMax(fastsize,slowsize));          return(0);}//-----int deinit(){   Comment("");   return(0);}//+------------------------------------------------------------------+//|Geo Crossover_signal                              |//+------------------------------------------------------------------+int start(){   int shift,limit, counted_bars=IndicatorCounted();         if(counted_bars > 0) limit = Bars - counted_bars - 1;   if(counted_bars < 0) return(0);   if(counted_bars < 1)   {    limit = Bars - 1;         for(int i=limit;i>=0;i--)       {      fast = EMPTY_VALUE;         slow = EMPTY_VALUE;      buy = EMPTY_VALUE;         sell = EMPTY_VALUE;      }   }      if(FastShift < 0) int fastlimit = MathAbs(FastShift); else fastlimit = limit;   if(SlowShift < 0) int slowlimit = MathAbs(SlowShift); else slowlimit = limit;          int limit1 = MathMax(limit,MathMax(fastlimit,slowlimit));         if(TimeFrame != Period())   {   limit = TimeFrame/Period()*(limit1+1);            for(shift = 0;shift < limit;shift++)       {      int y = iBarShift(NULL,TimeFrame,Time);            fast = iCustom(NULL,TimeFrame,IndicatorName,0,"",FastPrice,FastLength,FastMode,FastShift,"",SlowPrice,SlowLength,SlowMode,SlowShift,ShowFilled,CountBars,                            "",AlertMode,AlertShift,SoundsNumber,SoundsPause,UpSound,DnSound,EmailMode,EmailsNumber,2,y);      slow = iCustom(NULL,TimeFrame,IndicatorName,0,"",FastPrice,FastLength,FastMode,FastShift,"",SlowPrice,SlowLength,SlowMode,SlowShift,ShowFilled,CountBars,                            "",AlertMode,AlertShift,SoundsNumber,SoundsPause,UpSound,DnSound,EmailMode,EmailsNumber,3,y);      buy = iCustom(NULL,TimeFrame,IndicatorName,0,"",FastPrice,FastLength,FastMode,FastShift,"",SlowPrice,SlowLength,SlowMode,SlowShift,ShowFilled,CountBars,                            "",AlertMode,AlertShift,SoundsNumber,SoundsPause,UpSound,DnSound,EmailMode,EmailsNumber,4,y);      sell = iCustom(NULL,TimeFrame,IndicatorName,0,"",FastPrice,FastLength,FastMode,FastShift,"",SlowPrice,SlowLength,SlowMode,SlowShift,ShowFilled,CountBars,                            "",AlertMode,AlertShift,SoundsNumber,SoundsPause,UpSound,DnSound,EmailMode,EmailsNumber,5,y);               if(ShowFilled)         {         uptrend = iCustom(NULL,TimeFrame,IndicatorName,0,"",FastPrice,FastLength,FastMode,FastShift,"",SlowPrice,SlowLength,SlowMode,SlowShift,ShowFilled,CountBars,                               "",AlertMode,AlertShift,SoundsNumber,SoundsPause,UpSound,DnSound,EmailMode,EmailsNumber,0,y);         dntrend = iCustom(NULL,TimeFrame,IndicatorName,0,"",FastPrice,FastLength,FastMode,FastShift,"",SlowPrice,SlowLength,SlowMode,SlowShift,ShowFilled,CountBars,                               "",AlertMode,AlertShift,SoundsNumber,SoundsPause,UpSound,DnSound,EmailMode,EmailsNumber,1,y);         }      }            if(CountBars > 0)      {      SetIndexDrawBegin(0,Bars - cBars);         SetIndexDrawBegin(1,Bars - cBars);      SetIndexDrawBegin(2,Bars - cBars);      SetIndexDrawBegin(3,Bars - cBars);         SetIndexDrawBegin(4,Bars - cBars);      SetIndexDrawBegin(5,Bars - cBars);      }         return(0);   }   else   {       for(shift=limit;shift>=0;shift--)       {         if(FastPrice <= 6) fastprice = iMA(NULL,0,1,0,0,FastPrice,shift);            else         if(FastPrice > 6 && FastPrice <= 10) fastprice = HeikenAshi(FastPrice-7,cBars + FastLength,shift);                  if(SlowPrice <= 6) slowprice = iMA(NULL,0,1,0,0,SlowPrice,shift);            else         if(SlowPrice > 6 && SlowPrice <= 10) slowprice = HeikenAshi(SlowPrice-7,cBars + SlowLength,shift);            fastshift = allAveragesOnArray(0,fastprice,FastLength,FastMode,fastsize,cBars + FastLength,shift);       slowshift = allAveragesOnArray(1,slowprice,SlowLength,SlowMode,slowsize,cBars + SlowLength,shift);       }                   for(shift=limit1;shift>=0;shift--)       {      if(FastShift >=0 ||(FastShift < 0 && shift >= MathAbs(FastShift))) fast = fastshift;       if(SlowShift >=0 ||(SlowShift < 0 && shift >= MathAbs(SlowShift))) slow = slowshift;             trend = trend;            buy = EMPTY_VALUE;      sell= EMPTY_VALUE;               if(fast > slow && fast != EMPTY_VALUE && trend != 1) trend = 1;      if(fast < slow && slow != EMPTY_VALUE && trend !=-1) trend =-1;            double gap = 0.5*MathCeil(iATR(NULL,0,14,shift)/Point);                  if(trend != trend)         {         if(trend > 0) buy = MathMin(fast,slow) -   gap*Point;         if(trend < 0) sell = MathMax(fast,slow) + 2*gap*Point;          }                  if(ShowFilled)         {         uptrend = slow;         dntrend = fast;         }      }               if(CountBars > 0)      {      SetIndexDrawBegin(0,Bars - cBars);         SetIndexDrawBegin(1,Bars - cBars);      SetIndexDrawBegin(2,Bars - cBars);      SetIndexDrawBegin(3,Bars - cBars);         SetIndexDrawBegin(4,Bars - cBars);      SetIndexDrawBegin(5,Bars - cBars);      }                  if(AlertMode > 0)      {      bool upTrend = trend > 0 && trend <= 0;                        bool dnTrend = trend < 0 && trend >= 0;               if(upTrend || dnTrend)         {            if(isNewBar(TimeFrame))            {            BoxAlert(upTrend," : BUY Signal @ " +DoubleToStr(Close,Digits)+", StopLoss @ "+DoubleToStr(buy ,Digits));               BoxAlert(dnTrend," : SELL Signal @ "+DoubleToStr(Close,Digits)+", StopLoss @ "+DoubleToStr(sell,Digits));             }               WarningSound(upTrend,SoundsNumber,SoundsPause,UpSound,Time);         WarningSound(dnTrend,SoundsNumber,SoundsPause,DnSound,Time);                     if(EmailMode > 0)            {            EmailAlert(upTrend,"BUY" ," : BUY Signal @ " +DoubleToStr(Close,Digits)+", StopLoss @ "+DoubleToStr(buy ,Digits),EmailsNumber);             EmailAlert(dnTrend,"SELL"," : SELL Signal @ "+DoubleToStr(Close,Digits)+", StopLoss @ "+DoubleToStr(sell,Digits),EmailsNumber);             }         }      }   }      return(0);}

qtxh1008 发表于 2025-7-1 02:13:53

看看咋样

peterzhu2004 发表于 2025-7-1 05:21:01

测试一下看看震荡表现

我曾经是队长 发表于 2025-7-1 07:16:26

这个就是均线系统啊

qin324 发表于 2025-7-1 08:38:07

均线交叉

FXEA123 发表于 2025-7-1 10:49:53

交叉趋势带指标是一种技术分析工具,用于识别市场趋势的变化

123654789 发表于 2025-7-1 11:07:48

又没有用呢

kongyangfei 发表于 2025-7-2 20:33:14

你的源码在哪里

枫林晚 发表于 2025-7-5 23:26:14

好想试试看啊,加油活跃度

kenlee1628 发表于 2025-7-6 00:17:28

看起来不错啊

ll4040 发表于 2025-7-8 11:48:38

不知道使用 得如何

eastxuezi 发表于 2025-7-18 15:26:22

有手机信号通知吗

KING445599 发表于 2026-4-26 11:32:32

你这不是源码,放到源码的栏目里是做啥?不是源码就放无限制。真的是误导人

kevanjj 发表于 2026-4-27 11:37:09

KING445599 发表于 2026-4-26 11:32
你这不是源码,放到源码的栏目里是做啥?不是源码就放无限制。真的是误导人 ...

这是以前不会弄,又没法删除,就一直留着了
页: [1]
查看完整版本: 【交叉趋势带】趋势信号,适合做大趋势