mql4 绘制蜡烛图
//+------------------------------------------------------------------+
//|                                                   绘制蜡烛图.mq4 |
//|                                          Copyright 2023, 100w123 |
//|                                              https://100w123.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, 100w123"
#property link      "https://100w123.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

#property indicator_buffers 4
#property indicator_color1 clrDodgerBlue
#property indicator_width1 1
#property indicator_color2 clrRed
#property indicator_width2 1
#property indicator_color3 clrLightBlue
#property indicator_width3 3
#property indicator_color4 clrLightPink
#property indicator_width4 3

double blue_shadow[];
double red_shadow[];
double blue_body[];
double red_body[];

//+------------------------------------------------------------------+
int OnInit() {
    SetIndexBuffer(0, blue_shadow);
    SetIndexStyle(0, DRAW_HISTOGRAM);
    SetIndexBuffer(1, red_shadow);
    SetIndexStyle(1, DRAW_HISTOGRAM);
    SetIndexBuffer(2, blue_body);
    SetIndexStyle(2, DRAW_HISTOGRAM);
    SetIndexBuffer(3, red_body);
    SetIndexStyle(3, DRAW_HISTOGRAM);

    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[]) {
    int i, limit;
    if (prev_calculated == 0)
        limit = rates_total - 1;           // 没有计算时是最左侧第一根
    else
        limit = rates_total - prev_calculated; // 从左侧新增的 bar 开始

    for (i = limit; i >= 0; i--) {         // 从左往右开始处理
        blue_body[i] = Close[i];
        red_body[i] = Open[i];

        if (Open[i] < Close[i]) {
            blue_shadow[i] = High[i];
            red_shadow[i] = Low[i];
        } else {
            red_shadow[i] = High[i];
            blue_shadow[i] = Low[i];
        }
    }

    return(rates_total);
}
//+------------------------------------------------------------------+
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇