Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Printing the Instrument name from a strategy

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

    Printing the Instrument name from a strategy

    Hi,

    In my strategy I would like to print the instrument name (using the Print method) PRIOR to sending an order.
    I was wondering what method should I call in order to get the instrument name I set in the strategy window.

    Regards,

    Ron

    #2
    Hello Ron,
    Thanks for your post and I am happy to assist you.

    You can use the following to get the name of the instrument:
    Code:
    Instrument.FullName;
    Or
    Code:
    Instrument.MasterInstrument.Name;


    Please let me know if I can assist you any further.
    Last edited by NinjaTrader_Joydeep; 02-07-2012, 12:06 PM.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hi

      I have a strategy with several instruments, in order to debug I want to print all instrument names. However, when I print Instrument.FullName[1], then I get "A" instead the instrument name.
      Instrument.FullName alone works fine for first instrument (0-bars series)

      how can I get the name of my 2nd instrument?

      Comment


        #4
        Hello Beauregard,

        Thank you for your post.

        You'd want to use Instruments[]:



        Code:
        protected override void OnStateChange()
        {
          if (State == State.DataLoaded)
          {
              // Print all instruments which have been loaded
              foreach (Instrument i in Instruments)
              {
                  Print(i.FullName);
              }
          }
        }
        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Hi Kate

          thanks, this is not exactly what I am looking for. I would like to address the instrument name directly.
          Example: I have three data series, the default one and I add 2 more:
          Add(Instrument2, PeriodType.Day, 1);
          Add(Instrument3, PeriodType.Day, 1);

          Then I have a function where I need some debug information. The function is called within OnBarUpdate.
          I would like to have the name of my Instrument2 and the Marketposition
          Print (String.Format("{0:d}",Time[0])+" "+Instrument.FullName[1]+":"+Positions[1].MarketPosition);

          This does not work

          Comment


            #6
            Hello Beauregard,

            Thank you for your reply.

            I do apologize as the link I posted was for NT8, however, the general idea is the same. You're just putting the index in the wrong spot:

            Print (String.Format("{0:d}",Time[0])+" "+Instruments[1].FullName+":"+Positions[1].MarketPosition);

            You want to make sure you're referencing the Instruments array by index before accessing the FullName property.

            Please let us know if we may be of further assistance to you.

            Comment


              #7
              Great! thanks. I tried this before, but I used Instrument instead Instruments

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NinjaTrader_Brett, Yesterday, 03:19 PM
              0 responses
              179 views
              0 likes
              Last Post NinjaTrader_Brett  
              Started by domjabs, Yesterday, 01:55 PM
              2 responses
              39 views
              0 likes
              Last Post domjabs
              by domjabs
               
              Started by Morning Cup Of Trades, Yesterday, 11:50 AM
              1 response
              38 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Started by imjustkaze, Yesterday, 12:20 PM
              2 responses
              82 views
              0 likes
              Last Post imjustkaze  
              Started by IanS00, Yesterday, 11:57 AM
              3 responses
              30 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X