您现在的位置作文600字:简单化交易>> 外汇现货>> MT5>> MT5知识>>正文内容

MT5编程案例课程目录(阿郎)---第三讲活动(均线交加EA) [MT4]

  • #property copyright "Simon Yau"
    #property link "http://www.fx998.cn"
    #property version "1.00"
    int maFastHandle, maSlowHandle; //定义两个ca88会员登录入口手机ca88会员登录入口手机网操作句柄,用来操作两条均线
    double maFast[], maSlow[]; //定义两个数组,用于保存均线的数值
    //+------------------------------------------------------------------+
    //| Expert initialization function |
    //+------------------------------------------------------------------+
    int OnInit()
    {
    //---
    //在初始化函数OnInit中。区分指定两个操作句柄所对应的均线ca88会员登录入口手机ca88会员登录入口手机网
    maFastHandle = iMA(Symbol(), PERIOD_CURRENT, 5, 0, MODE_SMA, PRICE_CLOSE); //对应5期均线
    maSlowHandle = iMA(Symbol(), PERIOD_CURRENT, 10, 0, MODE_SMA, PRICE_CLOSE); //对应10期均线

    ArraySetAsSeries(maFast, true); //将数组办起为倒序保存,即图表上方向由右向左
    ArraySetAsSeries(maSlow, true); //同上
    //---
    return(0);
    }
    //+------------------------------------------------------------------+
    //| Expert deinitialization function |
    //+------------------------------------------------------------------+
    //+------------------------------------------------------------------+
    //| Expert tick function |
    //+------------------------------------------------------------------+
    void OnTick()
    {
    //---
    MqlTradeRequest request;
    MqlTradeResult result;

    CopyBuffer(maFastHandle, 0, 0, 3, maFast); //将句柄对应的ca88会员登录入口手机ca88会员登录入口手机网数值复制入数组
    CopyBuffer(maSlowHandle, 0, 0, 3, maSlow); //同上

    if (maFast[1]>maSlow[1] && maFast[2]<=maSlow[2]) //数组博取ca88会员登录入口手机ca88会员登录入口手机网的数值后,就可以开展均线交加的断定了
    {
    request.action = TRADE_ACTION_DEAL;
    request.symbol = Symbol();
    request.volume = 0.1;
    request.price = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
    request.type = ORDER_TYPE_BUY;

    OrderSend(request, result); //下单
    }
    else if (maFast[1]<maSlow[1] && maFast[2]>=maSlow[2])
    {
    request.action = TRADE_ACTION_DEAL;
    request.symbol = Symbol();
    request.volume = 0.1;
    request.price = SymbolInfoDouble(Symbol(), SYMBOL_BID);
    request.type = ORDER_TYPE_SELL;

    OrderSend(request, result);
    }
    }
    作者:阿郎(shawnyau)栽自火线贷款论坛http://www.fx998.cn。
    Lesson3代码.rar (2 K) 下载次数:155

【书体: 】【打印文章】【查看评论

相关文章

    没有相关内容
Baidu