New Trading API

lec0456's avatar

lec0456 since: 14 Nov 2012;

  31 Dec 2013, 08:33
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

AlexanderRC's avatar

AlexanderRC since: 04 Feb 2014;

  05 Nov 2014, 00:40

Should not OnError() virtual method be marked as [Obsolete]?

As it is not possible to deduce which API call caused the error?

Romanov Capital -- NDD STP broker \\\ https://en.romanovcapital.com \\\ Custom Robot and Indicator development \\\ email: calgo(at)romanovcapital.com
Spotware's avatar

Spotware since: 23 Sep 2013;

  05 Nov 2014, 14:09
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.

TRADERS FIRST™ Vote for your favorite features: https://ctrader.com/forum/suggestions
lec0456's avatar

lec0456 since: 14 Nov 2012;

  05 Mar 2015, 04:34

When I use Trade.Executing it gives a warning that this is obsolete.

What is the new way to get this functionality

Spotware's avatar

Spotware since: 23 Sep 2013;

  05 Mar 2015, 11:28
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)
              ...
TRADERS FIRST™ Vote for your favorite features: https://ctrader.com/forum/suggestions

RhettG since: 10 Sep 2014;

  03 Jul 2015, 13:56

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.

Spotware's avatar

Spotware since: 23 Sep 2013;

  07 Jul 2015, 12:07

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.

TRADERS FIRST™ Vote for your favorite features: https://ctrader.com/forum/suggestions

psossa.mobile since: 29 Apr 2016;

  29 Apr 2016, 01:20
RE: RE:

This post was removed by moderator.

greybox since: 23 Feb 2016;

  08 May 2016, 12:01

When will Partial Closure work in Backtest??

greybox since: 23 Feb 2016;

  11 May 2016, 04:34

@Spotware kindly comment on when partial closure will be available in Backtest, very important feature for me.