© 本贴为 大飞 原创/首发,严禁抄袭!
- //---移动止损
- void mstoploss_1(int stoploss)
- {
- bool modifys = false;
-
- for(int i=0; i<OrdersTotal(); i++)
- {
- if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)
- break;
- if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
- {
- if((Bid -OrderOpenPrice()) > stoploss*MarketInfo(OrderSymbol(), MODE_POINT))
- {
- if((OrderStopLoss() < (Bid -stoploss*MarketInfo(OrderSymbol(), MODE_POINT))) || (OrderStopLoss()==0))
- {
- modifys = OrderModify(OrderTicket(),OrderOpenPrice(),Bid - stoploss*MarketInfo(OrderSymbol(), MODE_POINT),OrderTakeProfit(),0,clrNONE);
- }
- }
- }
- if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
- {
- if((OrderOpenPrice() -Ask) > (stoploss*MarketInfo(OrderSymbol(), MODE_POINT)))
- {
- if((OrderStopLoss()) > (Ask + stoploss*MarketInfo(OrderSymbol(), MODE_POINT)) || (OrderStopLoss()==0))
- {
- modifys = OrderModify(OrderTicket(),OrderOpenPrice(),Ask + stoploss*MarketInfo(OrderSymbol(),MODE_POINT),OrderTakeProfit(),0,clrNONE);
- }
- }
- }
- }
- }
复制代码
|