我正在对两个具有不同经纪人的帐户(对冲帐户)使用掉期策略。 我有两个帐户之间(通过两个经纪人)同步的代码。
当我与经纪人A关闭买入订单时,我的EA发送关闭消息,经纪人B上的卖出订单被关闭。我从经纪人B的(掉期佣金)中获利。
我需要什么,而不是关闭经纪人B上的订单,请执行以下操作:
我只有跟踪止损功能,该功能在经纪人A的买单关闭时触发:
//+------------------------------------------------------------------+
//| Trailing stop loss |
//+------------------------------------------------------------------+
void Trail1()
{
double PointValue;
for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol()) continue; // Skipping positions in other currency pairs
Print("Swap for the order #",OrderSwap());
//Calculate the point value in case there are extra digits in the quotes
if (MarketInfo(OrderSymbol(), MODE_POINT) == 0.00001) PointValue = 0.0001;
else if (MarketInfo(OrderSymbol(), MODE_POINT) == 0.001) PointValue = 0.01;
else PointValue = MarketInfo(OrderSymbol(), MODE_POINT);
//Normalize trailing stop value to the point value
double TSTP = TrailingStop * PointValue;
if (OrderType() == OP_BUY)
{
if (OrderStopLoss() < Bid - TSTP)
{
if (!OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TSTP, OrderTakeProfit(), OrderExpiration(), clrNONE))
Print("Error setting Buy trailing stop: ", GetLastError());
}
}
else if (OrderType() == OP_SELL)
{
if ((OrderStopLoss() > Ask + TSTP) || (OrderStopLoss() == 0))
{
if (!OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TSTP, OrderTakeProfit(), OrderExpiration(), clrNONE))
Print("Error setting Sell trailing stop: ", GetLastError());
}
}
}
}
// --------------- ----------------------------------------------------------- ------------------------
请帮助。