當前位置:編程學習大全網 - 編程軟體 - 求問各位大神,mql4的EA中,如何壹次性對所有的多單或者空單掛壹個統壹的止損?比如我開了10筆多

求問各位大神,mql4的EA中,如何壹次性對所有的多單或者空單掛壹個統壹的止損?比如我開了10筆多

下面這段代碼妳應該看得懂,可以實現的功能是將所有同向訂單的止損止盈設置為最後成交的那個單子的止損止盈

if(use_sl_and_tp && total()>1)

{

double s_l, t_p;

for(i=0; i<OrdersTotal(); i++)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue;

type=OrderType();

s_l=OrderStopLoss();

t_p=OrderTakeProfit();

}

for(i=OrdersTotal()-1; i>=0; i--)

{

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue;

if(OrderType()==type)

{

if(OrderStopLoss()!=s_l || OrderTakeProfit()!=t_p)

{

OrderModify(OrderTicket(),OrderOpenPrice(),s_l,t_p,0,CLR_NONE);

}

}

}

}

  • 上一篇:音街如何把作品保存到本地?
  • 下一篇:醫學生需要考哪些證書
  • copyright 2024編程學習大全網