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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X