Ragazzi ho fatto una funzione che mi sposta il tp degli ordini, in input gli passo il valore di una media, ora succede questo a volte nonostante il take venga "preso" l'ordine non si chiude(allego screen), e poi capita anche che il take segue il prezzo poi il prezzo si (ritira) e il take rimane senza chiudere l'ordine (non so come spiegare meglio dovrei farvi un video)
penso che sia un problema dello slippage, avete idee come risolvere il problema;
funzione che sposta il take profit degli ordini
Re: funzione che sposta il take profit degli ordini
Dovresti abilitare sul grafico la visualizzazione della linea del Bid. Se è un ordine Long allora si chiude quando il Bid raggiunge il target.
Re: funzione che sposta il take profit degli ordini
Da quanto scrivi sembra che il tuo codice sposti in modo bidirezionale e troppo velocemente il tuo TakeProfit, un pò come la carota attaccata al filo davanti al muso del cavallo.
Re: funzione che sposta il take profit degli ordini
Quindi non è questione di spread medio o di slippage? idee o suggerimenti su come risolvere
Re: funzione che sposta il take profit degli ordini
Posta il tuo codice che vedo cosa sbagli.
Re: funzione che sposta il take profit degli ordini
Codice: Seleziona tutto
}
void TpModify(double tp)
{
static const string ms = "MaxSpread_" + _Symbol;
double maxSpread; GlobalVariableGet(ms, maxSpread);
double curSpread = (Ask - Bid) / _Point;
double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
if(maxSpread == 0.0) maxSpread = (Ask - Bid) / _Point;
double TakeProfit_B=NormalizeDouble(Ask+minstoplevel + tp*Point,Digits); //BUY
double TakeProfit_S=NormalizeDouble(Bid-minstoplevel - tp*Point,Digits); //SELL
for (int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
if(OrderSymbol()!=Symbol())continue;
if(OrderMagicNumber()!= MagicNumber)continue;
if (OrderType() == OP_BUY)
{
if (OrderOpenPrice()< TakeProfit_B)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), 0,0, clrGreen))
Print("Modifying order, delete TakeProfit");
}
if (tp< TakeProfit_B)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), TakeProfit_B,0, clrGreen))
Print("Modifying order, TakeProfit_B!");
else
Print("Error modifying order!, error#", GetLastError());
}
else if(tp> TakeProfit_B)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), tp, 0, clrGreen))
Print("Modifying order!");
else
Print("Error modifying order!, error#", GetLastError());
}
}
if (OrderType()==OP_SELL)
{
if (OrderOpenPrice()> TakeProfit_S)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), 0,0, clrGreen))
Print("Modifying order, delete TakeProfit");
}
if (tp< TakeProfit_S)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), TakeProfit_S, 0, clrGreen))
Print("Modifying orderTakeProfit_S!");
else
Print("Error modifying order!, error#", GetLastError());
}
else if (tp> TakeProfit_S)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), tp, 0, clrGreen))
Print("Modifying order!");
else
Print("Error modifying order!, error#", GetLastError());
}
}
}
Questa è la funzione che mi gestisce il tp e in input gli passo una media
Chi c’è in linea
Visitano il forum: Nessuno e 0 ospiti