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

    指定平仓时间

    老周 LV16
    2017-03-21 · 2911 阅读
    该函数在到达设定时间后执行平仓。过滤条件:货币对、订单类型、平仓开始时间。

    1. total=OrdersTotal();
    2. for(cnt=0;cnt<total;cnt++)
    3. {
    4. OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    5. if(OrderType()<=OP_SELL && // check for opened position
    6. OrderSymbol()==Symbol()) // check for symbol
    7. {
    8. if(OrderType()==OP_BUY) // long position is opened
    9. {
    10. // should it be closed?
    11. if(total>0 && Hour()==22 && Minute()>45)
    12. {
    13. OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
    14. return(0); // exit
    15. }
    16. }
    17. else // go to short position
    18. {
    19. // should it be closed?
    20. if(total>0 && Hour()==22 && Minute()>45)
    21. {
    22. OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
    23. return(0); // exit
    24. }
    25. }
    26. }
    27. }
    复制代码


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

    举报

     

    回答|共 4 个

    kun LV3

    发表于 2018-9-2 13:31:24 | 显示全部楼层

    真是 收益 匪浅

    LucienLin LV4

    发表于 2018-12-12 21:53:21 | 显示全部楼层

    謝謝分享,正在學習中

    hdhgh888 LV1

    发表于 2018-12-12 22:34:17 | 显示全部楼层

    謝謝分享,正在學習中

    春夏秋冬cxqd LV1

    发表于 2019-4-23 14:35:03 | 显示全部楼层

    謝謝分享,正在學習中
    您需要登录后才可以回帖 登录 | 注册

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

    微信二维码

    有问题联系客服