Position ClosingTime
Position ClosingTime
21 Apr 2015, 19:06
Intellisense does not show ClosingTime for the opened.Position or closed.Position objects. It is available on the history tab of the trade.
Replies
c.ostmo
06 Apr 2017, 15:51
RE:
I keep getting this error: Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object. My question for reference: /forum/cbot-support/11446
Am I missing something? My code is similar to yours and I even replaced it, but I'm getting the same error. What commonly causes this?
Spotware said:
Dear Trader,
An open position doesn’t have a closing time therefore we do not provide ClosingTime. Once the position is closed it will be removed from the Positions list. In the History tab it is available because it shows the time that a position was closed. The following code snippet shows how to retrieve the closing time of a closed position, which is considered a historical trade:
ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "mylabel"); ClosePosition(Positions.Find("mylabel")); HistoricalTrade hist = History.FindLast("mylabel"); Print("Position closed at: ", hist.ClosingTime.ToString());We hope this helps you.
@c.ostmo
Spotware
24 Jun 2015, 15:55
Dear Trader,
An open position doesn’t have a closing time therefore we do not provide ClosingTime. Once the position is closed it will be removed from the Positions list. In the History tab it is available because it shows the time that a position was closed. The following code snippet shows how to retrieve the closing time of a closed position, which is considered a historical trade:
We hope this helps you.
@Spotware