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

Best way to determine market position?

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

    Best way to determine market position?

    What is the best way to determine and save current market position from within a strategy? Suppose in my strategy class I have a protected varaible:

    protected MarketPosition currentMarketPosition;

    Then it looks like I have several options:

    1. in OnBarUpdate I can use

    this.currentMarketPosition = Position.MarketPosition;

    2. Or, i can implement OnPositionUpdate. I think (but I'm not sure) that OnPositionUpdate passes the current market position in:

    protected override void OnPositionUpdate(Cbi.Position position, double averagePrice, int quantity, MarketPosition marketPosition)
    {
    this.currentMarketPosition = marketPosition;
    }

    Is there any advantage or disadvantage of using either of these? Is my understanding correct that both will work?

    #2
    Hello westofpluto,

    Thank you for your post.

    Position contains position-related information pertaining to a strategy and already holds the current market position in .MarketPosition. That being said, it is not necessary to save the current market position to a variable since we can access the strategy's current market position by calling Position.MarketPosition.

    I have attached a help guide link below for more information.

    Position - https://ninjatrader.com/de/support/h.../?position.htm

    OnPositionUpdate is driven by Position update events and updates the account position (PositionAccount). OnPositionUpdate should not necessarily be considered for a change in strategy position. if you would like to get the current position of an account, you may use AccountPosition.MarketPosition.

    Here is a help guide link for more information.

    PositionAccount - https://ninjatrader.com/de/support/h...ionaccount.htm

    OnExecutionUpdate is driven by Execution events and updates the strategy position (Position). If you want to get the current market position of a strategy the moment an order is filled you could call Position.MarketPosition in OnExecutionUpdate.

    Please review the help guide link below for more information about OnExecutionUpdate.

    OnExecutionUpdate - https://ninjatrader.com/support/help...tionupdate.htm

    Please let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rocketman7, Today, 02:12 AM
    2 responses
    16 views
    0 likes
    Last Post rocketman7  
    Started by briansaul, Today, 05:31 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by PaulMohn, Today, 03:49 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by frslvr, 04-11-2024, 07:26 AM
    6 responses
    106 views
    1 like
    Last Post NinjaTrader_BrandonH  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    6 responses
    26 views
    0 likes
    Last Post trilliantrader  
    Working...
    X