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

    持仓订单的移动止损

    老周 LV16
    2017-03-27 · 2759 阅读
    函数执行持仓订单的移动止损功能。

    1. extern int Magic = 20080829;
    2. extern color clModify = Silver;
    3. extern int TrailingStart = 30;
    4. extern int TrailingSize = 30;
    5. void TrailPositions()
    6. {
    7. int cnt = OrdersTotal();
    8. for (int i=0; i<cnt; i++)
    9. {
    10. if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
    11. if (OrderSymbol() != Symbol()) continue;
    12. if (OrderMagicNumber() != Magic) continue;
    13. int type = OrderType();
    14. if (type == OP_BUY)
    15. {
    16. if (Bid-OrderOpenPrice() > TrailingStart*Point)
    17. {
    18. if (OrderStopLoss() < Bid - (TrailingSize+1)*Point)
    19. {
    20. OrderModify(OrderTicket(),
    21. OrderOpenPrice(),
    22. Bid-TrailingSize*Point,
    23. OrderTakeProfit(), 0, clModify);
    24. }
    25. }
    26. }
    27. if (type == OP_SELL)
    28. {
    29. if (OrderOpenPrice()-Ask > TrailingStart*Point)
    30. {
    31. if (OrderStopLoss() > Ask + (TrailingSize+1)*Point || OrderStopLoss() == 0)
    32. {
    33. OrderModify(OrderTicket(),
    34. OrderOpenPrice(),
    35. Ask+TrailingSize*Point,
    36. OrderTakeProfit(), 0, clModify);
    37. }
    38. }
    39. }
    40. }
    41. }
    复制代码


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

    举报

     

    回答|共 2 个

    sale LV1

    发表于 2019-10-20 17:16:16 | 显示全部楼层

    fdjhtrsjtrkkzyrkstylkytdltdu

    WUXIAODONG LV1

    发表于 2019-10-28 13:19:26 | 显示全部楼层

    sale 发表于 2019-10-20 17:16
    fdjhtrsjtrkkzyrkstylkytdltdu

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

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

    微信二维码

    有问题联系客服