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
Karputov Vladimir And simplify OnTradeTransaction()- consider only adding a trade to the history - no orders
You'll be fine, don't even bother writing it (don't waste your time).
I started to look into it because the real one was crashing.
It looks like they upgraded the server over the weekend. Milliseconds came up. There may be more surprises.
Apparently,OnTradeTransaction function works independently from the transaction log.
I think this behavior of the function is reasonable - there is no need to slow down the flow of operations and wait until the log is written and everything is calculated.
In your case, it would probably be better to useOnTrade,
or wait and periodically check with a minimum pause when the deal appears in the history.
Looks like they upgraded the server at the weekend. Milliseconds appeared. There may be more surprises.
ApparentlyOnTradeTransaction function works independently from operation log.
I think this behavior of the function is justified - there is no need to slow down the operation flow and wait until everything is registered and counted in the journal.
In your case, it would probably be better to useOnTrade,
or wait and periodically check with a minimum pause when the deal appears in the history.
Hi Sergei!
Yes we did, but not at the weekend, but on Thursday after the evening session (asked my broker).
I can't use the Trade() event and wait for the data to update in the terminal.
The Expert Advisor was written long ago and until recently it worked "like clockwork" (maybe I was lucky andTRADE_TRANSACTION_DEAL_ADD event wasalways the first to arrive).
It is important for the Expert Advisor to execute a reciprocal trade as soon as possible, that's why the asynchronous mode and OnTradeTransaction().
Now, the Expert Advisor (sometimes) sends duplicate orders to open and close positions.
You: "I think this behavior of the function is justified. There is no need to slow down the flow of operations and wait for everything to be written and counted in the journal".
Anyway, everything is being written and counted afterTRADE_TRANSACTION_DEAL_ADD arrives:)
The thing is thatTRADE_TRANSACTION_DEAL_ADD may be lost andTRADE_TRANSACTION_HISTORY_ADD may come and then the terminal will have outdated position data.:(,
which actually happens.
It's strange that developers didn't think about it.
TRADE_TRANSACTION_HISTORY_ADD only comes if the order has been executed or deleted (cancelled), therefore
if the order state changes (respectively, the position can change), the terminal should receive the information about the position change,
even ifTRADE_TRANSACTION_DEAL_ADD is lost
Let us see what the developers have to say.
Karputov Vladimir And simplify OnTradeTransaction() - consider only adding a trade to the history - no orders
You'll be fine, don't even bother writing it (don't waste your time).
Please ask "teachers" and "know-it-alls" to speak on substance,
and not just to put their foot up at the post to make a point.
Before showing off to people who want to help you, you should formulate your question normally. What does asynchronous sending of an order have to do with it, if partial closing is performed by the OrderSend() function? What are you asking questions about?
Great!
Should that be seen as help?
And Karputov has nothing to do with it, it's just that when I wrote my post he had already posted his and I didn't see it.
Initially, the question was posed as follows (in case you're too lazy to read it first)
How to build logging to show developers the error?
Why, I did it myself and the logs clearly show that
afterTRADE_TRANSACTION_HISTORY_ADD (beforeTRADE_TRANSACTION_DEAL_ADD)
the terminal does not update the position information.
prostotrader, Dimitri correctly tells you that partial (and full) closures are not asynchronous in your code, but synchronous... which means the program is waiting for a response from the server...
It's likely that OnTradeTransaction is triggered faster than the position itself changes.
Then here:
you could try looping the position check. Maybe it will help....
It's something like this:
Without knowing the exact algorithm(TH AT you need from the program), it's hard to assess the correctness of its implementation...
Changed completely to asynchronous mode
But nothing has changed
It was obvious, but "for the sake of purity" of the experiment...
Full logs in the basement
1. >Without knowing the exact algorithm (THAT you need from the program), it's hard to assess whether it's implemented correctly...
Thought it wasn't hard to understand what the program does, well if it's not clear, then
An Expert Advisor opens a position in the FORTS market with a volume of 2 contracts; if the position is opened, it is partially closed with a volume of 1 contract,
then the position will be closed completely. Repeat this procedure until the counter tr_cnt<50
2. You can "run" PositionSelect() a million times - it won't change anything, because
theTRADE_TRANSACTION_DEAL_ADD eventwill not be received until you are in the loop, and therefore, the terminal will not update
position information
...
I said above - don't get carried away with orders: look at the transactions. Here's a short code that shows WHEN the position volume changes and what type of transaction it is:
And here are the prints, at partial close:
You can clearly see that as soon as an event with the trade transaction typeTRADE_TRANSACTION_DEAL_ADD has passed, that's it, the position data in the terminal is updated.