- ago
I have a question regarding transaction quantity. I am trying to manually calculate the # of shares for three separate buy orders. This code appears to work when two transactions are placed but when adding three the third quantity is never calculated properly. Any suggestions? Is there a better way to do this? I am planning on adding more variables that the advanced possizers don't currently have.

CODE:
   t = PlaceTrade(stock1, TransactionType.Buy, OrderType.Market, 0, "Buy" + stock1);                t.Quantity = (CurrentEquity / close1[idx]) / 5;                t1 = PlaceTrade(stock2, TransactionType.Buy, OrderType.Market, 0, "Buy" + stock2);                t1.Quantity = (CurrentEquity / close2[idx]) / 5;                t2 = PlaceTrade(stock3, TransactionType.Buy, OrderType.Market, 0, "Buy" + stock3);                t2.Quantity = (CurrentEquity / close3[idx]) - t1.Quantity - t2.Quantity;             
0
924
Solved
3 Replies

Reply

Bookmark

Sort
- ago
#1
Could you give more detail about what's wrong with the calculation? Like show an example.
0
- ago
#2
I don't understand the goal of the calculation. Wouldn't you want to distribute the dollar value (and not the Quantity) equally among positions? If so, wouldn't you be dividing the CurrentEquity by 5 rather than the Quantity?

I would want the balance the "dollar value" invested across positions, but the calculation given seems to want to balance Quantity of shares across positions instead. Why are you doing that?
0
Best Answer
Cone8
 ( 4.98% )
- ago
#3
And that's even assuming too much - we don't even know what close1, close2, and close3 are!
0

Reply

Bookmark

Sort