订单移动止损功能

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:37 回复:0 关注量:986
该函数实现订单移动止损功能。

  1. void TrailingStairs(int ticket,int trldistance)
  2. {
  3. int Spred=Ask - Bid;
  4. if (OrderType()==OP_BUY)
  5. {
  6. if((Bid-OrderOpenPrice())>(Point*trldistance))
  7. {
  8. if(OrderStopLoss()<Bid-Point*trldistance || (OrderStopLoss()==0))
  9. {
  10. OrderModify(ticket,OrderOpenPrice(),Bid-Point*trldistance,OrderTakeProfit(),0,Green);
  11. if (PolLots)
  12. if
  13. (NormalizeDouble(OrderLots()/2,2)>MarketInfo(Symbol(),
  14. MODE_MINLOT))
  15. {
  16. OrderClose(ticket,NormalizeDouble(OrderLots()/2,2),Ask,3,Green);
  17. }
  18. else
  19. {
  20. OrderClose(ticket,OrderLots(),Ask,3,Green);
  21. }
  22. }
  23. }
  24. }
  25. else
  26. {
  27. if((OrderOpenPrice()-Ask)>(Point*trldistance))
  28. {
  29. if((OrderStopLoss()>(Ask+Point*trldistance)) || (OrderStopLoss()==0))
  30. {
  31. OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*trldistance,OrderTakeProfit(),0,Red);
  32. if (PolLots)
  33. if
  34. (NormalizeDouble(OrderLots()/2,2)>MarketInfo(Symbol(),
  35. MODE_MINLOT))
  36. {
  37. OrderClose(ticket,NormalizeDouble(OrderLots()/2,2),Bid,3,Green);
  38. }
  39. else
  40. {
  41. OrderClose(ticket,OrderLots(),Bid,3,Green);
  42. }
  43. }
  44. }
  45. }
  46. }
打赏