First, I have some knowledge of coding, so, I'm not a fresh beginner, even if sometimes like now, I feel like one, hahaha. As the Strategy Builder offers limited way to calculate things, I had no choice to unlock a code to do what I had in mind, supported by the Strategy Builder.
I'm almost done with my code but there is a problem I havent resolved yet.
FYI:
- I work in 1 minute chart
- My strategy is based on different indicators and my code is filled with calculation
- The Strategy setup is done on calculation at bar close
Here's my problem: When a signal is triggered, the strategy immediately create the resulting order but refuse to create the opposite order at the same time (Buy/Sell limit or Sell/Buy limit). This opposite order is only created 1 minute later (because of the calculation on bar close). You understand than in this minute, this opposite order can be reached and because of that, I miss the train.
I first worked with the position.AveragePrice command but I realized the order is not filled when the code line is read. I changed it to set up an order based on open[0] but it doesnt work either, even with Close[1].
Here's the code I tried without success.
ExitLongStopLimit(Convert.ToInt32(2), (Close[1] + (25 * TickSize)) , 0, @"LongExit", @"LongEntry");
This line is in the same group of code as the BUY order that is working fine. I only have problem to set the sell limit order at the same time of the Buy.
Here's the code working but 1 minute after the triggered order:
ExitLongLimit(Convert.ToInt32(Position.Quantity), (Position.AveragePrice + (25 * TickSize)) , @"ExitLong", @"LongEntry");
This line is in another group of code that is triggered by this code: if ((Position.Quantity != 0)...
I think everything is there.
Thanks in advance for the follow up.
Comment