Tutte le domande dei nuovi arrivati su MQL4 e MQL5, aiuto e discussione su algoritmi e codici - pagina 612
Ti stai perdendo delle opportunità di trading:
- App di trading gratuite
- Oltre 8.000 segnali per il copy trading
- Notizie economiche per esplorare i mercati finanziari
Registrazione
Accedi
Accetti la politica del sito e le condizioni d’uso
Se non hai un account, registrati
Ho scritto del codice che quando un ordine qualsiasi chiude tutti gli altri ordini in sospeso, ma il problema è che ho scritto 4 ordini 2, 3, 4, 5. Quindi quando i prossimi ordini pendenti 6, 7, 8, ecc. vengono aperti, non devono essere chiusi. I numeri degli ordini evidenziati in rosso dovrebbero essere cambiati negli ordini che tutti gli ordini pendenti saranno chiusi.
void start(){
//----
doppio Take1 = Ask+20 *Point;
doppio Take2 = Ask+0 *Point;
doppio Take3 = Ask-20 *Point;
doppio Take4 = Ask-40 *Point;
doppio Take5 = Ask-60 *Point;
doppio Stop = Bid-StopLoss *Point;
se(OrdiniTotali()==0){
OrderSend(Symbol(),0,0.01,Ask,30,Stop,Take1,",0,0,0,CLR_NONE);
OrderSend(Symbol(),2,0.02,Ask-20*Point,30,Stop,Take2,"",0,0,0,CLR_NONE);
OrderSend(Symbol(),2,0.04,Ask-40*Point,30,Stop,Take3,",0,0,0,CLR_NONE);
OrderSend(Symbol(),2,0.08,Ask-60*Point,30,Stop,Take4,",0,0,0,CLR_NONE);
OrderSend(Symbol(),2,0.16,Ask-80*Point,30,Stop,Take5,"",0,0,0,CLR_NONE);
}
se(OrdiniTotali()==4)
{
OrderDelete(2);
}
se(OrdiniTotali()==3)
{
OrderDelete(3);
}
se(OrdiniTotali()==2)
{
OrderDelete(4);
}
se(OrdiniTotali()==1)
{
OrderDelete(5);
ritorno(0);
}
Ho scritto del codice che quando un ordine qualsiasi chiude tutti gli altri ordini in sospeso, ma il problema è che ho scritto 4 ordini 2, 3, 4, 5. Quindi quando i prossimi ordini pendenti 6, 7, 8, ecc. vengono aperti, non devono essere chiusi. I numeri di ordine evidenziati in rosso dovrebbero essere cambiati in quegli ordini che tutti gli ordini in sospeso saranno chiusi.
Per prima cosa, controlliamo nel ciclo se la posizione è stata recentemente chiusa o meno, per cui avremo bisogno di OrdersHistoryTotal. Dove controlliamo il tempo di chiusura della posizione OrderCloseTime, se è superiore all'ultimo nella variabile, allora facciamo un loop attraverso tutti gli OrdersTotal aperti. E chiuderli.
P.S. Inserisci il codice usando Alt+S o il tasto
Per esempio questo
ecco la condizione if(OrdersTotal()==0). ma cosa dovremmo scrivere la condizione se ci sono zero baie?
Se (OP_BUY==0)
Se (OP_BUY==0)