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

Share variable

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

    Share variable

    Hello,
    I have an indicator A with a plot and I would like to use that data in an indicator B. How can I do it easily without touching anything of the code?

    I've been looking at the forum, there are many options like series, addons, etc ... but something complicated since I would have to touch the code of indicators A and B,

    INDICATOR A:
    AddPlot(Brushes.Blue, "Option");
    #region Properties
    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> Option
    {
    get { return Values[0]; }
    }

    INDICATOR B:
    protected override void OnBarUpdate()
    Print(string.Format("Time: {0} | Plot= {1} ",Time[0] , INDICATOR A(Option)

    Thank you




    #2
    Originally posted by anmir55 View Post
    Hello,
    I have an indicator A with a plot and I would like to use that data in an indicator B. How can I do it easily without touching anything of the code?

    I've been looking at the forum, there are many options like series, addons, etc ... but something complicated since I would have to touch the code of indicators A and B,

    INDICATOR A:
    AddPlot(Brushes.Blue, "Option");
    #region Properties
    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> Option
    {
    get { return Values[0]; }
    }

    INDICATOR B:
    protected override void OnBarUpdate()
    Print(string.Format("Time: {0} | Plot= {1} ",Time[0] , INDICATOR A(Option)

    Thank you


    ref: https://ninjatrader.com/support/help..._strategie.htm

    Even for indicators, you still access the called indicator Plot, using Plots[n] (ie., Plots[0] etc.)

    Comment


      #3
      Hello anmir55,

      If the first indicator has a public double series for Values[0], you can call this directly from another script.

      From example:

      IndicatorA().Options[0];
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello,
        That is not so simple because there are more public variables than when you use that instruction in INDICATOR B and compile it gives you an error because you need more parameters of the rest of the public variable ... how can I only give value to that option variable?

        Comment


          #5
          Hello anmir55,

          You are correct, if the indicator has parameters, you would need to use those parameters in the indicator method call.
          These have not been provided in your previous posts.

          However, in the example I have provided focus on the .Options[0] part as this is how to use that specific public series.

          With the MACD to print the diff plot this would appear as:

          Print(MACD(12, 26, 9).Diff[0]);
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by anmir55 View Post
            Hello,
            That is not so simple because there are more public variables than when you use that instruction in INDICATOR B and compile it gives you an error because you need more parameters of the rest of the public variable ... how can I only give value to that option variable?
            Quite possibly. The answers given are to the question as asked. You showed only a Plot declaration and assignment in one indicator and asked how to reference it from another indicator. If there are other properties involved, nobody knows about them. If you want a complete answer, you do have to provide all the information required to respond to the question.

            You may wan to read the reference below. Read the part that talks about "Referencing indicator methods" in the "Performance Practices" section.

            ref: https://ninjatrader.com/support/help..._practices.htm

            Click image for larger version  Name:	Screenshot 2019-12-02 10.06.45.png Views:	0 Size:	25.3 KB ID:	1079540
            Last edited by koganam; 12-02-2019, 08:19 PM.

            Comment


              #7
              I am a rookie in this and I have an A indicator that I have downloaded from the web where it gives cumulate delta data and I don't know how it works. I just need that the delta cumulate data that is in a double variable can be retrieved from indicator B, simply without calling other variables ...

              Comment


                #8
                Hello anmir55,

                Unfortunately, you will have to call the indicator using the parameters the programmer has designed.

                If you don't want to have to provide values for these parameters and the script is open source, you may want to make a copy of the script that removes the [NinjaScriptProperty] attribute from all of the public properties.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                21 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X