kevanjj 发表于 2025-6-27 21:11:07

【TDI Alerts v3】趋势通道判断方向

指标名称:TDI
版本:MT4ver. 3.0

一、指标简介TDI Alerts v3 是一款综合型交易指标,结合了趋势方向、市场强度和波动性分析。它通过多条颜色线帮助您快速判断市场状态:
[*]绿色线(RSI价格线):反映短期价格动向。
[*]红色线(交易信号线):辅助判断买卖时机。
[*]蓝色带(波动带):显示市场波动范围,扩张时趋势强,收缩时趋势弱。
[*]黄色线(市场基准线):判断整体趋势方向,通常在中线(32-68)之间波动。

二、安装步骤1. 下载指标,复制指标到MT4的 `MQL4/Indicators` 文件夹。2. 重启MT4,在“导航”窗口找到该指标,拖拽到图表即可。三、核心信号解读1. 趋势方向短期趋势:
[*]绿线在红线上方 → 价格上涨。
[*]红线在绿线上方 → 价格下跌。
整体趋势:
[*]黄线向上且价格在黄线上方 → 适合做多。
[*]黄线向下且价格在黄线下方 → 适合做空。

2. 买卖信号
[*]强买入:绿线 > 红线& 红线 > 黄线。
[*]强卖出:绿线 < 红线& 红线 < 黄线。
[*]超买/超卖:绿线触及上方蓝带(超买)或下方蓝带(超卖)。

3. 波动性
[*]蓝色带扩张 → 趋势强劲,适合跟随。
[*]蓝色带收缩 → 市场盘整,谨慎交易。

六、常见问题1. 指标不显示?
检查是否安装到正确文件夹,重启MT4。2. 警报不工作?
确保MT4允许弹出窗口和声音,邮件需提前设置SMTP。3. 如何调整灵敏度?
减小`RSI_Period`或`Volatility_Band`值,指标会更敏感。通过掌握TDI Alerts v3的多维度信号,能更自信地捕捉趋势和规避风险。参数:具体参数设置以及含义,可以参考部分代码展示内的参数注释。部分代码展示:
[*]
//+------------------------------------------------------------------+//|                                                    TDI Alerts v3.mq4 |//|                              Copyright © 2009-2024, www.QChaos.com |//|                                          https://www.qchaos.com/ |//+------------------------------------------------------------------+#define major   "2"#define minor   "a"#define indicatorName "TDI Alerts v3-" //"TDIvisual new"//----#property indicator_separate_window#property indicator_buffers 6#property indicator_color1 Gray#property indicator_color2 SkyBlue //MediumBlue#property indicator_color3 Yellow//#property indicator_width3 2#property indicator_color4 SkyBlue //MediumBlue#property indicator_color5 Green//#property indicator_width5 2#property indicator_color6 Red//#property indicator_color7 Aqua//#property indicator_style7 2
///////////////////////////////////////////////////////////////////////////////////////////|                                 外部可调参数(用户配置界面显示)                                 |/////////////////////////////////////////////////////////////////////////////////////////
//---- 指标核心参数组 ----extern string NoteIndic=" --- 指标选项 --- ";               // 参数分组标题extern int    RSI_Period          = 8;       // RSI计算周期(默认8,建议范围8-25)extern int    RSI_Price         = PRICE_MEDIAN; // RSI价格类型:0=收盘价,1=开盘价,2=最高价,3=最低价,4=中价(高+低)/2extern int    RSI_Price_Line_Shift= 0;       // RSI价格线位移(默认0,不偏移)extern int    Volatility_Band   = 23;      // 波动带计算周期(默认23,范围20-40)extern int    RSI_Price_Line      = 2;       // RSI价格线平滑周期(移动平均周期)extern int    RSI_Price_Type      = MODE_LWMA; // RSI价格线类型:0=SMA简单均线,1=EMA指数均线,2=SMMA平滑均线,3=LWMA线性加权
//---- 交易信号线参数组 ----extern int    Trade_Signal_Line   = 7;       // 主交易信号线周期(默认7)extern int    Trade_Signal_Line_Shift=0;   // 信号线位移(默认0)extern int    Trade_Signal_Type   = PRICE_CLOSE; // 信号线价格类型:0=收盘价,1=开盘价,2=最高价等extern int    Trade_Signal2_Line= 18;      // 第二交易信号线周期(默认18)extern int    Trade_Signal2_Line_Shift=0;    // 第二信号线位移extern int    Trade_Signal2_Type= PRICE_MEDIAN; // 第二信号线价格类型extern bool   SHOW_Trade_Signal2_Line=FALSE; // 是否显示第二信号线(默认关闭)
//---- 超买超卖参数组 ----extern string NoteLevels=" --- OB/OS Levels (32,68,20) --- "; // 水平线分组标题extern int    RSI_OversoldLevel   = 23;      // 超卖水平阈值(默认32)extern int    RSI_OverboughtLevel = 78;      // 超买水平阈值(默认68)extern int    VB_ConsolidationLevel=20;      // 波动带盘整阈值(带宽<20时视为盘整)
//---- 警报系统参数组 ----extern string NoteAlerts=" --- Alert Options --- "; // 警报分组标题extern bool   StrongBuySellAlerts = true;    // 启用强买卖信号警报(默认开启)extern bool   MediumWeakBuySellAlerts=true;// 启用中/弱信号警报(默认开启)extern bool   CautionAlerts       = true;    // 启用超买超卖警示(在指标窗口显示)extern int    AlertBar            = 1;       // 警报触发柱:0=当前柱,1=前一根K线等extern bool   SendTimeInfoAsTimeLocal=false; // 警报时间显示类型:true=本地时间,false=服务器时间extern string NoteAlerts1="*** ALERT METHODS ***:"; // 警报方式分组标题extern bool   PopupAlerts         = true;    // 启用弹窗警报(默认开启)extern bool   eMailAlerts         = false;   // 启用邮件警报(需配置MT4邮箱)extern bool   PushNotificationAlerts=false;// 启用推送通知(需移动端支持)extern bool   SoundAlerts         = false;   // 启用声音警报(默认关闭)extern string SoundAlertFileLong= "alert.wav";// 多头信号音效文件extern string SoundAlertFileShort = "alert2.wav"; // 空头信号音效文件extern string SoundAlertFileCautionAlert="news.wav"; // 警示信号音效文件string SoundAlertFile;                     // 内部使用的音效文件变量datetime MyTime;                           // 时间戳变量
//---- 可视化水平线参数组 ----extern string NoteLevel=" --- Visual Levels: ---"; // 可视化分组标题extern int Level2 = 50;                      // 中间水平线位置(默认50)
//---- 颜色配置参数组 ----extern string NoteColor=" --- Colors --- ";// 颜色分组标题extern colorBuyArrowColor      = Lime;   // 买入箭头颜色(莱姆绿)extern colorSellArrowColor   = Red;      // 卖出箭头颜色(纯红)extern colorStrongBuyArrowCautionColor=Chartreuse;// 强势买入警示色(亮黄绿)extern colorStrongSellArrowCautionColor=DeepPink;   // 强势卖出警示色(深粉红)
//---- 趋势信号颜色组 ----extern string NoteColor1=" --- TrendSignals --- ";extern colorWeakUpColor      = Green;    // 弱势上涨颜色(绿色)extern colorStrongUpColor      = Lime;   // 强势上涨颜色(亮绿色)extern colorWeakDownColor      = Orange;   // 弱势下跌颜色(橙色)extern colorStrongDownColor    = Red;      // 强势下跌颜色(红色)extern colorConsolidationColor = Silver;   // 盘整阶段颜色(银色)
//---- 趋势可视化颜色组 ----extern string NoteColor2=" --- TrendVisuals ---";extern colorStrongBuyColor   = Lime;   // 强买入信号颜色extern colorMediumBuyColor   = Green;    // 中等买入颜色extern colorWeakBuyColor       = SeaGreen; // 弱买入颜色(海绿色)extern colorStrongSellColor    = Red;      // 强卖出颜色extern colorMediumSellColor    = Tomato;   // 中等卖出颜色(番茄红)extern colorWeakSellColor      = Orange;   // 弱卖出颜色
//---- 通用显示参数组 ----extern string NoteGeneral=" --- General Options (true,true,0,0) --- ";extern bool   Show_TrendVisuals= true;   // 显示趋势可视化元素(默认开启)extern bool   Show_SignalArrows= true;   // 显示交易信号箭头(默认开启)extern int    SHIFT_Sideway      = -50;      // 横盘信号横向偏移量(像素)extern int    SHIFT_Up_Down      = -10;      // 涨跌信号纵向偏移量(像素)
//---- 字体设置参数组 ----extern string NoteFonts=" --- Font/Size (25,15,13,Tahoma Narrow) ---";extern int    TrendArrowFontSize = 15;       // 趋势箭头字体大小(默认15)extern int    TrendSignalsFontSize=10;       // 趋势信号文字大小(默认10)extern int    TrendPriceFontSize = 10;       // 价格标签字体大小(默认10)extern string TypeFace         = "Arial Black"; // 主要字体类型(默认Arial Black)
//////////////////////////////////////////////////////////////////|                      高级自定义设置                     |////////////////////////////////////////////////////////////////
//---- 随机指标替代组 ----extern string NoteIndiRsi=" --- misc: --- "; // 杂项分组标题extern string nirh="replace the RSI with:";// 功能描述标签extern bool   UseStochInsteadOfRsi=FALSE;    // 启用随机指标替代RSI(默认关闭)extern int    stochKPeriod       = 11;       // 随机指标%K周期(默认11)extern int    stochDPeriod       = 2;      // 随机指标%D周期(默认2)extern int    stochSlowing       = 2;      // 随机指标平滑系数(默认2)extern int    stochMethod      = MODE_LWMA;// 随机指标计算方法:0=SMA,3=LWMAextern int    stochPrice         = 1;      // 随机指标价格类型:0=高/低,1=收盘价
//---- 自定义交叉警报组 ----extern string NoteCustomAlert=" --- custom alert, nellycopter: --- ";extern string NoteCustomAlert1=" --- price cross tradesignal above/under marketbase line (optional ma-filter) --- ";extern bool RsiTradeSignalCrossAlerts=true;// 启用RSI/信号线交叉警报extern bool RsiTradeSignalCrossMaFilter=false; // 启用移动平均过滤extern int filterMaPeriod = 60;            // 过滤用MA周期(默认60)extern int filterMaShift= 0;               // MA位移(默认0)extern int filterMaMethod = MODE_EMA;      // MA类型:0=SMA,1=EMAextern int filterMaPrice= PRICE_CLOSE;   // MA价格类型:0=收盘价extern string CustomAlertSoundFileLong = "news.wav";// 自定义多头音效extern string CustomAlertSoundFileShort= "news.wav";// 自定义空头音效
//---- 界面控制按钮参数组 ----ENUM_BASE_CORNER btn_corner=CORNER_RIGHT_LOWER; // 按钮位置:右下角string btn_text    = "TDI1";          // 按钮显示文本string btn_Font    = "Arial";         // 按钮字体int    btn_FontSize= 8;               // 按钮文字大小colorbtn_text_ON_color=clrWhite;    // 启用状态文字颜色(白色)colorbtn_text_OFF_color=clrRed;   // 关闭状态文字颜色(红色)string btn_pressed = "TDI off";       // 按下时显示文本string btn_unpressed="TDI on";      // 弹起时显示文本colorbtn_background_color=clrDimGray;// 按钮背景色(暗灰)colorbtn_border_color=clrDarkGray;// 按钮边框色(深灰)int    button_x    = 70;            // 按钮X坐标(距右边缘70像素)int    button_y    = 20;            // 按钮Y坐标(距下边缘20像素)int    btn_Width   = 60;            // 按钮宽度(60像素)int    btn_Height= 20;            // 按钮高度(20像素)string soundBT   = "tick.wav";      // 按钮点击音效文件

bool                      show_data             = true;string IndicatorName, IndicatorObjPrefix,buttonId ;//end mod.string indicatorsName;///////////////////////////////////////////////////////////////////////----bool InitialLoad=True;string prefix="TDIV_";double RSIBuf[],UpZone[],MdZone[],DnZone[],MaBuf[],MbBuf[],McBuf[];string Signal="", Signal2="", Signal3="",Signal4="";color TDI_col,TDI_col2;int LastAlert=0, LastAlertBar,SigCounter=0;double BidCur;datetime TimeCur;//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+string GenerateIndicatorName(const string target){   string name = target;   int try         = 2;   while(WindowFind(name) != -1)   {      name = target + " #" + IntegerToString(try                                                ++);   }   return name;}//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+int init(){   /*    indicatorsName=indicatorName+major+minor+" (";    if (UseStochInsteadOfRsi) indicatorsName=indicatorsName+"STOCH)";      else indicatorsName=indicatorsName+"RSI)";    */   IndicatorShortName(indicatorName);//   SetIndexBuffer(0,RSIBuf); //Black/no color   SetIndexBuffer(1,UpZone); //SkyBlue, VB HIGH   SetIndexBuffer(2,MdZone); //Yellow,MARKET BASE LINE   SetIndexBuffer(3,DnZone); //SkyBlue, VB LOW   SetIndexBuffer(4,MaBuf);//Green,   RSI PRICE LINE   SetIndexBuffer(5,MbBuf);//Red,   TRADE SIGNAL LINE   SetIndexBuffer(6,McBuf);//Aqua,    TRADE SIGNAL2 LINE (has no function for signal generation)//----   if(SHOW_Trade_Signal2_Line == true)   {      SHOW_Trade_Signal2_Line = DRAW_LINE;   }   else   {      SHOW_Trade_Signal2_Line = DRAW_NONE;   }   SetIndexStyle(6,SHOW_Trade_Signal2_Line,0,2); // SetIndexStyle(6,SHOW_Trade_Signal2_Line);//SetIndexBuffer(6,McBuf);   SetIndexStyle(0,DRAW_NONE);   SetIndexStyle(1,DRAW_LINE);   SetIndexStyle(2,DRAW_LINE);   SetIndexStyle(3,DRAW_LINE);   SetIndexStyle(4,DRAW_LINE);   SetIndexStyle(5,DRAW_LINE);//----   SetIndexLabel(0,NULL);   SetIndexLabel(1,"VolatilityBand High");   SetIndexLabel(2,"Market Base Line");   SetIndexLabel(3,"VolatilityBand Low");
//   if(UseStochInsteadOfRsi)      SetIndexLabel(4,"STOCH Price Line");   else      SetIndexLabel(4,"RSI Price Line");//
   SetIndexLabel(5,"Trade Signal Line");   SetIndexLabel(6,"Trade Signal2 Line");//   /*   SetLevelValue(0,61.8);   SetLevelValue(1,50.0);   SetLevelValue(2,38.2);   SetLevelValue(3,23.6);   SetLevelStyle(STYLE_DOT,1,DimGray);   *///   LastAlertBar=Bars-1;//----   IndicatorName = GenerateIndicatorName(btn_text);   IndicatorObjPrefix = "__" + IndicatorName + "__";//IndicatorShortName(WindowExpertName());   IndicatorDigits(Digits);   double val;   if(GlobalVariableGet(IndicatorName + "_visibility", val))      show_data = val != 0;
   ChartSetInteger(ChartID(), CHART_EVENT_MOUSE_MOVE, 1);   buttonId = IndicatorObjPrefix+btn_text;   createButton(buttonId, btn_text, btn_Width, btn_Height, btn_Font, btn_FontSize, btn_background_color, btn_border_color, btn_text_ON_color);   ObjectSetInteger(ChartID(), buttonId, OBJPROP_YDISTANCE, button_y);   ObjectSetInteger(ChartID(), buttonId, OBJPROP_XDISTANCE, button_x);   return(0);}//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+void createButton(string buttonID,string buttonText,int width,int height,string font,int fontSize,color bgColor,color borderColor,color txtColor){//ObjectDelete    (ChartID(),buttonID);   ObjectCreate(ChartID(),buttonID,OBJ_BUTTON,WindowOnDropped(),0,0);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_COLOR,txtColor);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_BGCOLOR,bgColor);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_BORDER_COLOR,borderColor);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_XSIZE,width);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_YSIZE,height);   ObjectSetString(ChartID(),buttonID,OBJPROP_FONT,font);   ObjectSetString(ChartID(),buttonID,OBJPROP_TEXT,buttonText);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_FONTSIZE,fontSize);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_SELECTABLE,0);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_CORNER,btn_corner);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_HIDDEN,1);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_XDISTANCE,9999);   ObjectSetInteger(ChartID(),buttonID,OBJPROP_YDISTANCE,9999);}//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+int deinit(){   ObjectsDeleteAll(0,"TDI1");   ObjectsDeleteAll(ChartID(), IndicatorObjPrefix);
   int total=ObjectsTotal();   for(int i=total-1; i>=0; i--)   {      string name=ObjectName(i);      if(StringFind(name, prefix)==0)         ObjectDelete(name);   }//----   return(0);}

//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+bool recalc = true;void handleButtonClicks(){   if(ObjectGetInteger(ChartID(), buttonId, OBJPROP_STATE))   {      ObjectSetInteger(ChartID(), buttonId, OBJPROP_STATE, false);      show_data = !show_data;      GlobalVariableSet(IndicatorName + "_visibility", show_data ? 1.0 : 0.0);      recalc = true;      start();   }}//+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+void OnChartEvent(const int id,                  const long &lparam,                  const double &dparam,                  const string &sparam){   handleButtonClicks();   if(id==CHARTEVENT_OBJECT_CLICK && ObjectGet(sparam,OBJPROP_TYPE)==OBJ_BUTTON)   {      if(soundBT!="")         PlaySound(soundBT);   }}

lilihuan 发表于 2025-6-28 07:02:11

太复杂了,看不懂

weixi 发表于 2025-8-1 13:11:12

非常实用的系统
页: [1]
查看完整版本: 【TDI Alerts v3】趋势通道判断方向