Issue with new API

Created at 17 Dec 2013, 15:49
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
supafly's avatar

supafly

Joined 26.12.2012

Issue with new API
17 Dec 2013, 15:49


You have changed some of your APIs and I have updated my robots regarding the execute, modify trade commands but I have run into some issues. When it executes the positions, it does not modify the take profit and stop loss. Can you provide an example that includes the new changes to show how a trade can be modified.

Thanks


@supafly
Replies

Spotware
17 Dec 2013, 16:48

Modify position: /api/reference/robot/modifyposition-6f11

Please see also /api/guides/trading-guide


@Spotware

supafly
17 Dec 2013, 19:04

Your documentation doesn't really help me figure out the issue. Before the changes where made, a trade would be executed and then the s/l and t/p would be modified from the PositionOpen method. I have multiple buy/sell scenarios which the robot cycles through and when the criteria of one scenario is met, it executes an order and based on that scenario is uses a specific take profit and stop loss defined in the PositionOpen method.

I'm not sure how i can implement the new changes since some examples:

A. state that i must assign a traderesult variable which contains a boolean value and if that boolean value is true, then you can insert your code that modifies the order. (This though is inconvenient for me since there will be a repetition of code).

B. show this code which I have replicated and doesn't work.

protected override void OnStart()
{
ExecuteMarketOrder(TradeType.Buy, Symbol, 10000,"myLabel", 10, 10);
Positions.Opened += PositionsOnOpened;
}
private void PositionsOnOpened(PositionOpenedEventArgs args)
{
var pos = args.Position;
Print("Position opened at {0}", pos.EntryPrice);
}

 


@supafly

supafly
17 Dec 2013, 19:46

I have managed to replicate the above code and the robot seems to be working fine but I'm facing other issues. There is no restrictions in my source code on how many simulatenous positions the robot can execute. I checked the results against an older calgo using the older APIs and the only difference is that it cannot open multiple trades. Is there a new feature that restricts the amount of trades?


@supafly

Spotware
18 Dec 2013, 09:45

The new API allows the use of synchronous as well as asynchronous operation. Opening positions simultaneously requires asynchronous operation. ExecuteMarketOrder is using synchronous operation and will not continue to the next statement but will wait until the trade request response from the server is returned. 

Please read the Guide and the thread on the New Trading API for more information.

 


@Spotware