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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      47 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      22 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      15 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      21 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      23 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X