non riesco a modificare bene gli ordini pendenti :( vorrei che quando si avvicina di 100 pips al prezzo dell'ordine pendente parte una scadenza di 30 minuti! ovviamente dopo 30 minuti l'ordine viene cancellato!
ho fatto vari tentativi soltanto che partono sempre ordini a raffica... a me serve soltanto che modifica un ordine pendente per volta.
vi scrivo il mio codice:
Codice: Seleziona tutto
int start()
{
if (!ordineaperto())
{
if ( Hour() >= 8)
{
double HGrid_Pips = 50.0;
double dayH = iHigh(NULL, PERIOD_D1, 0);
double dayL = iLow(NULL, PERIOD_D1,0);
double pipRange=HGrid_Pips *10*Point;
double top1 = (dayH + pipRange) - MathMod(dayH, pipRange);
double top2 = (dayH + pipRange) - MathMod(dayH, pipRange)+ 500 *Point;
double bot1 = dayL - MathMod(dayL, pipRange);
double bot2 = dayL - MathMod(dayL, pipRange)- 500 *Point;
OrderSend(NULL,OP_SELLLIMIT,0.5,top1,0,top1 + 200 *Point,top1 - 50 *Point,NULL,MagicNumber,0,clrAliceBlue);
OrderSend(NULL,OP_SELLLIMIT,0.5,top2,0,top2 + 200 *Point,top2 - 50 *Point,NULL,MagicNumber,0,clrAliceBlue);
OrderSend(NULL,OP_BUYLIMIT,0.5,bot1, 0,bot1 - 200 *Point,bot1 + 50 *Point,NULL,MagicNumber,0,clrAquamarine);
OrderSend(NULL,OP_BUYLIMIT,0.5,bot2, 0,bot2 - 200 *Point,bot2 + 50 *Point,NULL,MagicNumber,0,clrAquamarine) ;
}
}
{
modificapendenti();
}
return(0);
}
bool ordineaperto ()
{
{
for(int i = 0; i < OrdersTotal(); i++)
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (iBarShift(NULL, PERIOD_MN1, OrderOpenTime(), true) == 0)
return true;
for(int i2 = 0; i2 < OrdersHistoryTotal(); i2++)
if(OrderSelect(i2, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (iBarShift(NULL, PERIOD_MN1, OrderOpenTime(), true) == 0)
return true;
}
return false;
}
void modificapendenti()
{
if ( OrdersTotal() > 0)
{
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES))
if (OrderType() == OP_BUYLIMIT && OrderMagicNumber() == MagicNumber)
{
if ( Bid - OrderOpenPrice() < 100 *Point)
if( OrderModify (OrderTicket (),OrderOpenPrice(),OrderStopLoss() ,OrderTakeProfit(),1800,clrAliceBlue))
Print ("BUYLIMIT",OrderTicket(),"MODIFICA");
}
}
}
}