Thanx guys for helping. I think I could solve the problem. I have merged the conditions of closed order profit into one. After closing (trigger or SL,TP) the code will check the last closed order. And this checking is independent from the closing criteria.
if (liveorder==false) {
if (last_profit==false) {
for (counter2=OrdersHistoryTotal()-1;counter2 >= 0;counter2--) {
if (OrderSelect(counter2,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol()==szimbolum && OrderMagicNumber()==magic_number) {
close_order_profit=OrderProfit() + OrderSwap() + OrderCommission();
Conditions: liveorder=false: no running trade ; last_profit=false: profit of closed trade did not get earlier ;
The first closed trade (magic number, symbol) is the trade what I want to get, so with OrderProfit I will get what I am looking for.
Thx for hint (conditions, loop, decrement loop etc.)!
total_profit is double. It's writing something out, I see 8 bytes filelength. It's recomended to close file after each write and read? Or could be stay opened?
total_profit is double. It's writing something out, I see 8 bytes filelength. It's recomended to close file after each write and read? Or could be stay opened?
You wrote a double, (total_profit,) and the size of a double is 8. What's the problem?
If you close after the write the next open is rewriting the file, unless you seek to the end.
You wrote a double, (total_profit,) and the size of a double is 8. What's the problem?
If you close after the write the next open is rewriting the file, unless you seek to the end.
If you keep it open, flush after each write.
Ty, from your answer the 3nd I did not know. In first version I have kept open and I got 16 bytes. If I read it back got wrong result. Now I close it after each write and as you wrote I got a rewrited file. Thats what I want.
WHRoeder I like to ask something about indicators crossing. Example: moving average. How can I avoid the off-key crossing? Sometimes the indicators are crossing each other but after the candle closing I see no crossing. If my EA under the candle time after "crossing" take a trade, it could be off-key after the candle closing. I hope it is understandable. As I am thinking in my EA I will check the 0. and the 1st shifted indicators if I want to get the crossing. But this thinking leads sometimes off-key crossing. Could you please help me?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Thanx guys for helping. I think I could solve the problem. I have merged the conditions of closed order profit into one. After closing (trigger or SL,TP) the code will check the last closed order. And this checking is independent from the closing criteria.
Conditions: liveorder=false: no running trade ; last_profit=false: profit of closed trade did not get earlier ;
The first closed trade (magic number, symbol) is the trade what I want to get, so with OrderProfit I will get what I am looking for.
Thx for hint (conditions, loop, decrement loop etc.)!
I have another problem. I don't want to start for this a new topic, I share here:
I want to open(create) a file for writing & reading, but it doesn't work
I get always errorcode. What could be wrong?
filename=terminal_data_path+"\\MQL4\\Files\\"+filename_temp;Ty WHRoeder!
I used search, but this topic what you have linked I did not find. Thats why I asked. Btw thx for help.
I am confused. What could be wrong with file write?
total_profit is double. It's writing something out, I see 8 bytes filelength. It's recomended to close file after each write and read? Or could be stay opened?
if I don't use:
but:
FileWriteDouble(filehandle,total_profit,DOUBLE_VALUE);It's working.
total_profit is double. It's writing something out, I see 8 bytes filelength. It's recomended to close file after each write and read? Or could be stay opened?
Ty, from your answer the 3nd I did not know. In first version I have kept open and I got 16 bytes. If I read it back got wrong result. Now I close it after each write and as you wrote I got a rewrited file. Thats what I want.
WHRoeder I like to ask something about indicators crossing. Example: moving average. How can I avoid the off-key crossing? Sometimes the indicators are crossing each other but after the candle closing I see no crossing. If my EA under the candle time after "crossing" take a trade, it could be off-key after the candle closing. I hope it is understandable. As I am thinking in my EA I will check the 0. and the 1st shifted indicators if I want to get the crossing. But this thinking leads sometimes off-key crossing. Could you please help me?