Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy runtime context

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

    strategy runtime context

    Hello all,

    I have a strategy that uses the following objects for its logic.

    Position.MarketPosition
    Performance.AllTrades
    Position.GetProfitLoss
    Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit

    I am running two instances of the strategy in parallel - each with different parameters.
    My question is about the context of the Position and Peformance objects. Are they for the strategy I am running?

    For example, will Position.MarketPosition return the current position of the current instance of the strategy or the overall account position?

    Onn

    #2
    Hello onnb1,

    Thanks for your note.

    Both the Position and Performance classes will reference the strategy only and not the full account.

    Below is a link to Position in the help guide.
    http://www.ninjatrader.com/support/h...7/position.htm

    Also, here is a link to Performance in the help guide.
    http://www.ninjatrader.com/support/h...erformance.htm


    Accessing the entire account position is unsupported, but would be done like:
    Code:
    	// set account position handle to myPosition
    	Cbi.Position myPosition = Account.Positions.FindByInstrument(Instrument);
    			
    	// will only print if there is a position
    	if (myPosition == null)
    		return;
    				
    	// print position and quantity to output window
    	Print
    	(
    		myPosition.MarketPosition.ToString()
    		+ " | " + myPosition.Quantity.ToString()
    	);

    Please let me know if this does not resolve your inquiry.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X