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

 
rigonich:


In practice this is used in all ops that work with orders. You must first select an order and then do something with it (view order information, send a trade order to the server to modify or close it) There are two ways to select orders in the terminal, by ticket, which is the number assigned to the order on the server that does not change for a particular order, or by the order number (index) under which the order is stored in the terminal. This number may change on every tick, depending on what and how many orders are opened, set, closed or deleted.

To work with orders, there are cycles of order evaluation.


Well, for example, I have a limit order at the opening of D1. TP and SL may not work for some days, if we check for an order, it will be available and we won't open a new one. So it is not good. Thus, potential trades will be missed.
 
hoz:

Well, for example, I have a limit order on opening D1. TP and SL may not work for a few days, if we check for an order... it will be available and we will not open a new one. So it is not good. Thus, potential trades will be missed.

Then check the opening times of all orders, and look to see if there is one open today.
 
rigonich:
The first option can be used with minimal changes (look for the history and what you need), and about the second, why are you so bent on it? That it does not open more than one trade a day?

I need to know the exact time of the last trade opened yesterday (which of course will be closed by the next day - but when exactly is irrelevant - may be right away, and may be early morning today) to let the Expert Advisor know that yesterday's trade does NOT affect today's one - that's why I have planned it that way.

But today's closed trade MUST affect today's open trade.

i.e., the Expert Advisor should distinguish yesterday's trade from today's one when it is opened in the morning. And this can be done only by comparing the OPEN time.

 
rigonich:


It will be.

Or rather, it will be, but it will be open, not closed


how to get the opening time of the last trade yesterday ?
 
rigonich:


It will be.

I mean, it will be, but it won't be closed, it will be open.


Damn right... it's clearly written there

(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

 
rigonich:
The first option can be used with minimal changes (look for the history and what you need). That it does not open more than one trade a day?


found an option.

there is this function

function isTradeToDay().

This function returns the trade flag for today. Flag is up -True- there were opened positions today. Flag down -False- no positions opened today

I only wonder - if a position is opened at 23:00 and closed at 4:00, what will this function show at 7:00 am?

 
lottamer:


there is such a function

The function isTradeToDay().


Give us a link to this function, eh? Where did you get it?
 
Equilibrium:


Thanks for the reply, but it didn't help me much, once again I lay out the problem, maybe someone else has some thoughts on this???

Good afternoon please help, I can't understand why unnecessary orders are opening ((, in the screenshot they are circled in red, code attached...


Sorry, got "bogged down". Noticed your question in the morning, wanted to answer right away, now it's night and I just came to my senses.You can see the answer to your question. It's done in the following way:

1. First, you start your EA for testing without visualization, then open a chart and save the template under your EA's name.

2. Close the chart, start the Expert Advisor in visualization mode, setting the fastest speed, because it is a 4-hour chart, and watch.

3. I think all questions will disappear.

P.S. Or print out the indicator values before placing an order and then look in the logs.

 
lottamer:


found an option.

there is this function

Function isTradeToDay().

This function returns the trade flag for today. Flag is up -True- there were opened positions today. Flag down -False- no positions opened today

But I want to know, if a deal opened at 11 PM and closed at 4 AM, what will this function show at 7 AM?


I think this function returnsTrue if the market is open andFalse if it's closed.

More precisely, I want to know if there is a function that returns the flag trades by date and forward (market timetable)

 
drknn:
Can you give me a link to this feature, please? Where did you get it?


https://forum.mql4.com/ru/38949/page4#434232
Reason: