设为首页 收藏本站 切换语言
| 发表于 2025-6-27 21:16:56 | 显示全部楼层 |复制链接
指标名称:时段箱体突破[color=rgba(0, 0, 0, 0.9)]
版本:MT4  ver. 2.01

[size=16.002px]时段箱体突破是一款用于MT4平台的交易辅助工具,通过识别特定时间窗口内的价格波动区间(箱体),自动计算突破后的潜在入场点、止损位及多级止盈目标。该指标适用于外汇、商品等市场的短线突破策略,帮助交易者快速识别关键价位。
image.jpg 一、指标原理
  • 时间窗口设定
    指标在用户指定的GMT时间范围内(如06:00-09:30)统计最高价与最低价,形成“价格箱体”。
  • 箱体动态调整

    • 若箱体幅度超出预设范围,可自动限制最大尺寸或吸附到最近的极值点。
    • 突破信号基于箱体边界外的入场偏移计算。

  • 多级目标与止损
    根据箱体幅度按比例生成止损位(SL)及5个止盈目标(TP1-TP5),支持固定点数或动态比例两种模式。



二、使用指南1. 关键功能解读
  • 箱体显示

    • 蓝色:有效箱体(幅度在Min-Max之间)。
    • 红色:箱体过小(需谨慎交易)。
    • 橙色:箱体超限(被限制到Max值)。

  • 突破信号

    • 买入信号:价格上破箱顶+EntryFactor(入场偏移系数)偏移位(蓝色虚线)。
    • 卖出信号:价格下破箱底-EntryFactor(入场偏移系数)偏移位(红色虚线)。

  • 辅助线

    • 灰色虚线:止损位(SL)及各级止盈(TP1-TP5)。
    • 青色区域:突破后的预期盈利区间。

2. 交易策略建议
  • 入场条件
    价格收盘突破Entry线后入场,止损设于SL线。
  • 止盈管理

    • 保守:TP1(1倍风险回报)。
    • 激进:分批平仓至TP3或TP5。

  • 过滤规则

    • 避免交易红色警告箱体。
    • 超限箱体(橙色)仅当趋势强劲时考虑。


[size=16.002px]示例:欧元/美元 15分钟图设置

StartTime_GMT = "07:00";      // 对应本地时间10:00(GMT+3)EndTime_GMT = "10:00";        // 对应本地时间13:00MinBoxSizeInPips = 10;        // 最小10点波动才有效TP3Factor = 2.5;              // 第三止盈目标为箱体高度的2.5倍
效果:识别上午10-13点的价格箱体,当突破时提供3个止盈目标
参数:
image.jpg
部分代码展示:

  1. //+------------------------------------------------------------------+//|                                                    时段箱体突破.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 strict#property indicator_chart_window#define VERSION "时段箱体突破V_2.01"
  2. //---- 输入参数(用户可配置)-----------------------------------------extern string Info                                 = VERSION;        // 版本信息extern string StartTime_GMT                        = "06:00";       // GMT时区箱体开始时间extern string EndTime_GMT                          = "09:30";       // GMT时区箱体结束时间extern string note1          = "-----定义突破时段----------";         // 时段说明1extern string note2          = "-----1,2,3=9点,4=10点,5=11点,6=伦敦时段--"; // 时段说明2extern string note3          = "-----1-2-3-4-5-6=亚洲时段----------";     // 时段说明3extern string adjust_GMT_time_offset_brocker_time  = " 时区偏移(正数或负数)";extern int    adjust_GMT_time_offset__brocker_time = 3;             // 经纪商时间与GMT时差(小时)color  SessionColor                                = clrLinen;     // 时段背景颜色extern int    NumDays                              = 2;            // 回溯天数extern int    MinBoxSizeInPips                     = 5;            // 最小交易箱体点数extern int    MaxBoxSizeInPips                     = 300;          // 最大交易箱体点数extern bool   LimitBoxToMaxSize                    = false;        // 是否限制最大箱体尺寸extern bool   StickBoxToLatestExtreme              = false;        // 是否吸附到最新极值extern bool   StickBoxOusideSRlevels               = false;        // 是否吸附到支撑阻力外extern double EntryFactor                          = 0.15;         // 入场偏移系数
  3. //---- 止盈参数 ----extern double TP1Factor                                  = 1.000;        // TP1系数extern double TP2Factor;                                                 // TP2系数(TP1和TP3中间值)extern double TP3Factor                                  = 3.0;          // TP3系数extern double TP4Factor;                                                 // TP4系数(TP3和TP5中间值)extern double TP5Factor                                  = 5.0;          // TP5系数(0=禁用TP4/TP5)extern string TP2_help                                   = "TP2是TP1和TP3中间值";extern string TP4_help                                   = "TP4是TP3和TP5中间值";
  4. //---- 止损参数 ----extern double SLFactor                             = 0.65;         // 止损系数extern double LevelsResizeFactor                         = 1.0;          // 级别缩放系数
  5. //---- 图形颜色设置 ----extern color  BoxColorOK                           = clrLightBlue; // 有效箱体颜色extern color  BoxColorNOK                          = clrRed;       // 无效箱体颜色extern color  BoxColorMAX                          = clrOrange;    // 超限箱体颜色extern color  LevelColor                           = clrDarkGray;  // 水平线颜色extern bool   showProfitZone                       = true;         // 显示盈利区域extern color  ProfitColor                          = clrMediumTurquoise;// 盈利区域颜色
  6. //---- 图形对象设置 ----string objPrefix                            = "LB1-";       // 对象名前缀string button_note1          = "------------------------------";ENUM_BASE_CORNER   btn_corner            = CORNER_LEFT_UPPER; // 按钮位置string btn_text              = "QC";         // 按钮文字string btn_Font              = "Arial";       // 按钮字体int    btn_FontSize          = 7;             // 按钮字号color  btn_text_color        = clrDarkGray;   // 按钮文字颜色color  btn_background_color  = clrWhite;      // 按钮背景色color  btn_border_color      = clrBlack;      // 按钮边框色int    button_x              = 600;           // 按钮X坐标int    button_y              = 12;            // 按钮Y坐标int    btn_Width             = 20;            // 按钮宽度int    btn_Height            = 10;            // 按钮高度
  7. //---- 全局变量 ----bool   show_data             = true;                 // 是否显示数据string IndicatorName, IndicatorObjPrefix;            // 指标名称和前缀double pip;                                          // 点值int    digits, BarsBack;                             // 品种精度,回溯柱数
  8. //---- 交易级别变量 ----double BuyEntry,BuyTP1,BuyTP2,BuyTP3,BuyTP4,BuyTP5,BuySL;  // 多单各级别double SellEntry,SellTP1,SellTP2,SellTP3,SellTP4,SellTP5,SellSL; // 空单各级别int    SL_pips,TP1_pips,TP2_pips,TP3_pips,TP4_pips,TP5_pips;    // 点数形式参数double TP1FactorInput,TP2FactorInput,TP3FactorInput,TP4FactorInput,TP5FactorInput,SLFactorInput; // 输入参数备份//---- 箱体相关变量 ----datetime tBoxStart,tBoxEnd;                          // 箱体起止时间datetime tSessionStart,tSessionEnd;                  // 交易时段起止datetime tLastComputedSessionStart,tLastComputedSessionEnd; // 最后计算时段double boxHigh,boxLow,boxExtent,boxMedianPrice;      // 箱体最高价、最低价、幅度、中值
  9. //---- 辅助变量 ----int StartShift,EndShift;                 // 时段位移量datetime alreadyDrawn;                   // 已绘制标记
  10. //+------------------------------------------------------------------+string GenerateIndicatorName(const string target) //don't change anything here          //no cambies nada aqui  {   string name = target;   int try         = 2;   while(WindowFind(name) != -1)     {      name = target + " #" + IntegerToString(try                                                ++);     }   return name;  }//+------------------------------------------------------------------+string buttonId;
  11. //+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+int init()  {   IndicatorName = GenerateIndicatorName(btn_text);   IndicatorObjPrefix = "__" + IndicatorName + "__";   IndicatorShortName(IndicatorName);   IndicatorDigits(Digits);
  12.    double val;   if(GlobalVariableGet(IndicatorName + "_visibility", val))      show_data = val != 0;
  13. // put init() here   RemoveObjects(objPrefix);   getpip();
  14.    BarsBack = NumDays*(PERIOD_D1/Period());   alreadyDrawn = 0;
  15. //save input Factors;   TP1FactorInput = TP1Factor;   TP3FactorInput = TP3Factor;   TP5FactorInput = TP5Factor;   SLFactorInput  = SLFactor;
  16.    TP2Factor = (TP1Factor+TP3Factor)/2;   TP4Factor = (TP3Factor+TP5Factor)/2;
  17. // StickBoxOusideSRlevels mode requires LimitBoxToMaxSize and StickBoxToLatestExtreme options true   if(StickBoxOusideSRlevels==true)     {      LimitBoxToMaxSize = true;      StickBoxToLatestExtreme = true;     }
  18.    ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, 1);   buttonId = IndicatorObjPrefix + "CloseButton";   createButton(buttonId, btn_text, btn_Width, btn_Height, btn_Font, btn_FontSize, btn_background_color, btn_border_color, btn_text_color);   ObjectSetInteger(0, buttonId, OBJPROP_YDISTANCE, button_y);   ObjectSetInteger(0, buttonId, OBJPROP_XDISTANCE, button_x);
  19.    return 0;  }//+------------------------------------------------------------------+//don't change anything herevoid createButton(string buttonID,string buttonText,int width,int height,string font,int fontSize,color bgColor,color borderColor,color txtColor)  {   ObjectDelete(0,buttonID);   ObjectCreate(0,buttonID,OBJ_BUTTON,0,0,0);   ObjectSetInteger(0,buttonID,OBJPROP_COLOR,txtColor);   ObjectSetInteger(0,buttonID,OBJPROP_BGCOLOR,bgColor);   ObjectSetInteger(0,buttonID,OBJPROP_BORDER_COLOR,borderColor);   ObjectSetInteger(0,buttonID,OBJPROP_BORDER_TYPE,BORDER_RAISED);   ObjectSetInteger(0,buttonID,OBJPROP_XSIZE,width);   ObjectSetInteger(0,buttonID,OBJPROP_YSIZE,height);   ObjectSetString(0,buttonID,OBJPROP_FONT,font);   ObjectSetString(0,buttonID,OBJPROP_TEXT,buttonText);   ObjectSetInteger(0,buttonID,OBJPROP_FONTSIZE,fontSize);   ObjectSetInteger(0,buttonID,OBJPROP_SELECTABLE,0);   ObjectSetInteger(0,buttonID,OBJPROP_CORNER,btn_corner);   ObjectSetInteger(0,buttonID,OBJPROP_HIDDEN,1);   ObjectSetInteger(0,buttonID,OBJPROP_XDISTANCE,9999);   ObjectSetInteger(0,buttonID,OBJPROP_YDISTANCE,9999);  }//+------------------------------------------------------------------+int deinit()  {   ObjectsDeleteAll(ChartID(), IndicatorObjPrefix);
  20. //put deinit() here   RemoveObjects(objPrefix);
  21.    return 0;  }//+------------------------------------------------------------------+//don't change anything herebool recalc = true;
  22. //+------------------------------------------------------------------+//|                                                                  |//+------------------------------------------------------------------+void handleButtonClicks()  {   if(ObjectGetInteger(0, buttonId, OBJPROP_STATE))     {      ObjectSetInteger(0, 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, //don't change anything here                  const long &lparam,                  const double &dparam,                  const string &sparam)  {   handleButtonClicks();  }//+------------------------------------------------------------------+int start2()  {   handleButtonClicks();   recalc = false;   int i, limit, counted_bars=IndicatorCounted();
  23.    limit = MathMin(BarsBack,Bars);
  24.    for(i=limit; i>=0; i--)     {      new_tick(i);     } // limit loop   return 0;  }//+------------------------------------------------------------------+int start()  {   handleButtonClicks();   recalc = false;   int i, limit, counted_bars=IndicatorCounted();
  25.    limit = MathMin(BarsBack,Bars-counted_bars-1);
  26.    for(i=limit; i>=0; i--)     {      new_tick(i);     } // limit loop
  27.    if(show_data)     {      start2();     }   else     {      RemoveObjects(objPrefix);     }   return 0;  }//+------------------------------------------------------------------+void new_tick(int i) // i = bar number: 0=current(last) bar//+------------------------------------------------------------------+  {   datetime now = Time;
  28. //determine box and session times   if(TimeDayOfWeek(now) == 1 || TimeDayOfWeek(now) == 2 || TimeDayOfWeek(now) == 3 || TimeDayOfWeek(now) == 4 || TimeDayOfWeek(now) == 5) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////::     {
  29.       // compute LEVELS values:      compute_LB_Indi_LEVELS(now);
  30.       show_boxes(now);     }
  31.   }//new_tick()
复制代码

时段箱体突破.ex4

37.04 KB, 下载次数: 3, 下载积分: 活跃度 -5 售价: 1 H币  [记录]  [下载]

评分
  • 1
  • 2
  • 3
  • 4
  • 5
平均分:NAN    参与人数:0    我的评分:未评 下载时遇到问题?
如果有帮助,就支持一下我呗
举报

评论 使用道具

精彩评论14

tbh1314
DDD
| 发表于 2025-6-27 23:12:47 | 显示全部楼层
路过看看加收藏
举报

点赞 评论 使用道具

qtxh1008
DD
| 发表于 2025-6-28 00:16:39 来自手机 | 显示全部楼层
收藏收藏
举报

点赞 评论 使用道具

jxj600
DD
| 发表于 2025-6-28 04:36:10 | 显示全部楼层
可以可以的
举报

点赞 评论 使用道具

崽崽0626
D
| 发表于 2025-6-28 05:38:36 | 显示全部楼层
若箱体幅度超出预设范围,可自动限制最大尺寸或吸附到最近的极值点?
举报

点赞 评论 使用道具

1594135666
DDD
| 发表于 2025-6-28 06:06:46 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

123654789
D
| 发表于 2025-6-28 06:57:07 来自手机 | 显示全部楼层
怎么用的
举报

点赞 评论 使用道具

lilihuan
C
| 发表于 2025-6-28 07:00:38 | 显示全部楼层
我喜欢箱体突破
举报

点赞 评论 使用道具

湘聚缘
DD
| 发表于 2025-6-28 09:26:38 | 显示全部楼层
使用情况如何
举报

点赞 评论 使用道具

sjwlyl
D
| 发表于 2025-6-28 11:57:49 | 显示全部楼层
看上去不怎么样
举报

点赞 评论 使用道具

jj644719356
DDD
| 发表于 2025-6-29 10:53:00 | 显示全部楼层
箱体突破是一款用于MT4平台的交易辅助工具
举报

点赞 评论 使用道具

dayu1362007
D
| 发表于 2025-7-1 20:45:46 | 显示全部楼层
路过看看加收藏使用情况如何
举报

点赞 评论 使用道具

minggege
DD
| 发表于 2025-7-3 00:24:28 | 显示全部楼层
还可以,只是盈亏比小了点
举报

点赞 评论 使用道具

btenns
DDD
| 发表于 2025-7-4 22:48:10 | 显示全部楼层
根本加载不了
举报

点赞 评论 使用道具

dayu1362007
D
| 发表于 2025-7-4 22:52:15 | 显示全部楼层
路过看看加收藏只是盈亏比小了点
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册

简体中文
繁體中文
English(英语)
日本語(日语)
Deutsch(德语)
Русский язык(俄语)
بالعربية(阿拉伯语)
Türkçe(土耳其语)
Português(葡萄牙语)
ภาษาไทย(泰国语)
한어(朝鲜语/韩语)
Français(法语)