指标名称:市场分布图
版本:MT4-MT5 ver. 1.3
市场分布图指标是经典的市场概况实现,能够展示价格随时间的密度,描绘出特定交易时段内的关键价格水平、价值区域和控制值。此指标适用于 M1 至 D1 的时间框架,能够显示每日、每周、每月或甚至是日内交易的市场分布图。较低的时间框架提供更高的精度,而较高的时间框架则适合更好的可视化。此外,可以使用自由绘制的矩形会话,在任何时间框架上创建自定义市场分布图。提供六种不同的配色方案来绘制图表的区块,也可以将图表绘制为单色直方图,或根据看涨/看跌的蜡烛颜色来着色。此指标基于纯价格行为,不使用任何标准指标。
适用于 MetaTrader 4、MetaTrader 5。
警报系统可用于检测价格穿越价值区域高低、均值和单一打印区域的情况。
主要参数
- – Session (默认 = 每日):选择市场分布图的交易时段:每日、每周、每月、日内和矩形。如果要计算矩形会话,需在图表上添加以“MPR”开头命名的矩形对象。按“r”键可以自动添加一个正确命名的矩形对象。
- – StartFromDate (默认 = __DATE__):如果
StartFromCurrentSession
为假,指标将从该日期开始绘制图表,向过去绘制。例如,如果设置为2018-01-20,且SessionsToCount
为2,则会绘制2018-01-20和2018-01-19的图表。 - – StartFromCurrentSession (默认 = true):如果为真,则指标从今天开始绘制,否则从
StartFromDate
中给定的日期开始。 - – SessionsToCount (默认 = 2):要绘制多少个交易时段的市场分布图。
- – SeamlessScrollingMode (默认 = false):如果为真,
StartFromDate
和StartFromCurrentSession
参数将被忽略;从当前图表位置的最右侧条开始计算并显示会话。这允许无限回滚查看过去的会话。 - – EnableDevelopingPOC (默认 = false):如果为真,将绘制多条水平线以显示控制点在会话中的发展情况。
- – EnableDevelopingVAHVAL (默认 = false):如果为真,将绘制多条水平线以显示价值区域高低的变化。
- – ValueAreaPercentage (默认 = 70):会话 TPOs 中包含在价值区域的百分比。
外观与颜色
- – ColorScheme (默认 = 蓝到红):配置图表区块的配色方案:
- 蓝到红- 红到绿- 绿到蓝- 黄到青- 品红到黄- 青到品红
- – SingleColor (默认 = clrBlue):如果
ColorScheme
设置为单色,则此颜色将用于绘制市场分布图。 - – ColorBullBear (默认 = false):如果为真,区块的颜色将根据蜡烛的方向而非生成蜡烛的时间来决定。
- – MedianColor (默认 = clrWhite):控制值(均值)的颜色。
- – ValueAreaSidesColor (默认 = clrWhite):价值区域侧边框的颜色。
- – ValueAreaHighLowColor (默认 = clrWhite):价值区域上下边框的颜色。
性能参数
- – PointMultiplier (默认 = 0):值越高,图表的价格框越宽,图表对象越少,可以用来降低指标对 CPU 的负担。值为零时使用自适应乘数,指标会自动计算最佳值。
- – ThrottleRedraw (默认 = 0):在每次重新绘制图表前应用的延迟,单位为秒。可以用来减少指标对 CPU 的负担。
- – DisableHistogram (默认 = false):如果为真,则不会绘制市场分布图直方图,但价值区域和均值仍会被标记。这样会使指标运行得非常快速,但对于深入市场分析的帮助较少。
警报设置
- – AlertNative (默认 = false):如果为真,指标在满足某些警报条件时将发出平台的本地弹出警报。
- – AlertEmail (默认 = false):如果为真,当满足某些警报条件时,将发送 MetaTrader 的电子邮件警报。电子邮件需在 MetaTrader 中通过“工具”->“选项”->“电子邮件”进行正确配置。
- – AlertPush (默认 = false):如果为真,当满足某些警报条件时,MetaTrader 将向你的移动设备发送推送通知。通知需在 MetaTrader 中通过“工具”->“选项”->“通知”进行正确配置。此类型的警报在 cTrader 版本中不可用。
- – AlertForValueArea (默认 = false):如果为真,价格穿越价值区域的高低线时将发出警报。
- – AlertForMedian (默认 = false):如果为真,价格穿越均值线时将发出警报。
日内会话
- – EnableIntradaySessionN (默认 = true):如果为真,且
Session
设置为日内,则指标将在图表上绘制日内市场分布图 N。 - – IntradaySessionNStartTime (默认 = “HH:MM”):日内会话 N 的开始时间,格式为 HH:MM。
- – IntradaySessionNEndTime (默认 = “HH:MM”):日内会话 N 的结束时间,格式为 HH:MM。
其他设置
- – SaturdaySunday (默认 = 正常会话):如何处理周六和周日的会话:
- – 正常会话:将周六和周日视为正常会话。
- – 忽略周六和周日:忽略周六和周日的蜡烛图。
- – 附加周六和周日:将周六的蜡烛图附加到周五会话,将周日的蜡烛图附加到周一会话。
这些参数和设置使得该指标具有灵活性和强大的功能,帮助交易者更好地分析市场动态。
- – SingleColor (默认 = clrBlue):如果
警报系统可用于检测价格穿越价值区域高低、均值和单一打印区域的情况。
这个指标还有另外的两个版本,这个会在接下来发布出来,欢迎持续关注!
部分代码展示:
//+——————————————————————+
//| 市场分布图.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 "1.3"
property strict
property description "———————————————"
property description "EA、指标公式分享"
property description "EA、指标编写业务承接"
property description "———————————————"
property description "更多资源,关注公众号:量化程序"
property description "微 信:QChaos001"
property description "手机号:134-8068-5281"
property description "———————————————"
property description "显示市场概况指标,用于日内、日线、周线或月线交易时段。"
property description "日线 – 应附加到M5-M30时间框架。推荐使用M30。"
property description "周线 – 应附加到M30-H4时间框架。推荐使用H1。"
property description "周的开始时间为星期日。"
property description "月线 – 应附加到H1-D1时间框架。推荐使用H4。"
property description "日内 – 应附加到M1-M15时间框架。推荐使用M5。"
property description "设计用于主要货币对,但也应适用于外汇、差价合约或商品。"
//+——————————————————————+
// Rectangle session – a rectangle’s name should start with ‘MPR’ and must not contain an underscore (‘_’).
//+——————————————————————+
property indicator_chart_window
// Two buffers are used for the Developing POC and Developing VAH/VAL display because a single buffer wouldn’t support an interrupting line.
property indicator_plots 6
property indicator_buffers 6
property indicator_color1 clrGreen
property indicator_color2 clrGreen
property indicator_width1 5
property indicator_width2 5
property indicator_type1 DRAW_LINE
property indicator_type2 DRAW_LINE
property indicator_style1 STYLE_SOLID
property indicator_style2 STYLE_SOLID
property indicator_label1 "Developing POC"
property indicator_label2 "Developing POC"
property indicator_color3 clrGoldenrod
property indicator_color4 clrGoldenrod
property indicator_width3 5
property indicator_width4 5
property indicator_type3 DRAW_LINE
property indicator_type4 DRAW_LINE
property indicator_style3 STYLE_SOLID
property indicator_style4 STYLE_SOLID
property indicator_label3 "Developing VAH"
property indicator_label4 "Developing VAH"
property indicator_color5 clrSalmon
property indicator_color6 clrSalmon
property indicator_width5 5
property indicator_width6 5
property indicator_type5 DRAW_LINE
property indicator_type6 DRAW_LINE
property indicator_style5 STYLE_SOLID
property indicator_style6 STYLE_SOLID
property indicator_label5 "Developing VAL"
property indicator_label6 "Developing VAL"
enum color_scheme
{
Blue_to_Red, // Blue to Red
Red_to_Green, // Red to Green
Green_to_Blue, // Green to Blue
Yellow_to_Cyan, // Yellow to Cyan
Magenta_to_Yellow, // Magenta to Yellow
Cyan_to_Magenta, // Cyan to Magenta
Single_Color // Single Color
};
enum session_period
{
Daily,
Weekly,
Monthly,
Intraday,
Rectangle
};
enum sat_sun_solution
{
Saturday_Sunday_Normal_Days, // Normal sessions
Ignore_Saturday_Sunday, // Ignore Saturday and Sunday
Append_Saturday_Sunday // Append Saturday and Sunday
};
enum sessions_to_draw_rays
{
None,
Previous,
Current,
PreviousCurrent, // Previous & Current
AllPrevious, // All Previous
All
};
enum ways_to_stop_rays
{
Stop_No_Rays, // Stop no rays
Stop_All_Rays, // Stop all rays
Stop_All_Rays_Except_Prev_Session, // Stop all rays except previous session
Stop_Only_Previous_Session, // Stop only previous session’s rays
};
// Only for dot coloring choice in PutDot() when ColorBullBear == true.
enum bar_direction
{
Bullish,
Bearish,
Neutral
};
enum single_print_type
{
No,
Leftside,
Rightside
};
enum alert_check_bar
{
CheckCurrentBar, // Current
CheckPreviousBar // Previous
};
enum alert_types // Required to type a parameter of DoAlerts().
{
PriceBreak, // Price Break
CandleCloseCrossover, // Candle Close Crossover
GapCrossover // Gap Crossover
};
input group "Main"
input string __Main = "================";
input session_period Session = Daily;
input datetime StartFromDate = DATE__; // StartFromDate: lower priority.
input bool StartFromCurrentSession = true; // StartFromCurrentSession: higher priority.
input int SessionsToCount = 2; // SessionsToCount: Number of sessions to count Market Profile.
input bool SeamlessScrollingMode = false; // SeamlessScrollingMode: Show sessions on current screen.
input bool EnableDevelopingPOC = false; // Enable Developing POC
input bool EnableDevelopingVAHVAL = false; // Enable Developing VAH/VAL
input int ValueAreaPercentage = 70; // ValueAreaPercentage: Percentage of TPO’s inside Value Area.
input group "Colors and looks"
input string ____Colors_and_looks = "================";
input color_scheme ColorScheme = Blue_to_Red;
input color SingleColor = clrBlue; // SingleColor: if ColorScheme is set to Single Color.
input bool ColorBullBear = false; // ColorBullBear: If true, colors are from bars’ direction.
input color MedianColor = clrWhite;
input color ValueAreaSidesColor = clrWhite;
input color ValueAreaHighLowColor = clrWhite;
input ENUM_LINE_STYLE MedianStyle = STYLE_SOLID;
input ENUM_LINE_STYLE MedianRayStyle = STYLE_DASH;
input ENUM_LINE_STYLE ValueAreaSidesStyle = STYLE_SOLID;
input ENUM_LINE_STYLE ValueAreaHighLowStyle = STYLE_SOLID;
input ENUM_LINE_STYLE ValueAreaRayHighLowStyle= STYLE_DOT;
input int MedianWidth = 1;
input int MedianRayWidth = 1;
input int ValueAreaSidesWidth = 1;
input int ValueAreaHighLowWidth = 1;
input int ValueAreaRayHighLowWidth = 1;
input sessions_to_draw_rays ShowValueAreaRays = None; // ShowValueAreaRays: draw previous value area high/low rays.
input sessions_to_draw_rays ShowMedianRays = None; // ShowMedianRays: draw previous median rays.
input ways_to_stop_rays RaysUntilIntersection = Stop_No_Rays; // RaysUntilIntersection: which rays stop when hit another MP.
input bool HideRaysFromInvisibleSessions = false; // HideRaysFromInvisibleSessions: hide rays from behind the screen.
input int TimeShiftMinutes = 0; // TimeShiftMinutes: shift session + to the left, – to the right.
input bool ShowKeyValues = true; // ShowKeyValues: print out VAH, VAL, POC on chart.
input color KeyValuesColor = clrWhite; // KeyValuesColor: color for VAH, VAL, POC printout.
input int KeyValuesSize = 8; // KeyValuesSize: font size for VAH, VAL, POC printout.
input single_print_type ShowSinglePrint = No; // ShowSinglePrint: mark Single Print profile levels.
input color SinglePrintColor = clrGold;
input bool SinglePrintRays = false; // SinglePrintRays: mark Single Print edges with rays.
input ENUM_LINE_STYLE SinglePrintRayStyle = STYLE_SOLID;
input int SinglePrintRayWidth = 1;
input color ProminentMedianColor = clrYellow;
input ENUM_LINE_STYLE ProminentMedianStyle = STYLE_SOLID;
input int ProminentMedianWidth = 4;
input bool RightToLeft = false; // RightToLeft: Draw histogram from right to left.
input group "Performance"
input string ____Performance = "================";
input int PointMultiplier = 0; // PointMultiplier: higher value = fewer objects. 0 – adaptive.
input int ThrottleRedraw = 0; // ThrottleRedraw: delay (in seconds) for updating Market Profile.
input bool DisableHistogram = false; // DisableHistogram: do not draw profile, VAH, VAL, and POC still visible.
input group "Alerts"
input string ____Alerts = "================";
input bool AlertNative = false; // AlertNative: issue native pop-up alerts.
input bool AlertEmail = false; // AlertEmail: issue email alerts.
input bool AlertPush = false; // AlertPush: issue push-notification alerts.
input bool AlertArrows = false; // AlertArrows: draw chart arrows on alerts.
input alert_check_bar AlertCheckBar = CheckPreviousBar;// AlertCheckBar: which bar to check for alerts?
input bool AlertForValueArea = false; // AlertForValueArea: alerts for Value Area (VAH, VAL) rays.
input bool AlertForMedian = false; // AlertForMedian: alerts for POC (Median) rays’ crossing.
input bool AlertForSinglePrint = false; // AlertForSinglePrint: alerts for single print rays’ crossing.
input bool AlertOnPriceBreak = false; // AlertOnPriceBreak: price breaking above/below the ray.
input bool AlertOnCandleClose = false; // AlertOnCandleClose: candle closing above/below the ray.
input bool AlertOnGapCross = false; // AlertOnGapCross: bar gap above/below the ray.
input int AlertArrowCodePB = 108; // AlertArrowCodePB: arrow code for price break alerts.
input int AlertArrowCodeCC = 110; // AlertArrowCodeCC: arrow code for candle close alerts.
input int AlertArrowCodeGC = 117; // AlertArrowCodeGC: arrow code for gap crossover alerts.
input color AlertArrowColorPB = clrRed; // AlertArrowColorPB: arrow color for price break alerts.
input color AlertArrowColorCC = clrBlue; // AlertArrowColorCC: arrow color for candle close alerts.
input color AlertArrowColorGC = clrYellow; // AlertArrowColorGC: arrow color for gap crossover alerts.
input int AlertArrowWidthPB = 1; // AlertArrowWidthPB: arrow width for price break alerts.
input int AlertArrowWidthCC = 1; // AlertArrowWidthCC: arrow width for candle close alerts.
input int AlertArrowWidthGC = 1; // AlertArrowWidthGC: arrow width for gap crossover alerts.