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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      56 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      143 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X