Latest Version Update OnPositionOpened OnPositionClosed
Latest Version Update OnPositionOpened OnPositionClosed
20 Dec 2013, 06:25
Hi,
I got the latest update of cAlgo installed and created a new robot. I am using ExecuteMarketOrder and PlaceStopOrder. For some reason neither are triggering OnPositionOpened or OnPositionClosed. I'm sure this was working fine before the update.
protected override void OnPositionOpened(Position openedPosition)
protected override void OnPositionClosed(Position closedPosition)
Any help please?
John
Replies
Spotware
30 Dec 2013, 14:35
RE: ... does not exist
Any subscribed method has to be defined.
See the examples here:
/api/reference/positionclosedeventargs
/api/reference/positionopenedeventargs
jeex said:
Positions.Closed += PositionsOnClosed;Gives the error: PositionsOnClosed does not exist...
@Spotware
Spotware
20 Dec 2013, 10:08
OnPositionOpened / OnPositionClosed will not be raised with the new API methods. Instead you can subscribe events such as in the following example.
The new API allows the use of synchronous as well as 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. Therefore, you can access position information from the result. You can also subscribe an event to be raised when the position opens.
Please read the Guide and the thread on the New Trading API for more information.
example
@Spotware