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

    移动止损功能

    老周 LV16
    2017-03-27 · 1806 阅读
    该函数执行移动止损功能。

    1. for(i = 0; i < OrdersTotal(); i++)
    2. { // 1
    3. OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    4. // Trail Long / Buy
    5. if ( (OrderType() == OP_BUY) && (OrderMagicNumber() == magic) )
    6. { // 2
    7. if ( (OrderClosePrice() - OrderOpenPrice()) > (TrailingStop*Point) )
    8. { // 3
    9. if ( OrderStopLoss() < (OrderClosePrice() - TrailingStop*Point) )
    10. { // 4
    11. OrderModify(OrderTicket(),
    12. OrderOpenPrice(),
    13. OrderClosePrice() - TrailingStop*Point,
    14. OrderTakeProfit(),
    15. Orchid);
    16. } // 4
    17. } // 3
    18. } // 2
    19. // Trail Short / Sell
    20. if ( (OrderType() == OP_SELL) && (OrderMagicNumber() == magic) )
    21. { // 2
    22. if ( (OrderOpenPrice() - OrderClosePrice()) > (TrailingStop*Point) )
    23. { // 3
    24. if ( (OrderStopLoss() > (OrderClosePrice() + TrailingStop*Point)) ||
    25. (OrderStopLoss() == 0) )
    26. { // 4
    27. OrderModify(OrderTicket(),
    28. OrderOpenPrice(),
    29. OrderClosePrice() + TrailingStop*Point,
    30. OrderTakeProfit(),
    31. Orchid);
    32. } // 4
    33. } // 3
    34. } // 2
    35. } // 1
    36. //+- End of trading control -----------------------------------------------------------------+
    37. } // B if (UserAcceptsAllLiability == true)
    38. return(0);
    39. } // A init start()
    复制代码


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

    举报

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

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

    微信二维码

    有问题联系客服