[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 579

 
rigonich:

It takes 2.5 seconds to execute it in mt 4.

Damn, that's my problem. I wonder how I can bypass it if I only need to delete the whole grid when I unload the robot... I can't even think of anything here :(
 
lottamer:

you need to insert the terms HAVE an open trade (one, without any majors) in one row, for example, with a crossover of averages.

found this

==============================================

int start()

{

for(int i=0; i<OrdersTotal(); i++)

{

if ((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) )

PlaySound ("alert.wav");

return(0);

}}

==============================================

There is an open position but no sound.

Can you tell me what's wrong?

Or how easy it is to write the condition:

IF MA 5 crosses MA 10 and there is an open position - close that position.

this seems to be where void.... is needed


See if sounds are allowed for MT in the windup, and if there are files in theSound folder.But on the bstrom market the sn will work as an alarm clock.
 
rigonich:

See if sounds are allowed for MT in the windup, and if there are files in theSound folder.But on the bstrom market the sn will work as an alarm clock.


no, well even though i'm a beginner, but i don't make such mistakes. :))

other experts are singing like nightingales! in the same terminal!

 
Desead:

Damn, that's my problem. I wonder how I can get around it if I only need to delete the whole grid when I unload the robot... I can't even think of anything here :(

place the same condition before calling deinit on the same condition you call deinit on.
 
lottamer:


No, I'm a beginner, but I don't make that kind of mistake. :))

the other experts are singing like nightingales! in the same terminal!


And if it is a script - you need to have trade permission for Expert Advisors enabled, and in the window, where you put it, there should be no other working scripts or Expert Advisors, besides it will " zing" if there are open deals on any instrument.
 
rigonich:

Place a deinit before calling the deinit by the same condition that you call deinit.


So deinit is called when I remove a robot from a 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 robots, there is no other way.

By the way, another thought on the subject:

I think I have solved the problem of deleting pending orders. I determine the amount 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 the amount of "necessary", counter of removing attempts with 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.

 
rigonich:

And if it's a script -- you need to have Expert Advisor trading permissions enabled.


this is an EA.

all permissions enabled of course (there are other EAs - they work -NOT at the same time)

there is a problem in the code. something is wrong there.....

 
Desead:

Thanks for the reply. I do not need all of them, only bylimit and selllimit, and I also put them only, the magician is also present everywhere the same. I looked the code given by you, there is so much stuff there, I sat to understand it, in general, if I can not solve the problem myself, I will have to dismantle your scripts more thoroughly, there is no other way, it does not delete and that's it (

I was thinking about something. I set the deletion of all pending robots in one place only - when I unload my robot, it will be placed in deinit. Maybe this section has some kind of time limitation? When only few orders are deleted, everything is fine, but when I unload a whole grid, then what the hell happens - about ten orders are always left and it's not an option to clean it manually.

My script uses this library. The function responsible for deleting the orders in it:

/*int fClose_AllOrders (double& fd_Pribul,         // Возвращаемый профит закрытых ордеров
                        int fi_Type = -1,          // тип закрываемых ордеров: -1 - все; -2 - рыночные; 7 - отложенные или OrderType()
                        int fi_NBars_Life = 0,     // минимальная "жизнь" ордера в барах на fi_Period: 0 - параметр не учитывается
                        int fi_Period = 0,         // Период
                        int fi_OrderProfit = 0)*/  // Идентификатор профитности ордера: > 0 - профитный; < 0 - лоссовый
                                     // Функция закрытия "своих" ордеров по признаку

You need some knowledge to rip the function out of the library, but using the whole library is quite acceptable for a newbie.

 
rigonich:

Hurrah, it seems I have solved the problem of deleting orders. I calculated the number of "necessary" (to be removed) orders in a separate function, called this function, then while with a condition (Total>0), then the cycle of removing for(int i=Total-1 ;i<=0l; i--), again, the function of counting the "necessary", counter of removal attempts with the exit fromwhile when the specified level is reached. This way, everything is deleted.
When using loops, you should ALWAYS be careful: put the iteration count and the exit condition when the EA is forbidden to trade.
 
TarasBY:
You should ALWAYS be careful when using loops: put an iteration counter and an exit condition when prohibiting the EA from trading.


Thanks for the tip. I had forgotten about the exit condition when no trade is allowed.
Reason: