I keep having the same problem appear over and over again and I am at loss at what I'm doing wrong. Please see the attached image.
Why is it that the submitted quantity is not correct? I have used Print() to tell me what the "Position.Quantity" is and it always returns 2 when "ATP2" is Filled, yet it seems to not translate into the submitted order quantity.
This is the entry method for ATP2
if (ATP2 == null
&& Position.MarketPosition == MarketPosition.Flat
&& Close[0] > KyoriBands2(TwentyFive, Fifty, SeventyFive, Hundred).Low4[0] + 5 * TickSize
&& Close[0] < KyoriBands2(TwentyFive, Fifty, SeventyFive, Hundred).Low2[0]
&& Low[0] < KyoriBands2(TwentyFive, Fifty, SeventyFive, Hundred).Low2[0])
{
EnterLongMIT(0, true, Contracts, KyoriBands2(TwentyFive, Fifty, SeventyFive, Hundred).Low4[0], "ATP2");
}
The strange thing is that when I remove "ATP2 == null" — then the script actually does submit both orders correctly.
And taking a closer look at it while running on Simulated Data Feed over the weekend, while running with Calculate.OnPriceChange, it seems to be submitting one TP34/SL34 on the first price movement, and then the script submits the second TP34/SL34 on the second price movement. Why is this not happening together at once?
I'm looking forward to your reply, because this has been a very puzzling issue.
Edit 1:
You can see that I have a CancelOrder() for both TP34/SL34 right above where the orders are submitted, and I can tell you that this is not causing the issue because the issue has been occurring even before I had those CancelOrder()'s installed.
Edit 2:
Even using the number 2 instead of "Position.Quantity" does not work.
Edit 3:
This line of code does work correctly, Contracts is a variable
EnterShortStopMarket(0, true, Contracts, KyoriBands2(TwentyFive, Fifty, SeventyFive, Hundred).Low2[0], "AS1");
Comment