- Home
- Forum
- cTrader News & Announcements
- New Trading API
New Trading API
- ← Previous
- 1
- 2 (current)
- 3
- Next →
New Trading API
that is correct, meant to say that there is NO variable named "positions" and that that the function ClosePosition should use the variable "position"
it was just a type-o, I wanted clarified
Should not OnError() virtual method be marked as [Obsolete]?
As it is not possible to deduce which API call caused the error?
RE:
AlexanderRC said:
Should not OnError() virtual method be marked as [Obsolete]?
OnError is not obsolete, it handles errors from both API approaches.
As it is not possible to deduce which API call caused the error?
No, it is not possible. We plan to add TradeOperation to TradeResult in the future.
When I use Trade.Executing it gives a warning that this is obsolete.
What is the new way to get this functionality
RE:
lec0456 said:
When I use Trade.Executing it gives a warning that this is obsolete.
What is the new way to get this functionality
If you use synchronous methods like ExecuteMarketOrder, ClosePosition, etc., there is no need to check the executing property. If you use asynchronous methods like ExecuteMarketOrderAsync, ClosePositionAsync, etc., you can check IsExecuting property of TradeOperation object:
var operation = ExecuteMarketOrderAsync(...); ... RefreshData(); if (operation.IsExecuting) ...
Hi
So:
OnPositionClosed - Only handles positions opened by this instance of this bot
OnPositionsClosed - Handles any and all positions on your account
Correct?
What if I stop the bot and start it again later with trades opened by the previous version still in the system?
What about stop and limit orders placed by this instance of this bot? It seems to me they aren't included in OnPositionClosed when they close and I have to manipulate the comment and label fields to keep my bot running on only its own trades.
Is there any thought to including positions opened by stop and limit orders in the OnPositionOpened and OnPositionClosed methods?
I often want to use the comment and labels for other things and I can't edit those while a trade is open so its tricky (I seem to have lots of code manipulating, concatenating and splitting strings so I can see exactly what my bots are doing. One day when I am an expert coder I'll have more confidence.)
Thanks for a great product. Keep up the excellent work.
Dear Trader,
OnPositionClosed is obsolete therefore we do not recommend it. The old API is also obsolete and we do not recommend the use of it.
We recommend you to subscribe a method to the Positions.Closed event which is called each time a position closes. You can filter the positions closed based on some label filter.
@Spotware kindly comment on when partial closure will be available in Backtest, very important feature for me.
- ← Previous
- 1
- 2 (current)
- 3
- Next →