Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MarketPosition?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    MarketPosition?

    Is the MarketPosition attribute correct? When I execute this code:

    Print("Pre Position is: " + Position.MarketPosition);
    EnterShort(1);
    Print("Enter Short Order Position is: " + Position.MarketPosition);

    the output is:

    Pre Position is: Flat
    Enter Short Order Position is: Flat


    With the code:

    Print("Pre Position is: " + Position.MarketPosition);
    EnterLong(1);
    Print("Enter Long Order Position is: " + Position.MarketPosition);

    the output is:

    Pre Position is: Flat
    Enter Long Order Position is: Flat

    Why does it say flat after order execution? Thanks

    #2
    Hello timmbbo,

    Thanks for your post.

    You are seeing those results because the order is processed as an asynchronous event meaning that the order is sent to the exchange and processed while the strategy continues to run OnBarUpdate(). The method OnPositionUpdate() is called when a position managed by the strategy changes state. Once the order has reached a "filled" state then Position.MarketPosition would reflect that status of long or short.

    Orders sent to the exchange do take some time to be processed including being filled and then that information is sent back to your strategy. If you are testing on sim101 the orders are not actually transmitted or filled by the exchange but instead by the simulator within your PC. The simulator has a delay built in to simulate the order process events (you can get an idea of this by going to Tools>Options>Simulator and observing the times set for comm and exchange delay).

    After you have placed your order, you would want to test Position.MarketPosition as that will be the confirmation that the entry order has filled and that the strategy position is now set. Reference: http://ninjatrader.com/support/helpG...etposition.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    51 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    142 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    275 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X