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

2nd instrument.fullname?

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

    2nd instrument.fullname?

    I'm running an indicator which uses as its input, two instruments displayed on the chart.

    I am trying to simply print (for now) the fullname of the second instrument but I can't get it.

    I can call up and print the 1st-(primary) instrument.

    Is this possible to do?

    #2
    You can accomplish this by calling the Instrument.Full name in the respective BarsInProgress filter

    Code:
    			if(BarsInProgress == 0)
    			{
    				Print("Primary Series : " + Instrument.FullName);
    			}
    			
    			if(BarsInProgress == 1)
    			{
    				Print("Secondary Series : " + Instrument.FullName);
    			}
    MatthewNinjaTrader Product Management

    Comment


      #3
      You can also do 'Instruments[x].FullName', so for example

      Instruments[1].FullName

      would get the name of the second instrument, etc.

      Comment


        #4
        Using

        Instruments[1].FullName


        I thought I had done that but I couldn't get it to work. Maybe my syntax was wrong? (Compile error)

        How would you output that in a print statement? What's the correct syntax?

        Comment


          #5
          Hello Steve R,
          You can use the below code to print out the instrument full name of the secondary series.
          Code:
          Print(Instruments[1].FullName);
          You can view the prints in the Output Window (in Control Center menu bar goto Tools>Output Window)
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            Yeah it's still not working properly guys. It's no longer throwing a syntax/compile error (which is a step and we know that your syntax is correct) but now it has a run-time error and won't display that part of the print statement.

            Once I take that part out of the print statement it goes back to working again, (less the printing of what the second instrument's name is of course).

            I think it has something to do with this being an indicator of an indicator type of arrangement?

            This indicator (the one doing the printing to the output window) takes as an input, a second indicator (called "Spread") which itself take the spread of two securities, then it performs more number crunching. By the time the info seems to get through to the second indicator it seems to have lost the second instruments name?

            Is it possible that the info after being recursively crunched like this just loses the original securities names?

            Comment


              #7
              If I understand correctly. the second instrument is not actually Added to the indicator you're printing from?

              If this is the case you would not be able to print the instrument name. You'd have to do the printing from the Spread indicator. Unless you're passing this information from the Spread indicator as a public string.

              Please have a look at our reference sample on Exposing indicator values that are not plots:

              MatthewNinjaTrader Product Management

              Comment


                #8
                Hi Matthew, it goes like this:

                IndicatorDoingThePrinting(Spread(Inst#1, Inst#2))

                Where: Spread() is an indicator itself.

                From the best of my understanding of the situation, IndicatorDoingThePrinting gets passed only the single combined value? of the two instruments.

                Oddly, I can print the Primary Instrument.FullName (In this case Inst#1 which is also the primary instrument on the chart.) It's just the Inst#2 (which is also on the chart 2nd Panel) that I can't seem to capture.
                Last edited by Steve R; 08-02-2012, 07:07 PM.

                Comment


                  #9
                  One more thing Matthew,

                  It looks to me like what you're saying is what is happening here, meaning it's not possible for me to 'get' the Inst#2 Name.

                  If that's the case then I have one more question.

                  How can I rename Spread() to something else like AnotherSpread() and then rewrite that indicator, but leave the original Spread() indicator as it is.

                  I've not seen how I can rename an indicator.

                  I'd also need to add a few things (user input values) to AnotherSpread() where the 'wizard' was usually involved and I don't think I'd be able to use the wizard after all the manual editing, correct?

                  I'm looking for an easy work-around here.

                  Comment


                    #10
                    Originally posted by Steve R View Post
                    Hi Matthew, it goes like this:

                    IndicatorDoingThePrinting(Spread(Inst#1, Inst#2))

                    Where: Spread() is an indicator itself.

                    From the best of my understanding of the situation, IndicatorDoingThePrinting gets passed only the single combined value? of the two instruments.

                    Oddly, I can print the Primary Instrument.FullName (In this case Inst#1 which is also the primary instrument on the chart.) It's just the Inst#2 (which is also on the chart 2nd Panel) that I can't seem to capture.
                    You have Inst#2 in the IndicatorDoingThePrinting. From where are you getting that value? Is it a property of IndicatorDoingThePrinting? If not, how are you passing it to the Spread() indicator?

                    Comment


                      #11
                      Koganam,

                      I'm not sure I'm following you.

                      Spread() is passing a single value to IndicatorDoingThePrinting()

                      Spread() is 'Nested' within IndicatorDoingThePrinting(), is how I think you guys would term it.

                      That value came from Inst#1 and Inst#2 which were the two Inputs to Spread()

                      It seems to me that Matthew has it right here. I just can't do it all that easily since the Inst#2 full name has been lost (or not passed along, however we want to term it).

                      Somehow or another I still have access to the FullName of Inst #1.

                      This is why my next question, so I can gain an easier work-around, is how to rename the Spread() indicator and possible add a few new user input variables(no longer via wizard? Yes/No?) so I can combine my second indicator into the Spread() indicator, thus fixing the problem and quite frankly making a few more things likely work better too, now that I look at it.

                      thanks for any help you guys can give.
                      Last edited by Steve R; 08-02-2012, 08:07 PM.

                      Comment


                        #12
                        Originally posted by Steve R View Post
                        Koganam,

                        I'm not sure I'm following you.

                        Spread() is passing a single value to IndicatorDoingThePrinting()

                        Spread() is 'Nested' within IndicatorDoingThePrinting(), is how I think you guys would term it.

                        That value came from Inst#1 and Inst#2 which were the two Inputs to Spread()

                        It seems to me that Matthew has it right here. I just can't do it all that easily since the Inst#2 full name has been lost (or not passed along, however we want to term it).

                        Somehow or another I still have access to the FullName of Inst #1.

                        This is why my next question, so I can gain an easier work-around, is how to rename the Spread() indicator and possible add a few new user input variables(no longer via wizard? Yes/No?) so I can combine my second indicator into the Spread() indicator, thus fixing the problem and quite frankly making a few more things likely work better too, now that I look at it.

                        thanks for any help you guys can give.
                        Making a new copy of an indicator for editing is as simple as right-clicking in the original indicator, selecting "Save As ..." from the popup menu, and saving to a new name. That will properly rename all references to the indicator name in the code and wrappers.

                        If that is your preference, then so be it.

                        My question was actually, I thought, quite clear. Where is the value of Inst#2 being defined/declared. Is it a defined property of IndicatorDoingThePrinting(), or is it a fixed, hard-coded string that you are passing to the Spread() indicator when you call it?

                        Comment


                          #13
                          "My question was actually, I thought, quite clear. Where is the value of Inst#2 being defined/declared. Is it a defined property of IndicatorDoingThePrinting(), or is it a fixed, hard-coded string that you are passing to the Spread() indicator when you call it?"

                          It's like I said before, Inst#1 and Inst#2 are the primary and secondary data series of the chart. (Multi-instrument chart I think you guys call it?)

                          Hey, "Save As" works cool enough, lol, but I can't find where I can right click them that brings up a pop-up menu that gives me that option. It sounds funny, but seriously, I can't find it. Is it within NT, or do I navigate to the folder? Either way I haven't found it yet :-(

                          You've got me this far, bring it home brother! lol.

                          Comment


                            #14
                            Originally posted by koganam View Post
                            Making a new copy of an indicator for editing is as simple as right-clicking in the original indicator, selecting "Save As ..." from the popup menu, and saving to a new name. That will properly rename all references to the indicator name in the code and wrappers.
                            I didn't know about that , very useful!

                            To Steve R: Right click within the Ninjascript editor window, and you'll see it.
                            Last edited by Radical; 08-02-2012, 08:57 PM.

                            Comment


                              #15
                              Originally posted by Steve R View Post
                              "My question was actually, I thought, quite clear. Where is the value of Inst#2 being defined/declared. Is it a defined property of IndicatorDoingThePrinting(), or is it a fixed, hard-coded string that you are passing to the Spread() indicator when you call it?"

                              It's like I said before, Inst#1 and Inst#2 are the primary and secondary data series of the chart. (Multi-instrument chart I think you guys call it?)

                              Hey, "Save As" works cool enough, lol, but I can't find where I can right click them that brings up a pop-up menu that gives me that option. It sounds funny, but seriously, I can't find it. Is it within NT, or do I navigate to the folder? Either way I haven't found it yet :-(

                              You've got me this far, bring it home brother! lol.
                              You said you wanted to copy the indicator code. I guess I made an assumption there. But it means that you have to be editing the code that you want to copy.

                              IOW, open the code as if you want to edit it, then do your thing.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by poplagelu, Today, 05:00 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post poplagelu  
                              Started by fx.practic, 10-15-2013, 12:53 AM
                              5 responses
                              5,407 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by Shai Samuel, 07-02-2022, 02:46 PM
                              4 responses
                              98 views
                              0 likes
                              Last Post Bidder
                              by Bidder
                               
                              Started by DJ888, Yesterday, 10:57 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by MacDad, 02-25-2024, 11:48 PM
                              7 responses
                              160 views
                              0 likes
                              Last Post loganjarosz123  
                              Working...
                              X