Anyway, the point is this: I'm looking for code options to search for orders.
Do you want to monitor active orders?
MQL4 or MQL5?
Do you want to monitor active orders?
Basically, the gist is as follows, I am looking for code options to search for orders.
The task is as follows:
1 :
Get information about the maximum order by price and by order type ( Buy / Sell ) topmost
To get information about the minimum order by price and by order type ( Buy/Sell ) lowest
Get last order information by time and by order type ( Buy/Sell )
Get information about the first order by time and by order type ( Buy/Sell )
2 :
Obtain information about last but one maximal price and order type ( Buy/Sell )
Obtain information on last but one minimum order (Buy/Sell) by price and by order type ( Buy/Sell )
Get information about the last but one order by time and by order type (Buy/Sell)
Get information about second order in time and order type (Buy/Sell)
This information includes all information about the order (symbol, lot, price ......)
The procedural programming style solved it long time ago, now I want to simplify it and make a class, but I can't think of anything useful...
Yes Vladimir - it's a GREAT task! :-)
Can you tell me where to go?
Only not all, but maximum/minimum by price and first and last by time, 2 of each, i.e. last and penultimate...
It's not difficult, because you are setting orders.
So, you will remember the last two BUY's and the last two SELL's
And you won't have to search for anything.
struct MEM_ORDER { ulong ticket; long ord_type; double price; }; struct MEM_ORDERS { bool is_first_buy; bool is_first_sell; MEM_ORDER buy_oders[2]; MEM_ORDER sell_oders[2]; };
It's not difficult, because you are setting orders.
So, you will remember the last two BUY's and the last two SELL's
And you won't have to search for anything.
I thought of such a solution, but I was not happy with the fact that when the EA/terminal is reloaded, it is re-initialised and all data from the past work will be lost.
I think the most reliable way to work is to collect data about the environment when the EA is working.
I thought of such a solution, but I was not happy with the fact that when the EA/terminal is reloaded, it is re-purposed and all data from the previous work will be lost.
I believe that a reliable method of operation is to collect data about the environment at the time of the EA operation.
And what prevents you from saving data to a file when you exit the EA, and when you load it, load it from a file?
//| Expert Load setings function | //+------------------------------------------------------------------+ void LoadSettings() { string file_name = _Symbol + ".dat"; int file_handle; //--- if ( FileIsExist( file_name, 0 ) ) { file_handle = FileOpen( file_name, FILE_READ|FILE_BIN ); if ( file_handle != INVALID_HANDLE ) { e_high = FileReadLong( file_handle ); a_profit = FileReadLong( file_handle ); e_low = FileReadLong( file_handle ); ord_delta_high = FileReadLong( file_handle ); ord_delta_low = FileReadLong( file_handle ); order_delta = FileReadLong( file_handle ); exit_delta = FileReadLong( file_handle ); FileClose( file_handle ); } } } //+------------------------------------------------------------------+ //| Expert Save settings function | //+------------------------------------------------------------------+ void SaveSettings() { string file_name = _Symbol + ".dat"; int file_handle; bool file_found = true; //--- if ( FileIsExist( file_name, 0 ) ) { if ( FileDelete( file_name, 0 ) ) file_found = false; } else { file_found = false; } //--- if ( ! file_found ) { file_handle = FileOpen( file_name, FILE_WRITE|FILE_BIN ); if ( file_handle != INVALID_HANDLE ) { FileWriteLong( file_handle, e_high ); FileWriteLong( file_handle, a_profit ); FileWriteLong( file_handle, e_low ); FileWriteLong( file_handle, ord_delta_high ); FileWriteLong( file_handle, ord_delta_low ); FileWriteLong( file_handle, order_delta ); FileWriteLong( file_handle, exit_delta ); FileClose( file_handle ); } } }
What prevents you from saving the data to a file when you leave the EA and loading it from a file when you load it?
This is of course good, but not reliable, as the environment may change during the reboot.
Close all orders before exiting.
You still need to do this.
Close all orders before exiting.
It's a tedious thing to do anyway.
Unanticipated restarts will lead to trouble...
I wrote a class...
Unanticipated reboots will lead to trouble...
I have written a class...
Don't make people laugh....
If something unforeseen happens, no classes will save you!
If the windup or terminal "crashes", then the EA will re-initialise,
I just "look" at the active orders and close them, because there's no control over them.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Basically, the gist is as follows, I am looking for code options to search for orders.
The task is as follows:
1 :
Get information about the maximum order by price and by order type ( Buy / Sell ) topmost
To get information about the minimum order by price and by order type ( Buy/Sell ) lowest
Get last order information by time and by order type ( Buy/Sell )
Get information about the first order by time and by order type ( Buy/Sell )
2 :
Obtain information about last but one maximal price and order type ( Buy/Sell )
Obtain information on last but one minimum order (Buy/Sell) by price and by order type ( Buy/Sell )
Get information about the last but one order by time and by order type (Buy/Sell)
Get information about second order in time and order type (Buy/Sell)
This information includes all information about the order (symbol, lot, price ......)
The procedural programming style solved it long time ago, now I want to simplify it and make a class, but I can't think of anything useful...