“K线剩余时间”,显示当前K线已用和剩余时间 +品种信息面板 MT4免费工具!

指标名称:K线剩余时间

版本:MT4 ver. 2.01(指标)

K线剩余时间该指标提供了当前K线剩余时间统计,以及其他市场的详细信息视图,显示当前交易品种的基本交易状态、合约规格、价格信息等。通过在图表上创建面板,用户可以方便地查看实时的市场数据,例如买卖价格、点差、合约大小等,还包括每根K线的开始时间和剩余时间等信息。

功能:

  • 市场交易状态:显示当前市场的交易模式(例如是否只允许买入、卖出、仅平仓等)。

  • 合约信息:包括合约大小、最小/最大交易量、点值、止损限制等。

  • 价格信息:显示当前的买入价格、卖出价格、点差、Tick大小及Tick值。

  • 时间信息:显示当前K线的已过时间与剩余时间,帮助交易者更好地把握市场节奏。

参数:

部分代码展示:

//+------------------------------------------------------------------+
//|                                                       K线剩余时间.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 description "---------------------------------------------"
#property description "EA、指标公式分享"
#property description "EA、指标编写业务承接"
#property description "---------------------------------------------"

#property description "---------------------------------------------"
#property description   "显示关于交易品种的详细信息、上根蜡烛的时间间隔,以及到下一根蜡烛的倒计时。"
#property description   "提供警报选项。"
#property indicator_chart_window

#include <MQLTA Utils.mqh>

enum ENUM_PANEL_SIZE
{
    PANEL_SIZE_SMALL = 1,  // 小尺寸面板
    PANEL_SIZE_MEDIUM = 2, // 中等尺寸面板
    PANEL_SIZE_LARGE = 3   // 大尺寸面板
};

enum ENUM_DEFAULT_OPEN
{
    NOTHING = 0, // 无操作
    DETAILS = 1, // 显示详细信息
    CURRENT = 2  // 显示当前信息
};

enum ENUM_DISPLAY_MODE
{
    MINIMAL = 0, // 仅显示倒计时
    FULL = 1     // 完整界面
};

enum ENUM_TIMEFORMAT
{
    HMS = 0,   // 时:分:秒
    COLON = 1, // 时:分:秒 格式 (HH:MM:SS)
};

input string Comment_1 = "====================";    // 蜡烛计时器设置
input string IndicatorName = "品种信息显示";             // 指标名称(用于绘制对象)
input ENUM_DISPLAY_MODE DefaultDisplay = FULL;   // 默认界面显示方式
input ENUM_DEFAULT_OPEN DefaultOpen = CURRENT;      // 默认打开的窗口
input ENUM_TIMEFORMAT TimeFormat = HMS;             // 时间格式
input string Comment_2 = "====================";    // 通知选项
input bool EnableNotify = false;                    // 启用通知功能
input int SecondsNotice = 60;                       // 提前通知的秒数
input bool SendAlert = true;                        // 是否发送警报通知
input bool SendApp = false;                         // 是否发送手机通知
input bool SendEmail = false;                       // 是否通过电子邮件发送通知
input string Comment_3 = "====================";    // 面板位置设置
input ENUM_BASE_CORNER Corner = CORNER_LEFT_UPPER;  // 面板在图表上的位置(左上角)
input int Xoff = 20;                                // 面板的水平偏移量
input int Yoff = 20;                                // 面板的垂直偏移量
input int FontSize = 8;                             // 字体大小
input ENUM_PANEL_SIZE PanelSize = PANEL_SIZE_SMALL; // 面板大小
input string Comment_4 = "====================";    // 面板颜色设置
input color LargeFontColor = clrNavy;               // 大字体颜色
input color SmallFontColor = clrBlack;              // 小字体颜色
input color CaptionBGColor = clrKhaki;              // 标题背景颜色
input color EditsBGColor = clrWhiteSmoke;           // 编辑框背景颜色
input color BorderColor = clrBlack;                 // 边框颜色
input color BorderFillColor = clrWhite;             // 边框填充颜色


int CornerSignX = 1;
int CornerSignY = 1;

string HoursString = "";
string MinutesString = "";
string SecondsString = "";

string Font = "Consolas";

bool DetailsOpen = false;
bool CurrentOpen = false;
bool NotifiedThisCandle = false;

double DPIScale; // Scaling parameter for the panel based on the screen DPI.
int PanelMovX, PanelMovY, PanelLabX, PanelLabY, PanelRecX;
int DetGLabelX, DetGLabelEX, DetGLabelY, DetButtonX, DetButtonY;
int CurGLabelX, CurGLabelEX, CurGLabelY, CurButtonX, CurButtonY;

int OnInit()
{
    IndicatorSetString(INDICATOR_SHORTNAME, IndicatorName);
    
    CleanChart();
    
    if (Corner == CORNER_LEFT_UPPER)
    {
        CornerSignX = 1;
        CornerSignY = 1;
    }
    else if (Corner == CORNER_LEFT_LOWER)
    {
        CornerSignX = 1;
        CornerSignY = -1;
    }
    else if (Corner == CORNER_RIGHT_UPPER)
    {
        CornerSignX = -1;
        CornerSignY = 1;
    }
    else if (Corner == CORNER_RIGHT_LOWER)
    {
        CornerSignX = -1;
        CornerSignY = -1;
    }

    DPIScale = (double)TerminalInfoInteger(TERMINAL_SCREEN_DPI) / 96.0;

    PanelMovX = (int)MathRound(26 * DPIScale * PanelSize);
    PanelMovY = (int)MathRound(26 * DPIScale * PanelSize);
    PanelLabX = (int)MathRound(120 * DPIScale * PanelSize);
    PanelLabY = PanelMovY;
    PanelRecX = (PanelMovX + 2) * 2 + PanelLabX + 2;

    DetGLabelX = (int)MathRound(80 * DPIScale * PanelSize);
    DetGLabelEX = (int)MathRound(80 * DPIScale * PanelSize);
    DetGLabelY = (int)MathRound(20 * DPIScale * PanelSize);
    DetButtonX = (int)MathRound(90 * DPIScale * PanelSize);
    DetButtonY = DetGLabelY;

    CurGLabelX = (int)MathRound(80 * DPIScale * PanelSize);
    CurGLabelEX = (int)MathRound(80 * DPIScale * PanelSize);
    CurGLabelY = (int)MathRound(20 * DPIScale * PanelSize);
    CurButtonX = (int)MathRound(90 * DPIScale * PanelSize);
    CurButtonY = DetGLabelY;

    if (TimeFormat == HMS)
    {
        HoursString = "h ";
        MinutesString = "m ";
        SecondsString = "s";
    }
    else if (TimeFormat == COLON)
    {
        HoursString = ":";
        MinutesString = ":";
        SecondsString = "";
    }

    if ((DefaultDisplay == 1) && (DefaultOpen == 1)) DetailsOpen = true;
    if ((DefaultDisplay == 1) && (DefaultOpen == 2)) CurrentOpen = true;
    if (DefaultDisplay == 1) CreateMiniPanel();
    if (DefaultDisplay == 0) ShowCountdown();
    if (DefaultDisplay == 0)
    {
        DetailsOpen = false;
        CurrentOpen = false;
    }

    EventSetTimer(1);
    
    return INIT_SUCCEEDED;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值