Empty "Positions" collection
Empty "Positions" collection
25 Feb 2016, 22:37
Hi,
apparently I don't get how the Positions collection work. Running this robot on EURUSD pair prints "Positions: 0" even though the order was fullfiled and neither its TakeProfit nor its StopLoss was reached (thus the position exists).
public class Tutorial : Robot { private int orders = 0; protected override void OnTick() { if (orders == 0) { PlaceLimitOrder(TradeType.Buy, Symbol, 1000, 0.5, "buy order", 1000, 1000); orders++; } else { Print("Positions: ", Positions.Count); // always prints out "Positions: 0" } } }
Could you explain or point me towards an explanation?
Thank you,
Jaromir
Replies
Spotware
29 Feb 2016, 17:52
Dear Trader,
The Positions.Count prints zero positions because you have no open positions.
You open limit orders in the previous line. A limit order is an Order and when it's filled a Position opens.
Please have a look at the ExecuteMarketOrder, API Reference, API Programmers Guides sections of cTDN.
@Spotware
svobod8
28 Feb 2016, 22:21
RE:
Bump :), anybody?
@svobod8