Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jon17, Today, 04:33 PM
    0 responses
    1 view
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    4 views
    0 likes
    Last Post Javierw.ok  
    Started by timmbbo, Today, 08:59 AM
    2 responses
    10 views
    0 likes
    Last Post bltdavid  
    Started by alifarahani, Today, 09:40 AM
    6 responses
    40 views
    0 likes
    Last Post alifarahani  
    Started by Waxavi, Today, 02:10 AM
    1 response
    19 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X