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

Determine Instrument name

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

    Determine Instrument name

    The following code;
    protectedoverridevoid Initialize()
    {
    BPer= BarsPeriod.Value;


    Add(PeriodType.Minute,
    90);

    CalculateOnBarClose =
    true;
    InstrumentName=(Instrument.MasterInstrument.Name[
    1].ToString());
    BValue= (BarsPeriods[
    1].Id.ToString()) ;
    Print (BValue);
    Print (BPer);
    Print (InstrumentName);
    }
    Yields the following results on a GBPUSD 30 minute chart;
    Minute
    30
    B
    Minute
    30
    Q

    The 'Minute' and '30' are correct.
    Why are 'B' and 'Q' being returned? I am expecting 'GBPUSD'
    If I use InstrumentName=(Instrument.FullName[0].ToString()); I get the same type of results for InstrumentName.
    I checked the ref mat'l that I found referenced on the forum. I believe I did what was indicated on the forum.
    Thank you,
    Duke



    #2
    Instrument.FullName[1].ToString() ?


    Originally posted by dukeb View Post
    The following code;
    protectedoverridevoid Initialize()
    {
    BPer= BarsPeriod.Value;


    Add(PeriodType.Minute,
    90);

    CalculateOnBarClose =
    true;
    InstrumentName=(Instrument.MasterInstrument.Name[
    1].ToString());
    BValue= (BarsPeriods[
    1].Id.ToString()) ;
    Print (BValue);
    Print (BPer);
    Print (InstrumentName);
    }
    Yields the following results on a GBPUSD 30 minute chart;
    Minute
    30
    B
    Minute
    30
    Q

    The 'Minute' and '30' are correct.
    Why are 'B' and 'Q' being returned? I am expecting 'GBPUSD'
    If I use InstrumentName=(Instrument.FullName[0].ToString()); I get the same type of results for InstrumentName.
    I checked the ref mat'l that I found referenced on the forum. I believe I did what was indicated on the forum.
    Thank you,
    Duke


    Comment


      #3
      Upon more research ---
      When I omit the secondary chart ( // Add(PeriodType.Minute,90)
      And use --- InstrumentName=(Instrument.FullName.ToString());
      Print (InstrumentName);

      I get--
      $GBPUSD ---good
      NQ 03-12 ---???

      Why are two instruments returned?

      Comment


        #4
        Originally posted by dukeb View Post
        Upon more research ---
        When I omit the secondary chart ( // Add(PeriodType.Minute,90)
        And use --- InstrumentName=(Instrument.FullName.ToString());
        Print (InstrumentName);

        I get--
        $GBPUSD ---good
        NQ 03-12 ---???

        Why are two instruments returned?
        I see what is going on. You are just printing 1 character out of the string.

        Code:
        Print ("InstrumentName3="+Instrument.FullName[0].ToString()+
                                  Instrument.FullName[1].ToString()+
                                  Instrument.FullName[2].ToString()+
                                  Instrument.FullName[3].ToString()+
                                  Instrument.FullName[4].ToString()+
                                  Instrument.FullName[5].ToString()
                                  );
        Print ("InstrumentName4="+Instrument.FullName.ToString() );
        HTML Code:
        Output:
        InstrumentName3=ES 09-
        InstrumentName4=ES 09-12

        Comment


          #5
          Originally posted by dukeb View Post
          Upon more research ---
          When I omit the secondary chart ( // Add(PeriodType.Minute,90)
          And use --- InstrumentName=(Instrument.FullName.ToString());
          Print (InstrumentName);

          I get--
          $GBPUSD ---good
          NQ 03-12 ---???

          Why are two instruments returned?

          How many data series are in your chart?

          Right click the chart, Data Series , and on lower left corner.

          You might have $GBPUSD and then NQ 03-12.


          If NQ 03-12 is there, try to remove it. If you can't, Create a new chart for $GBPUSD.

          good luck

          Comment


            #6
            This behavior is peculiar to the strategy tester. Before I go to the strategy tester, I open the output box and discover the reference to NQ. I then delete this from the output box, run the tester. Everything is fine. I had assumed that it was being placed in the output box as a result of the actual testing. Not so. It appears to be a wierd type of behavior that has nothing to do with the testing and is placed there before the testing.

            Comment


              #7
              dukeb,

              Do you perhaps have a toy example strategy I can use to verify this? I would also need to have replication steps.
              Adam P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GussJ, 03-04-2020, 03:11 PM
              15 responses
              3,270 views
              0 likes
              Last Post xiinteractive  
              Started by Tim-c, Today, 02:10 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Taddypole, Today, 02:47 PM
              0 responses
              2 views
              0 likes
              Last Post Taddypole  
              Started by chbruno, 04-24-2024, 04:10 PM
              4 responses
              51 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              10 responses
              403 views
              1 like
              Last Post beobast
              by beobast
               
              Working...
              X