📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    单量风险控制

    2019-12-09 · 1120 阅读
    1. #property copyright "shiyingpan"
    2. #property link      "https://aijy.github.io"
    3. #property version   "1.00"
    4. #property strict

    5. input double 万美金最大单量=2;     //--- 一万美金可下几首单量,按比例缩减
    6. bool new_orders=true;
    7. double max_lots=0;
    8. //+------------------------------------------------------------------+
    9. //|                                                                  |
    10. //+------------------------------------------------------------------+
    11. int OnInit()
    12.   {
    13.    while(AccountNumber()==0)
    14.       Sleep(10000);
    15.    max_lots=AccountEquity()/10000*万美金最大单量;
    16.    return(INIT_SUCCEEDED);
    17.   }
    18. //+------------------------------------------------------------------+
    19. //|                                                                  |
    20. //+------------------------------------------------------------------+
    21. void OnDeinit(const int reason)
    22.   {

    23.   }
    24. //+------------------------------------------------------------------+
    25. //|                                                                  |
    26. //+------------------------------------------------------------------+
    27. void OnTick()
    28.   {

    29.    double total_lots=0;
    30.    for(int i=OrdersTotal()-1;i>=0;i--)
    31.      {
    32.       if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
    33.         {
    34.          total_lots=total_lots+OrderLots();
    35.         }
    36.      }

    37.    if(total_lots>max_lots)
    38.      {
    39.       new_orders=false;
    40.      }

    41.    if(new_orders==true)
    42.      {
    43.       Print("当前单量未超最大单量,允许下单");
    44.      }
    45.   }
    复制代码


    ""
    还没有人打赏,支持一下
    回复

    举报

     
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服