I'm relatively new to NinjaScript, but I have coded before in C# so I know the basics. What I am trying to create is a certain strategy that allows me to go short and long at the same time. If I understood correctly, the only way to do this is to us the Unmanaged approach. For now, my strategy only runs on 1 data serie. Currently, what I do is the following:
Open Sell Position:
v_OpenOrders[0] = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.Market, Convert.ToInt32(v_LotIncrement[0]));
Open Buy Position:
v_OpenOrders[0] = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, Convert.ToInt32(v_LotIncrement[0]));
WHERE >>> v_OpenOrders[] is an Order[] and v_LotIncrement[] a double[] that contains a predefined set of volumes.
After a while I might have executed orders (and thus open position=) like
1000 Long at 1.1300
2000 Short as 1.1250
3000 Long at 1.1280
First of all, am I correct to say that:
- PositionAccount.AveragePrice will give me the BreakEvenPrice level. In other words, it is the average weighted price of all my orders?
- How do I close all orders at once by Mar****rder? I saved the orders in the v_OpenOrders array.
- How do I know in the end, after all orders are closed what was my eventually realized PNL?
Thanks a lot in advance
Paulito
Comment