zoukankan      html  css  js  c++  java
  • MT5基础知识

    获取账户相关信息 

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    printf("ACCOUNT_BALANCE =  %G",AccountInfoDouble(ACCOUNT_BALANCE));
       printf("ACCOUNT_CREDIT =  %G",AccountInfoDouble(ACCOUNT_CREDIT));
       printf("ACCOUNT_PROFIT =  %G",AccountInfoDouble(ACCOUNT_PROFIT));
       printf("ACCOUNT_EQUITY =  %G",AccountInfoDouble(ACCOUNT_EQUITY));
       printf("ACCOUNT_MARGIN =  %G",AccountInfoDouble(ACCOUNT_MARGIN));
       printf("ACCOUNT_FREEMARGIN =  %G",AccountInfoDouble(ACCOUNT_FREEMARGIN));
       printf("ACCOUNT_MARGIN_LEVEL =  %G",AccountInfoDouble(ACCOUNT_MARGIN_LEVEL));
       printf("ACCOUNT_MARGIN_SO_CALL = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_CALL));
       printf("ACCOUNT_MARGIN_SO_SO = %G",AccountInfoDouble(ACCOUNT_MARGIN_SO_SO));
     
     
    printf("ACCOUNT_LOGIN =  %d",AccountInfoInteger(ACCOUNT_LOGIN));
       printf("ACCOUNT_LEVERAGE =  %d",AccountInfoInteger(ACCOUNT_LEVERAGE));
       bool thisAccountTradeAllowed=AccountInfoInteger(ACCOUNT_TRADE_ALLOWED);
       bool EATradeAllowed=AccountInfoInteger(ACCOUNT_TRADE_EXPERT);
       ENUM_ACCOUNT_TRADE_MODE tradeMode=(ENUM_ACCOUNT_TRADE_MODE)AccountInfoInteger(ACCOUNT_TRADE_MODE);
       ENUM_ACCOUNT_STOPOUT_MODE stopOutMode=(ENUM_ACCOUNT_STOPOUT_MODE)AccountInfoInteger(ACCOUNT_MARGIN_SO_MODE);
     
     
     
       Print("The name of the broker = ",AccountInfoString(ACCOUNT_COMPANY));
       Print("Deposit currency = ",AccountInfoString(ACCOUNT_CURRENCY));
       Print("Client name = ",AccountInfoString(ACCOUNT_NAME));
       Print("The name of the trade server = ",AccountInfoString(ACCOUNT_SERVER));

    Bar 向前 的值 可以通过 Copytime  什么的 进行 操作 

    获取  iMA的 值

    1
    2
    3
    double aaa[];
       int handle = iMA(Symbol(),PERIOD_H1,60,0,MODE_SMA,PRICE_CLOSE);
       CopyBuffer(handle,0,0,2,aaa);

    开仓 

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
       if(!PositionSelect(_Symbol))
       {
     
                MqlTradeRequest request={0};
             request.action=TRADE_ACTION_DEAL;         // 设置挂单
             request.magic=1000;                  // ORDER_MAGIC
             request.symbol=_Symbol;                      // 交易品种
             request.volume=0.1;                          // 0.1为单位的交易量
             request.sl=1.09;                                // 没有指定止损价位
             request.tp=1.1;                                // 没有指定盈利价位
          //--- 形成订单类型
             request.type=ORDER_TYPE_BUY;                // 订单类型
          //--- 形成挂单价格
             request.price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);  // 开盘价
             Print(SYMBOL_ASK);
          //--- 发送交易请求
             MqlTradeResult result={0};
             OrderSend(request,result);
    Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
     
     
     
     
       }



    修改止损止盈 

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
       if(PositionSelect(_Symbol))
       {
                MqlTradeRequest request={0};
             request.action=TRADE_ACTION_SLTP;         // 设置挂单
             request.sl=1.08;                                // 没有指定止损价位
             request.tp=1.11;                                // 没有指定盈利价位
             request.symbol = _Symbol ;
             MqlTradeResult result={0};
             OrderSend(request,result);
    Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
     
       }

    平仓

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
       if(PositionSelect(_Symbol))
       {
                MqlTradeRequest request={0};
             request.action=TRADE_ACTION_DEAL;         // 设置挂单
             request.type =ORDER_TYPE_SELL;
             request.volume =PositionGetDouble(POSITION_VOLUME);
             request.price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
     
             request.symbol = _Symbol ;
             MqlTradeResult result={0};
             OrderSend(request,result);
    Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
     
       }

    挂单

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
       if(!PositionSelect(_Symbol))
       {
                MqlTradeRequest request={0};
             request.action=TRADE_ACTION_PENDING;         // 设置挂单
             request.type =ORDER_TYPE_BUY_LIMIT;
             request.volume =0.1;
             request.price=1.09;
             request.sl = 1.08;
             request.tp = 1.1;
             request.symbol = _Symbol ;
             MqlTradeResult result={0};
             OrderSend(request,result);
    Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
     
       }

    修改挂单

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
       for(int i=0;i<OrdersTotal();i++)
       {
          long tic = OrderGetTicket(i);
          MqlTradeRequest request={0};
             request.action=TRADE_ACTION_MODIFY;         // 设置挂单
       request.order = tic ;
       request.price=1.091;
       //止损 必须加 ,如果不加  则给你全部归零
             request.sl = 1.081;
             request.tp = 1.11;
             MqlTradeResult result={0};
             OrderSend(request,result);
    Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
     
     
     
     
     
       }

    移除挂单

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
       for(int i=0;i<OrdersTotal();i++)
       {
          long tic = OrderGetTicket(i);
          MqlTradeRequest request={0};
             request.action=TRADE_ACTION_REMOVE;         // 设置挂单
       request.order = tic ;
       request.price=1.091;
       //止损 必须加 ,如果不加  则给你全部归零
             request.sl = 1.081;
             request.tp = 1.11;
             MqlTradeResult result={0};
             OrderSend(request,result);
    Print(__FUNCTION__,": ",result.comment," reply code ",result.retcode);
     
     
     
     
     
       }

     

  • 相关阅读:
    Blank page instead of the SharePoint Central Administration site
    BizTalk 2010 BAM Configure
    Use ODBA with Visio 2007
    Handling SOAP Exceptions in BizTalk Orchestrations
    BizTalk与WebMethods之间的EDI交换
    Append messages in BizTalk
    FTP protocol commands
    Using Dynamic Maps in BizTalk(From CodeProject)
    Synchronous To Asynchronous Flows Without An Orchestration的简单实现
    WSE3 and "Action for ultimate recipient is required but not present in the message."
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5493798.html
Copyright © 2011-2022 走看看