RefreshRates();
Sleep(3000);
DataOraAperOrdin=TimeToStr(OrderOpenTime(),TIME_DATE|TIME_SECONDS);
DataOraChiusOrdin=TimeToStr(OrderCloseTime(),TIME_DATE|TIME_SECONDS);
CorpoEmail=StringConcatenate("Chiuso ordine numero ", NumeroOrdine, ". Tipo ordine (0 buy, 1 sell) ", OrderType(), "Data\ora di apertura ", DataOraAperOrdin, ", prezzo di apertura ", OrderOpenPrice(), ", numero lotti ", OrderLots(), ". Data\ora di chiusura ", DataOraChiusOrdin, ", prezzo di chiusura ", OrderClosePrice(), ". StopLoss ", OrderStopLoss(), ". Takeprofit ", OrderTakeProfit(), ". Swap ", OrderSwap(), ". Spread ", Spread, ". Profitto senza swap e commissioni ", OrderProfit());
SendMail(OggettoEmail, CorpoEmail);
ScritturaFile=FileOpen(FileStorico,FILE_CSV|FILE_READ|FILE_WRITE,";");
FileSeek(ScritturaFile, 0, SEEK_END);
FileWrite(ScritturaFile, NumeroOrdine, Symbol(), OggettoEmail, OrderType(), DataOraAperOrdin, OrderOpenPrice(), OrderLots(), DataOraChiusOrdin, OrderClosePrice(), OrderStopLoss(), OrderTakeProfit(), OrderSwap(), Spread, OrderProfit());
FileClose(ScritturaFile);
Now i select the order first and all it's ok.
I select order to close order and, after the close, I select yet the order for file write.
I thought it was sufficient use refresrate command but it is incorrect.
Thank you very much!
Now i select the order first and all it's ok.
I select order to close order and, after the close, I select yet the order for file write.
I thought it was sufficient use refresrate command but it is incorrect.
Thank you very much!
After closing the order u must select it from the history pool (pool=MODE_HISTORY in the OrderSelect() function -> https://docs.mql4.com/trading/OrderSelect).
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all
When the Order is closed the EA analyze the closed order and send email and write file .csv with some order information.
The order informations are OpenTime OpenPrice CloseTime ClosePrice. 3 value are ok but the OrderCloseTime is not ok (I have always 1970.01.01).
I try to set sleep and refreshrates before the OrderCloseTime function but the value is always 1970.01.01.
The command is string DataOraChiusOrdin=TimeToStr(OrderCloseTime(),TIME_DATE|TIME_SECONDS);
The command for the OrderOpenTime (it work and i have correct value) is string DataOraAperOrdin=TimeToStr(OrderOpenTime(),TIME_DATE|TIME_SECONDS);
How I can resolve this?
Thanks