How do I open a market order correctly? - page 6

 
Gennady Mazur:

You were correctly advised about the pause. There was already a topic on the forum that a pause of several milliseconds after sending the order is often enough to continue working with the position. You'd better not rely on OnTradeTransaction() if it is possible.

And in general, to be more reliable, try to check if there is a position after the order is sent on the next tick. If there is a position, do not send more orders.

 
Alexey Kozitsyn:

OnTradeTransaction(), if possible, is not to be relied upon.


I wonder why?
 
prostotrader:
I wonder why?

1. It is not certain that it will come;

2. Misbehaved before in the tester. Don't know now;

Added:

3. Some order or transaction parameters (can't remember exactly) like enumeration can have "default values" that are not. I.e. MQ made not WRONG_VALUE but, for example, ORDER_TYPE_BUY. Could be misleading;

 
Alexey Kozitsyn:

You were correctly advised about the pause. There was already a topic on the forum that a pause of several milliseconds after sending the order is often enough to continue working with the position. You'd better not rely on OnTradeTransaction() if it is possible.

And in general, to be more reliable, try to check the position availability on the next tick after the order is sent. If there is a position, do not send more orders.

In principle, I do so, but in Forts an order is often accepted successfully... but there is no position on the next tick.
This is where the additional opening may slip through .... partially solving the issue as follows, if the order is accepted, I increase the Int variable, and after the increase the conditions for opening are slightly different, so a new opening does not happen, but.... if the order is not accepted the variable does not increase, and here is the tricky part... I have not correctly identified the state and extra orders are coming in.
 
Alexey Kozitsyn:

1. It is not certain that it will come;

2. Misbehaved before in the tester. Don't know now;

You probably didn't see the message from the developers that now, OnTradeTransaction() is guaranteed.

Кроме того, транзакции могут потеряться при доставке от сервера к терминалу.
Что касается этой фразы.

Судя по всему - она осталась из документации к одной из начальных версий терминала с асинхронной торговли. В ближайшее время уберём. Виновные будут расстреляны.

How many seconds to pause? 1 sec 2, maybe 10?

2016.12.14 22:01:41.371 Trades  'xxxxx': cancel order #49932961 buy limit 1.00 CHMF-6.17 at 92501 placed for execution in 64873.549 ms

Added

Don't forget that you are working with a CUSTOMER - SERVER (request-response) application

 
prostotrader:

You probably haven't seen the message from the developers that now, OnTradeTransaction() is guaranteed.

Кроме того, транзакции могут потеряться при доставке от сервера к терминалу.
Что касается этой фразы.

Судя по всему - она осталась из документации к одной из начальных версий терминала с асинхронной торговли. В ближайшее время уберём. Виновные будут расстреляны.

How long should we pause for? 1sec 2, maybe 10?

2016.12.14 22:01:41.371 Trades  'xxxxx': cancel order #49932961 buy limit 1.00 CHMF-6.17 at 92501 placed for execution in 64873.549 ms

Yes, you're right, didn't see the phrase, neither did the corpses :)

About the pause - you gave a rather exotic case, however, of course, it's possible. I meant the case for working with liquid instruments, current contracts and for working on the current tick immediately after sending the order. In the great majority of cases several milliseconds are enough. And, of course, after the pause, it is necessary to check the presence of a position for further work with it.

 
Gennady Mazur:
In principle I do so, but in Forts the order is often accepted successfully...but on the next tick there is no position yet...
This is where the additional opening may slip .... partially solve the problem this way, if the order is accepted, I increase the int variable, and after the increase the conditions for opening are slightly different, so a new opening does not happen, but.... if the order is not accepted the variable does not increase, but here is the trick... I misjudged the state and extra orders started to appear.
In any unclear case, as already suggested, use advanced logging, not just a yes/no return. Especially at the development stage.
 
Alexey Kozitsyn:

Yes, you're right, I didn't see the phrase, and neither did the corpses:)

About the pause - you gave a rather exotic case, however, of course, it is possible. I meant the case for working with liquid instruments, current contracts and for working on the current tick right after order sending. In the great majority of cases several milliseconds are enough. And, of course, after the pause, it is necessary to check the presence of a position for further work with it.

Alexey!

Quite a liquid instrument :)

2016.12.14 22:01:41.431 Trades  'xxxxx': cancel order #49931802 sell limit 1.00 GOLD-9.17 at 1190.2 placed for execution in 64926.078 ms

It's not about instrument (liquidity), it's about delay, which can occur in ANY instrument.

I've been actively trading using EAs for almost 4 years now.

In none of my EAs there are any pauses (Except pause while waiting for data to be downloaded from server in INDICATORS),

If you pause, it's a sure sign that your EA didn't do it right :(

 
prostotrader:

Alexey!

I've been actively trading with EAs for almost 4 years now.

I don't have any pauses in any of my EAs (except pause for waiting for data to be downloaded from server in INDICATORS),

If you're entering a pause, it's a TRUE sign that you've wrongly created your EA's algorithm :(

Michael, if you haven't seen or done something, it doesn't mean it's not possible or not needed.
 
Alexey Kozitsyn:
Michael, if you have not seen or done something, it does not mean that it is impossible or unnecessary.

I completely agree with you!

Everyone does as they want or as they can.

Reason: