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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X