to my NT7 log file, and I've noticed something that strikes me as
a bit odd, perhaps even a bug.
Why does the IExecution.MarketPosition property sometimes differ
from the IPosition.MarketPosition?
Basically, as shown in this annotated screenshot of my NT7
log file (populated with results from running a strategy called
XXX_20 on Sim101), lines 36 and 44 (stamped with red 1 and
2, respectively) are printed into NT7 log by NinjaTrader itself.
But I recognize these 2 lines with red dots as the string from
IExecution.ToString(), see here,
IPosition also supports ToString(), see here
As you can see from the help guide, both IExecution and IPosition
contain a MarketPosition property. It looks to me like IExecution's
MarketPosition gets out of sync, as witnessed by attached log file.
Explanation of log file:
The strategy XXX_20 was trading a long position, entered 2 orders
long, and then submitted a stop and target for each order when they
were filled in OnExecution.
In the attached screenshot, you can see at line 31 the stop was moved
for the 2nd order.
But my comment is about when the stop orders are filled, which occurs
at lines 36 & 44. I added red dots to those lines.
Look at the "position=" reported at red dot #1 and red dot #2 ...
They should say "long", not "short".
Notice how all the other positions being reported by IPosition.ToString()
and IExecution.ToString() correctly report position is "long".
So why does IExecution.MarketPosition report "short" at the red dots?
Looks like a bug to me.
Comment