Questions about MQL4 - page 8

 
You asked him to destroy all orders five minutes before the bar closes, so he will take them all down. Just set the time correctly. And use other pieces of code to close unnecessary orders. Or, do you want the entire program to be written for you?

I was wondering about the first part... how to delete the second order after it has triggered.
My deletion happens before it triggers, but the deletion algorithm is based on checking for OPEN orders
For example, two pending orders have been set. One triggered, i.e.
OrderType()==OP_SELL or OrderType()==OP_SELL
The corresponding line is printed in the log
And in the test results
delete comes before buy or sell
and this causes confusion in order numbering

. And I asked if I could close at the end of the day without using Curtime() since the update depends on incoming ticks and if they are absent, the EA will not close at the time I need
Now I understand that you cannot since the EA does not work without ticks
 
Hang the script and it won't care if there are ticks.
 
You can delete the second one like this:
   for(cnt=0;cnt<OrdersTotal();cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { for(i=0;i<OrdersTotal();i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType()>OP_SELL && // check for opened position OrderSymbol()==Symbol()) // check for symbol { OrderDelete(OrderTicket()); } }


And the time...? Do you really have to be that precise? Set it to within 2 minutes, you don't usually get full doldrums at that time.

 
For Roger
Thanks now... With a little tweaking it worked as it should, although I still don't understand why it didn't work for me (it's all transparent to the max)
About the doldrums... The thing is that sometimes not two but five or more minutes (depending on the cross)

For Rosh
Do not share the script if you have certainly?
 
int Coord[8]; Coord[8]=1;


The compiler shows no errors. Is it supposed to be like this?

 
yes, that's how it should be.
GetLastError will generate an error when executed. the compiler does not check expression values (constant 8 is a special case of an expression)
 
Slawa,
thank you very much, I will now keep an eye on the dimensionality of arrays more carefully...)

Another simple question.
In case the lot size clearly exceeds the amount of available funds, when opening "from hand"...
- is the first check performed on the server?
- If not, why does the order opening panel hang for several seconds?
- if yes, is it correct, maybe this check should be done on the terminal first?
 
For Roger<br / translate="no"> Thanks now... With a little tweaking it worked as it should although I still don't understand why it didn't work for me (everything is transparent to the extreme)
About the doldrums... The thing is that sometimes not two but five or more minutes (depending on the cross)

For Rosh
Can you share the script, if you have one?


I just noticed, or maybe I forgot. What script is the one that works independent of ticks?
If so, we should write something like:

while (true) { startFromExpert(); Sleep(as long as necessary); }



The function startFromExpert() is obtained by simply re-branding the EA's start() function, we copy it all and paste it into our script, and do not forget to use all parameters of the EA.
This is one of the options.

 
In MQL 3 there was a function:
TotalProfit - total unrealized profit on all open positions.
I can't find how to implement it in MQL 4, please advise how to do it.
 
I will start swearing soon too. Don't you want to read the help?
double AccountProfit( ) <br / translate="no">

Returns profit value for the current account.

Example

Print("Profit ", AccountProfit());
Reason: