评论

收藏

移动止损功能

avatar 老周 | 1481 人阅读 | 0 人评论 | 2017-03-27

该函数执行移动止损功能。

  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()
复制代码


""
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则