[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 581
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
And may I ask what they're trying to do with this?
for(int i=0; i<OrdersTotal(); i++)
it feels like they're trying to count open positions...
Well this way it selects orders according to given parameters.
e.g. https://www. mql5.com/ru/forum/131859/page3#434221
Function NumberOfPositions().
This function returns the number of open positions at the moment. A more accurate selection of positions to be counted is specified by external parameters:
thanks...i'll add that forum thread to my bookmarks. :))
So deinit is called when I delete the robot from the chart - I can't track this condition any other way..... , it's probably easier to write a separate script that deletes all the remaining pending.
By the way, another thought on this subject:
I seem to have solved the problem of deleting orders. I calculated the number of "necessary" (to be removed) orders in a separate function, called this function and then while with a condition (Total>0), then the cycle of removing for(int i=Total-1;i<=0l; i--), again calculating"necessary", counter of removing attempts with an exit fromwhile when the given level is reached. This way everything is deleted.
An infinite loop may occur here in case one of the orders disappears after the moment of counting for any reason.
Order counting is done every time after the for loop for deleting an order, the counter iterates while with exit from the loop bybreak, when the counter reaches the value you set in the external variable, you can add error handling before the exit and output the result with
Good day!!! Can't find a pretty solution to the situation. Here is a typical order setting. But if I give zero to my robot in parameters, i.e. no stops and takeprofits, nothing will work.
We can also set an if and enter an order with zeros for the second time, but it is a bit cumbersome.
Everything is mature - at the level of art!!! ;)
And seriously - learn to think about what you have just written. At zero values of STOPPs according to your formula stoploss and take profit are equal to the opening price of an order, which is IMPOSSIBLE. Do you have any other solutions (can you use your brain??? :))?
Good day!!! Can't find a pretty solution to the situation. Here is a typical order setting. But if I give zero to my robot in parameters, i.e. no stops and takeprofits, nothing will work.
We can also set an if and enter an order with zeros for the second time, but it is a bit cumbersome.
...you're wrong (you haven't given the man a chance): if a man doesn't stimulate his grey matter, he'll spend his whole life "on the porch" - "Give me a hint, for Christ's sake!" :)))
Well this way it selects orders according to given parameters.
e.g. https://www. mql5.com/ru/forum/131859/page3#434221
Function NumberOfPositions().
This function returns the number of open positions at the moment. A more accurate selection of positions to be counted is specified by external parameters:
looked at
ModifyOrder() function. https://forum.mql4.com/ru/38949#434195
there are 3 parameters that need to be entered. Two I guessed, the third one I didn't.
What is UseSound on the next line?
----------------------------------------------------
if (UseSound) PlaySound("alert.wav"); break;
I would have let it work - I have one position and one tool.
But it doesn't work!
It says there's an error in the code
to this.
---------------------------
int start()
{
//----
if OrdersTotal()>0
PlaySound ("alert.wav");
//----
return(0);
}
-----------------------------
gives up 8 errors!!!
Put the condition (the one after if) in parentheses
You've got it all mature - at an art level!!! ;)
And seriously - learn to think about what you have just written. If we set zero STOPPs according to your formula, stop loss and take profit are equal to the opening price of an order, which is UNACCEPTABLE. Do you have any other solutions (can you use your brain??? :))?
:))) oops, may I also clarify the following point in "pan-European"?
What is the difference between start and void functions?
...you're wrong: if a person doesn't stimulate his grey matter, he will spend his whole life "on the porch" - "Give me a hint, for Christ's sake!" :)))
You're probably right but it's my philosophy in life - if it's not too much trouble, help others and they will help you when you need it. At 55, it's hard to change habits.
P.S. This is also how I learn.