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

 
trend_lab:
And in general, you throw out NewBar, look at the time of the last order opening and compare it with Time[0]. If it's higher, it's your case, you can delete everything.

Yes, I guess I will have to do it. Thanks for that :)
 
Noterday:
Man, I still don't understand how to do it. I need the code with deletion and closing of orders to be triggered only at next candlestick. But other candlesticks should open on this one too. This means the program will again get into the deletion. Some kind of flag is needed but my brain is already sweating to understand how to do it :)

Read the OrderSend() function carefully. It has a parameter for pending orders:

expiration - Срок истечения отложенного ордера.

If you open a pending order at the beginning of current day = iTime (Symbol(), PERIOD_D1, 0), then you add to this time one more day - 1440 * 60. If pending orders are not triggered, they will be deleted by themselves at the beginning of the next day.

P.S. The end of the current bar can also be controlled through function iBarShift():

    if (iBarShift (Symbol(), PERIOD_D1, OrderOpenTime()) == 0) return(0);

or any other "body movements" on this condition by tracing the OrderTicket() of the last order.

 
TarasBY:

Read the OrderSend() function carefully. It has a parameter for pending orders:

If you open a pending order at the beginning of current day = iTime (Symbol(), PERIOD_D1, 0), then you add to this time one more day - 1440 * 60. The pending orders that don't get triggered are automatically deleted at the beginning of the next day.


I read it, my DC does not seem to support it.
 
Noterday:
I read it, the DC doesn't seem to support it.
Is there such a thing?
 
Well, I guess so, or maybe it's just a problem with my terminal. I've already said in a neighbouring thread that I'm not saving reports from the Account HISTORY tab either...
 
Noterday:
Well, I guess so, or maybe it's just a problem with my terminal. I've already said in a neighbouring thread that I'm not saving reports from the Account HISTORY tab either...
Oddly enough, neither do I, although my build is 416. Although, the terminal has nothing to do with deleting pending order that didn't work when it expired - it's up to brokerage company's server.
 
hoz:

Honestly, I'm already completely confused. I don't even have any examples to see how others do it.

I understand that, apart from getting the values, you have to assign them to some other variables?


I don't need the basics. I am well aware of variable visibility. There's nothing in the textbook about passing values of variables by reference. Why are you sending me there? Are you kidding me?


No, I'm not. Your opinion of your knowledge of scope is greatly exaggerated. It's not to insult, it's just obvious that you haven't mastered the basics.

I have some time, so I will try "on my fingers": You described variables inside a function - that's where they exist. The function has completed its work and memory allocated to the variables is freed. Then reference to what you use outside the scope of variables? There can be any "rubbish" at this address. We can only be glad that the developers had far-sightedness and excluded address arithmetic. The result of the function, if we need to pass outside, is always passed by value, not by reference (i.e., we pass the value itself, not the address of the memory cell where the value is stored). There are, of course, exceptions, but not for µl4 (except when working with arrays). So, please re-read it - it won't hurt.

 
VladislavVG:

We can only rejoice at the farsightedness of the developers who eliminated address arithmetic.

But it is there, even though it is not described ...
 
valenok2003:


What about arrays?


With arrays it's not difficult: usually an array as a parameter is passed by reference from outside - inside the function, you process it inside the function and don't need to return anything - the result is obtained at once. The need to return the reference (or address) may arise if you're dynamically allocating memory for the array within a function, and describing the array itself there. Then, in order to use this array outside the function, you need to pass the address of allocated memory area outside.

It sounds scarier than it is. If it's not clear, I can give you some examples.

 
VladislavVG:


It is not complicated with arrays: usually an array as a parameter is passed by reference from outside - inside the function, you process it inside the function and do not need to return anything - the result is obtained immediately. The need to return the reference (or address) may arise if you're dynamically allocating memory for the array within a function, and describing the array itself there. Then, in order to use this array outside the function, you need to pass the address of allocated memory area outside.

It sounds scarier than it is. If you don't understand, I can give you some examples.



thanks, that's clear. i.e., if a variable or an array is described at a higher level, you can reference its address back and forth as much as you want.
Reason: