how intercept position value change? ... OnPositionChanged()

Questions about MultiCharts .NET and user contributed studies.
Smarty
Posts: 31
Joined: 05 Nov 2013
Has thanked: 11 times
Been thanked: 1 time

how intercept position value change? ... OnPositionChanged()

Postby Smarty » 13 Jan 2014

Could you please let me know how to intercept the change positions for a strategy?

Using Position [1]. ClosedTrades I can access previous positions, it works when I close a position, but this is not enough when there is a change in the number of contracts.

Using Currentposition.ClosedTrades know how many trades are open but I can not determine the time at which this change occurs.

I need a kind of OnPositionChanged ().....

Many Thanks for attention and regards.

Sabino.

p.s:
errore.png
should be 90 and not 50 right?
(60.9 KiB) Downloaded 544 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: how intercept position value change? ... OnPositionChang

Postby Henry MultiСharts » 14 Jan 2014

Hello Sabino,

We don't have this exact event, but the same functionality can be accessed using TradeManager events. Please refer to the following sample code.

Smarty
Posts: 31
Joined: 05 Nov 2013
Has thanked: 11 times
Been thanked: 1 time

Re: how intercept position value change? ... OnPositionChang

Postby Smarty » 14 Jan 2014

Thanks for fast response.

I know that the OnPositionChanged() event does not exist, but due to its great utility I needs to rebuild it ...

however... If I'm not mistaken I can not use TradeManager in backtest mode, correct?

Regards, Sabino

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: how intercept position value change? ... OnPositionChang

Postby Henry MultiСharts » 14 Jan 2014

In backtesting you can keep the OpenLots value in a variable, when variable value changes you can get the closing time of the previous bar to get the time when the position value has changed.


Return to “MultiCharts .NET”