大伊人青草狠狠久久-大伊香蕉精品视频在线-大伊香蕉精品一区视频在线-大伊香蕉在线精品不卡视频-大伊香蕉在线精品视频75-大伊香蕉在线精品视频人碰人

您現(xiàn)在的位置:程序化交易>> 外匯現(xiàn)貨>> MT4>> MT4知識>>正文內(nèi)容

MT編程入門教程(0)----指標(biāo)文件構(gòu)成 [MT4]

  • //例1
    //+------------------------------------------------------------------+
    //雙些線后是單行注釋,用于注解,自用說明。/*和*/包起來實現(xiàn)多行注釋,記錄自己的說明介紹,編程使用記錄等
    //MQL4語言基本服從C語言的規(guī)則-----------注意目前MetaEditor處理不好多字節(jié)代碼,所以不要在代碼中使用中文和中文空格-------------+
    //每個指標(biāo)文件只是至少包括三個部分(1)property 和參數(shù),數(shù)組聲明,(2)初始化函數(shù)nit(), (3)主函數(shù)start()
    //property 是各種說明信息
    //最重要必須的是這三種,(1)說明指標(biāo)將畫在價格窗口還是獨立的窗口
    //(2)有多少個(1~7)儲存指標(biāo)數(shù)據(jù)的數(shù)組,(3)說明對應(yīng)將畫指標(biāo)的繪畫顏色,編號1~7
    #property indicator_chart_window
    #property indicator_buffers 1
    #property indicator_color1 Red

    //---- 可設(shè)置的參數(shù),可根據(jù)需要,由使用者設(shè)置
    extern int MA_Period=13;
    extern int MA_Shift=0;
    extern int MA_Method=2;
    extern int MA_Price = 6;
    /* MA_Method =
    MODE_SMA 0 Simple moving average,
    MODE_EMA 1 Exponential moving average,
    MODE_SMMA 2 Smoothed moving average,
    MODE_LWMA 3 Linear weighted moving average.
    */
    /* MA_Price =
    PRICE_CLOSE 0 Close price.
    PRICE_OPEN 1 Open price.
    PRICE_HIGH 2 High price.
    PRICE_LOW 3 Low price.
    PRICE_MEDIAN 4 Median price, (high+low)/2.
    PRICE_TYPICAL 5 Typical price, (high+low+close)/3.
    PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

    */

    //數(shù)組,儲存指標(biāo)數(shù)據(jù)
    double Buffer0[];
    //----
    //+------------------------------------------------------------------+
    //| 初始化準(zhǔn)備函數(shù),裝入時調(diào)用一次 |
    //+------------------------------------------------------------------+
    int init()
    {
    //-設(shè)置編號為0的線的線形等參數(shù), 0~6,對應(yīng)indicator_color1~7
    SetIndexStyle(0,DRAW_LINE);
    //---- 設(shè)置編號為0的線 與數(shù)組的對應(yīng)關(guān)系, 0~6
    SetIndexBuffer(0,Buffer0);
    return(0);
    }
    //+------------------------------------------------------------------+
    //| |
    int start() //指標(biāo)計算主函數(shù),每次計算調(diào)用
    {
    ma();
    return(0);
    }
    //+------------------------------------------------------------------+
    //|自定義函數(shù),這里只是直接使用庫函數(shù)實現(xiàn)MA, 若你自己計算,可設(shè)計任何指標(biāo) |
    //+------------------------------------------------------------------+
    void ma()
    {
    int pos=Bars; //Bars = Number of bars in the current chart.當(dāng)前窗口中的蠟燭數(shù)
    while(pos>=0)
    {
    Buffer0[pos]=iMA(NULL,0,MA_Period,MA_Shift,MA_Method,MA_Price,pos);
    pos--;
    }
    }
    //
    ///----------------------------------------------------------------------


    [Copy to clipboard]


    例2

    CODE:

    //+------------------------------------------------------------------+
    //雙些線后是單行注釋,用于注解,自用說明。/*和*/包起來實現(xiàn)多行注釋,記錄自己的說明介紹,編程使用記錄等
    //MQL4語言基本服從C語言的規(guī)則-----------注意目前MetaEditor處理不好多字節(jié)代碼,所以不要在代碼中使用中文和中文空格-------------+
    //每個指標(biāo)文件只是至少包括三個部分(1)property 和參數(shù),數(shù)組聲明,(2)初始化函數(shù)nit(), (3)主函數(shù)start()
    //property 是各種說明信息
    //最重要必須的是這三種,(1)說明指標(biāo)將畫在價格窗口還是獨立的窗口
    //(2)有多少個(1~7)儲存指標(biāo)數(shù)據(jù)的數(shù)組,(3)說明對應(yīng)將畫指標(biāo)的繪畫顏色,編號1~7
    #property indicator_separate_window
    #property indicator_buffers 7
    #property indicator_color1 Red
    #property indicator_color2 Yellow
    #property indicator_color3 Blue
    #property indicator_color4 Green
    #property indicator_color5 Gray
    #property indicator_color6 SkyBlue
    #property indicator_color7 Tan
    //---- 可設(shè)置的參數(shù),可根據(jù)需要,由使用者設(shè)置
    extern int MA_Period=13;
    extern int MA_Shift=0;
    extern int MA_Method=2;
    extern int MA_Price = 6;

    //數(shù)組,儲存指標(biāo)數(shù)據(jù)
    double Buffer0[];
    double Buffer1[];
    double Buffer2[];
    double Buffer3[];
    double Buffer4[];
    double Buffer5[];
    double Buffer6[];
    //----
    //+------------------------------------------------------------------+
    //| 初始化準(zhǔn)備函數(shù),裝入時調(diào)用一次 |
    //+------------------------------------------------------------------+
    int init()
    {
    //-設(shè)置編號為0的線的線形等參數(shù), 0~6,對應(yīng)indicator_color1~7
    SetIndexStyle(0,DRAW_LINE);
    SetIndexStyle(1,DRAW_LINE);
    SetIndexStyle(3,DRAW_LINE);
    SetIndexStyle(4,DRAW_LINE);
    SetIndexStyle(5,DRAW_LINE);
    SetIndexStyle(6,DRAW_LINE);
    //---- 設(shè)置編號為0的線 與數(shù)組的對應(yīng)關(guān)系, 0~6
    SetIndexBuffer(0,Buffer0);
    SetIndexBuffer(1,Buffer1);
    SetIndexBuffer(2,Buffer2);
    SetIndexBuffer(3,Buffer3);
    SetIndexBuffer(4,Buffer4);
    SetIndexBuffer(5,Buffer5);
    SetIndexBuffer(6,Buffer6);
    return(0);
    }
    //+------------------------------------------------------------------+
    //| |
    int start() //指標(biāo)計算主函數(shù),每次計算調(diào)用
    {
    ma();
    ma1();
    return(0);
    }
    //+------------------------------------------------------------------+
    //|自定義函數(shù),這里只是直接使用庫函數(shù)實現(xiàn)MA, 若你自己計算,可設(shè)計任何指標(biāo) |
    //+------------------------------------------------------------------+
    void ma()
    {
    int pos=Bars; //Bars = Number of bars in the current chart.當(dāng)前窗口中的蠟燭數(shù)
    while(pos>=0)
    {
    Buffer0[pos]=iMA(NULL,0,MA_Period,MA_Shift,MA_Method,MA_Price,pos);
    Buffer1[pos]=iMA(NULL,0,MA_Period*2,MA_Shift,MA_Method,MA_Price,pos);
    Buffer2[pos]=iMA(NULL,0,MA_Period*3,MA_Shift,MA_Method,MA_Price,pos);
    pos--;
    }
    }
    void ma1()
    {
    int pos=Bars; //Bars = Number of bars in the current chart.當(dāng)前窗口中的蠟燭數(shù)
    while(pos>=0)
    {
    Buffer3[pos]=iMA(NULL,0,MA_Period*4,MA_Shift,MA_Method,MA_Price,pos);
    Buffer4[pos]=iMA(NULL,0,MA_Period*5,MA_Shift,MA_Method,MA_Price,pos);
    Buffer5[pos]=iMA(NULL,0,MA_Period*6,MA_Shift,MA_Method,MA_Price,pos);
    Buffer6[pos]=iMA(NULL,0,MA_Period*7,MA_Shift,MA_Method,MA_Price,pos);
    pos--;
    }
    }

【字體: 】【打印文章】【查看評論

相關(guān)文章

    沒有相關(guān)內(nèi)容
主站蜘蛛池模板: 9966久久精品免费看国产 | 日本不卡一区二区三区视频 | 华人欧美国产在线精品 | 久久99精品久久久久久噜噜 | 51国产午夜精品免费视频 | 国内精品视频一区二区三区八戒 | 久久一区二区三区不卡 | 亚洲六月丁香婷婷综合 | 日本aaaaa级毛片 | 国内特级毛片 | 午夜性色福利视频在线视频 | 亚洲成人福利 | 一级毛片免费高清视频 | 97午夜理伦片在线影院 | 热re66久久精品国产99re | 色无极综合 | 天天夜夜爽| 国产精品亚洲精品一区二区三区 | 久久精品国产亚洲高清 | 国产在线视精品麻豆 | 5g影院天天5g天天爽精品 | 亚洲成人免费网站 | 日韩欧美h | 99热国产在线| 免费黄色一级大片 | 在线视频www| 久久精品国产国语对白 | fxxxx性欧美高清 | 国产高清看片日韩欧美久久 | 精品日本久久久久久久久久 | 97影院在线午夜 | 看黄a大片 免费 | 亚洲精品久久久久网站 | 成人免费视频网站 | 精品视频一区二区三区在线播放 | 四虎成人精品 | 四虎影视入口 | 91久久福利国产成人精品 | 国产男女xoxo在线视频 | 成人欧美一区二区三区视频不卡 | 香蕉视频网站在线播放 |