I’ve been using ClosePosition() for positions closing. And this method refers to Position object. But it looks like I can close positions with PlaceTrade() method too, can I?
TransactionType.Cover and TransactionType.Sell are here for this purposes, I guess? But how does it work if no references to a Position object. All positions of the appropriate direction are closed with the single PlaceTrader() or what?
TransactionType.Cover and TransactionType.Sell are here for this purposes, I guess? But how does it work if no references to a Position object. All positions of the appropriate direction are closed with the single PlaceTrader() or what?
Rename
It closes the last Position opened for the bars object.
And, consecutive calls will keeps closing Positions from last to first opened.
Example -
And, consecutive calls will keeps closing Positions from last to first opened.
Example -
CODE:
for (int i = 13; i < 20; i++) { if (idx == bars.Count - i) PlaceTrade(bars, TransactionType.Buy, OrderType.Market); } //close them all on the last bar if (idx == bars.Count - 2) for (int i = 0; i < OpenPositions.Count; i++) { PlaceTrade(bars, TransactionType.Sell, OrderType.Market); }
Thanks a lot!
Your Response
Post
Edit Post
Login is required