Elaya68
06:54,
Ottengo profitto negativo quando eseguo il trailing stop loss perché il codice non tiene conto della commissione e dello swap,
Ho provato i seguenti che non funzionano
ho bisogno di aiuto, grazie!
void LongTrailingStop ()
{
int lcnt;
int ltotal = OrdersTotal ();
doppio BuyProfit;
for (lcnt = ltotal-1; lcnt gt; = 0; lcnt--)
{
OrderSelect (lcnt, SELECT_BY_POS, MODE_TRADES);
if (OrderType () lt; = OP_SELL OrderSymbol () == Symbol ())
{
se (OrderType () == OP_BUY)/viene aperta la posizione lunga
{
if (TrailingStopgt; 0)
{
if (Bid-OrderOpenPrice () gt; (Point * TrailingStop))
{
if (OrderStopLoss () lt; bid (Point * TrailingStop))
{
BuyProfit = (OrderProfit () OrderCommission () OrderSwap ());
OrderModify (OrderTicket (), OrderOpenPrice (), bid (Point * TrailingStop BuyProfit), OrderTakeProfit (), 0, verde);
ritorno (0);
}
}
}
}
}
}
}
Ho provato i seguenti che non funzionano
ho bisogno di aiuto, grazie!
void LongTrailingStop ()
{
int lcnt;
int ltotal = OrdersTotal ();
doppio BuyProfit;
for (lcnt = ltotal-1; lcnt gt; = 0; lcnt--)
{
OrderSelect (lcnt, SELECT_BY_POS, MODE_TRADES);
if (OrderType () lt; = OP_SELL OrderSymbol () == Symbol ())
{
se (OrderType () == OP_BUY)/viene aperta la posizione lunga
{
if (TrailingStopgt; 0)
{
if (Bid-OrderOpenPrice () gt; (Point * TrailingStop))
{
if (OrderStopLoss () lt; bid (Point * TrailingStop))
{
BuyProfit = (OrderProfit () OrderCommission () OrderSwap ());
OrderModify (OrderTicket (), OrderOpenPrice (), bid (Point * TrailingStop BuyProfit), OrderTakeProfit (), 0, verde);
ritorno (0);
}
}
}
}
}
}
}