Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 ninjascripts. Any way they can talk with each other?

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

    2 ninjascripts. Any way they can talk with each other?

    Hi,

    I am trying to figure out how I can send a variable from one ninja script indicator to another indicator. The reason for doing so is because one indicator needs to calculate on each tick and the other needs to calculate on the bar close. I am using the buysellvolume indicator.

    I have been trying to use Static Variables and events but the moment I try to reference the variable by mentioning the ninjascript in a different script, I get an error saying "Indicator. bla bla is a method, which is not valid in the given context."

    Any help will be greatly appreciated.

    Regards

    #2
    Hello IDumpedCinderella,

    The supported way would be to set a plot value in the symbiote indicator and call the symbiote indicator from the host indicator.

    Using static classes and properties is not supported and will not work in all situations.

    However, I can provide you an unsupported example of using a static class.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I get an error saying "Indicator. bla bla is a method, which is not valid in the given context."
      This error is a result of the way NT8 adds the invocation methods to the Indicator class (auto generated code at bottom of indicators) that also handles the caching.

      You can reference your actual Indicator class for static properties through full class name. e.g.
      Code:
      Indicators.INDNAME.foo
      or if you create your own Namespace,
      Code:
      Indicators.MyIndicators.INDNAME.foo

      Comment


        #4
        Originally posted by IDumpedCinderella View Post
        Hi,

        I am trying to figure out how I can send a variable from one ninja script indicator to another indicator. The reason for doing so is because one indicator needs to calculate on each tick and the other needs to calculate on the bar close. I am using the buysellvolume indicator.

        I have been trying to use Static Variables and events but the moment I try to reference the variable by mentioning the ninjascript in a different script, I get an error saying "Indicator. bla bla is a method, which is not valid in the given context."

        Any help will be greatly appreciated.

        Regards
        I'm not 100% sure, but I think it might be possible with a static class using an event driven design.

        Comment


          #5
          Originally posted by IDumpedCinderella View Post
          Hi,

          I am trying to figure out how I can send a variable from one ninja script indicator to another indicator. The reason for doing so is because one indicator needs to calculate on each tick and the other needs to learn more and calculate on the bar close. I am using the buysellvolume indicator.

          I have been trying to use Static Variables and events but the moment I try to reference the mitfozzek variable by mentioning the ninjascript in a different script, I get an error saying "Indicator. bla bla is a method, which is not valid in the given context."

          Any help will be greatly appreciated.

          Regards
          Hey, was it solved? I'm also the similar issue.
          Last edited by Joeteryse; 04-09-2025, 10:22 PM.

          Comment


            #6
            Originally posted by Joeteryse View Post

            Hey, was it solved? I'm also the similar issue.
            I created an example here. https://github.com/WaleeTheRobot/ind...cation-example

            Comment


              #7
              Originally posted by WaleeTheRobot View Post
              Okay, thanks!

              Comment


                #8
                Code:
                var i = ChartControl.Indicators.Where(x => x.Name == "indicatorname").FirstOrDefault();
                ​if (i != null)
                 {
                  //do something
                }​
                You need indicatorname applied on chart. Still 95% of the time you are better off following Chelsea's advice of using plot values.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                566 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                330 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                547 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                548 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X