[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 589
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
Because these are local variables that already on the second tick store rubbish instead of ticket
Thank you very much! Honestly thought about it all the time!
See trailer. Place its contents in the Experts folder of the terminal. Select the timeframe of the instrument you are interested in and place it on the chart of the Expert Advisor,
Set parameters for opening an order in MetaTrader external variables:
Then you wait for the formation of a new bar on the selected timeframe of the instrument.
When the Expert Advisor opens an order from the market, compare the time of its opening with the time of opening a new bar.
Roman, as promised, I want to show you what happens in practice when working with the Expert Advisor on the "open at the opening". First, the EA is triggered on the next tick after placing it on the 1-hour chart and opens a second trade at the opening of the next candle. Why, I cannot yet understand. Secondly, the opening price of the deal does not coincide with the opening price of a new candle:
2012.02.24,12:00,1.3392,1.3405,1.3383,1.3387,768 - the candle opens at 1.3392 and the order is triggered at 1.3390. I specify a slippage of 1 point in the settings. If I were to enter 0 pips, the EA would not trigger at all.
I attached the log. The important thing for me is still that the opening order coincided with the opening price of the candlestick.
Hello, gentlemen. I would appreciate a clarification.
Am I correct to understand that if in the code the OrderDelete and OrderSend commands are written sequentially and if the EA receives a signal to execute both commands (withdrawal + setting) on tick #1, then:
- these two commands cannot be executed on the same tick #1, and their execution is stretched by at least 3 ticks, and
- on tick #1 the OrderDelete command is issued;
- after OrderDelete has been submitted, only with the next tick #2 the result is returned, and only now on the same tick #2 can the OrderSend command be submitted;
- the result of the OrderSend command will only be known on tick #3.
Is this the case?
And is it true that there is no possibility to send two commands to MT on the same tick?
I am writing an EA in MT4.
Thank you.
Hello, gentlemen. I would appreciate a clarification.
Am I correct to understand that if in the code the OrderDelete and OrderSend commands are written sequentially and if the EA receives a signal to execute both commands (withdrawal + setting) on tick #1, then:
- these two commands cannot be executed on the same tick #1, and their execution is stretched by at least 3 ticks, and
- on tick #1 the OrderDelete command is issued;
- after OrderDelete has been submitted, only with the next tick #2 the result is returned, and only now on the same tick #2 can the OrderSend command be submitted;
- the result of the OrderSend command will only be known on tick #3.
Is this the case?
And is it true that there is no possibility to send two commands to MT on the same tick?
I am writing an EA in MT4.
Thank you.
A tick is a new quote. And there is no connection between the OrderDelete and OrderSend commands
If there is news updates and slippage, then by the time a simple OrderSend is executed, a dozen ticks will have passed. And if the market is in a nighttime flat, both commands may be executed within one tick
There may also be a collision when, for example, one order triggers a stoploss and you try to open/close another order on the same tick. Then the server may, in some cases, not allow you to execute the operation.
I.e. the answer to your questions is no, it's not))
A tick is a new quote. And there is no connection with OrderDelete and OrderSend commands execution time
If there's news updates and slippage, by the time a simple OrderSend is executed, a dozen ticks have passed. And if the market is in a night-time flat, then both commands may be executed within one tick.
MT, as far as I understand, is pulling information from server via ticking (and server, in its turn, is giving answers on commands simultaneously with sending new ticks, it optimizes costs by time). And before a new tick arrives, nothing is known. That's what I meant. But maybe I'm wrong in that assumption? The question has more to do with the second option you mentioned, when the tick is slow, rather than a dozen ticks.
Did I understand you correctly, thus, that getting a response on command #1 is not a prerequisite to go to command #2 and process it completely?
The command response is the "non-essential" part of the command? Is its presence not critical to move on to the next command?
We got into a discussion with alsu below, and I think I assumed the same as he did: that having a response is critical. You, however, write that two commands can be executed on a single tick. So the information from the server comes with no connection to the quote flow at all?
Thank you.
It all depends on how fast the ticks go. Generally functions, which return a value, OrderDelete, OrderSend etc. are not executed asynchronously, i.e. until the entire operation is passed and an error code is returned (or NO_ERROR in case of success), the next operator will not be executed. Another thing is that several ticks may run during this time, but they will not be processed by the start() function.
There may also be a collision when, for example, one order triggers a stoploss and you try to open/close another order on the same tick. Then the server may, in some cases, not allow you to execute the operation.
I.e. the answer to your questions is no, it is not))
How is it not so, if it turns out to be exactly "so", according to your own words? )) Or am I misunderstanding something again? In reply you write that functions are executed in such a way that the next operator is executed only after the previous operator's error code is processed. I think that's what I meant: that "two commands can't be executed on the same tick #1", because the response - that response or error code - appears earliest with the new tick. Or doesn't it? Or do the command responses go in a separate timed stream, unrelated to the quote stream? Perhaps my mistake was in assuming that command execution results are returned with a new quote?
Of course, I was referring primarily to the situation where the ticks are slow.
The MT, as far as I understand, pulls information from the potikovo server (and the server, in turn, gives command responses at the same time as sending new ticks, this optimises time costs). And before a new tick arrives, nothing is known. That's what I meant. But maybe I'm wrong in that assumption? The question has more to do with the second option you mentioned, when the tick is slow, rather than a dozen ticks.
Did I understand you correctly, thus, that getting a response on command #1 is not a prerequisite to go to command #2 and process it completely?
The command response is the "non-essential" part of the command? Is its presence not critical to move on to the next command?
We got into a discussion with alsu below, and I think I assumed the same as he did: that having a response is critical. You do write that two commands can be executed on a single tick. So the information from the server comes with no connection to the quote flow at all?
Thank you.
Hello. I am not good at programming at all. I am not so experienced in coding, so please help me to add closing positions byStopLoss and TrailingStop to my code. The Expert Advisor is not mine, but the strategy is not bad, so trial and error reworking the EA for me - and to be honest, I`m already blowing my mind, and there is not much time - work. I have already tried and tested it and, frankly, I have no time for it - work. And here is what I do with it: