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

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 Tin34, Today, 03:30 AM
      1 response
      6 views
      0 likes
      Last Post brucerobinson  
      Started by ETFVoyageur, Today, 12:52 AM
      1 response
      9 views
      0 likes
      Last Post Leeroy_Jenkins  
      Started by lollers, Today, 03:26 AM
      0 responses
      7 views
      0 likes
      Last Post lollers
      by lollers
       
      Started by aliyahany, Today, 03:16 AM
      0 responses
      1 view
      0 likes
      Last Post aliyahany  
      Started by mariajvillarrealr, Today, 02:57 AM
      0 responses
      1 view
      0 likes
      Last Post mariajvillarrealr  
      Working...
      X