I am trying to set my strategy to set the order quantity to a specified value of stocks.
To do this I have a variable for the value, lets say 10000 (to represent $10000).
I have another variable for order quantity.
At the beginning of my code I divide the value by the current ask to determine the correct number of stocks which I then use when EnterLong is called.
However when I backtest the strategy all trades are always 100 shares in size.
Note I have "set order quantity" to "by strategy" in the order properties.
Anyone have any ideas on what I'm doing wrong? Code below:
private double value = 10000; // Default value of shares to buy
private double Dqty; // Variable for number of shares to buy of type double
private int Iqty; // Variable for number of shares to buy of type integer
... (other code here)
//calculate number of shares to buy
Dqty = value / Ask[0];
Iqty = Convert.ToInt32(Dqty);
... (other code here)
EnterLong("Buy1", Iqty);

Comment