- ago
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?
0
129
2 Replies

Reply

Bookmark

Sort
Cone8
 ( 24.99% )
- ago
#1
It closes the last Position opened for the bars object.

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);             }          
2
- ago
#2
Thanks a lot!
0

Reply

Bookmark

Sort