Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Instrument Name

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

    Instrument Name

    Hi,

    i´d like to check in my strategy if the name of the intrument is MSFT.
    I need this for backtesting on a bunch of possible stock portfolios.

    How do i do this ?

    I´ve found at http://www.ninjatrader.com/support/h...html?today.htm

    that there is something like "Instrument.MasterInstrument.Name".

    But if i put it into my "if clause" then it says that MSFT is not known.
    My sample:

    ...if (Position.MarketPosition == MarketPosition.Flat && Instrument.MasterInstrument.Name == MSFT)...
    then do something...

    It would be great if you could give me a hint how i could archive this.
    Thank You !

    #2
    Originally posted by nt2010 View Post
    Hi,

    i´d like to check in my strategy if the name of the intrument is MSFT.
    I need this for backtesting on a bunch of possible stock portfolios.

    How do i do this ?

    I´ve found at http://www.ninjatrader.com/support/h...html?today.htm

    that there is something like "Instrument.MasterInstrument.Name".

    But if i put it into my "if clause" then it says that MSFT is not known.
    My sample:

    ...if (Position.MarketPosition == MarketPosition.Flat && Instrument.MasterInstrument.Name == MSFT)...
    then do something...

    It would be great if you could give me a hint how i could archive this.
    Thank You !
    You need to compare like variables. Instrument.MasterInstrument.Name is a string. Correct would be: ... Instrument.MasterInstrument.Name == "MSFT"

    Comment


      #3
      Hi Koganam,

      thank you for your feedback. Its working !
      Thanx for the fast help.

      NT2010

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      65 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 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
      51 views
      0 likes
      Last Post CarlTrading  
      Working...
      X