Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Communicating between two strategies

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

    Communicating between two strategies

    I have two strategies which run on 2 different time frames is there a way the two can share a variable? I used a global value and that works if they are on the same chart but they can't see each other when on different charts.

    I know it wasn't supported in Ninja but didn't know if some of the new enhancements supported now enabled this function in some way.

    Cheers

    ct

    #2
    CT!

    Strangely enough, I was referencing your post last night about global variables.

    As long as you have a public static type vName you should be able to reference it from anywhere using NT.

    What are you doing differently from this?
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      Here is what I am using:

      public static string MessengerInterStrategicVar = "" ;

      Comment


        #4
        This is what I do.

        In C#, or any Object Oriented Programming you should create a class with a default constructor, private variables, and get / set methods.

        I made a dummy indicator, pulled out all of the methods (initialize(), onbarupdate(), etc) that won't be used.

        Here is an example of a variable Class with this.

        Code:
        namespace NinjaTrader.Indicator
        {
            public class GlobalChart
            {
                private int tValue1;
        
                public GlobalChart()
                {
                    this.tValue1 = 0;
                }
        
                public int TValue1 { 
                                          get { return this.tValue1; } 
                                          set { this.tValue1 = value; } 
                                         }
            }
        
            partial class Indicator
            {
                public static GlobalChart gEURUSD_1 = new GlobalChart();
            }
        }
        You can set the value as such.
        Code:
        gEURUSD_1.tValue = 55;
        You can get the value as such.
        Code:
        int val = (int)gEURUSD_1.tValue;
        Make sure you have some logic that sets a "Sender" and a "Receiver" variable.

        Let me know.

        mrLogik
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Thanks. I am not a c# expert bill will work though it.

          Comment


            #6
            Passing data between indicators and strategy

            Hi,

            I hope you will be able to help...

            Say, I wanted to write an indicator that would be able to communicate with a strategy (or strategies) and share some data, even if it was one way, say strategy would be nice enough to update indicator...

            Is there a way that this could be done without going to .dll?

            Your help will be most appreciated...

            Roman

            Comment


              #7
              Roman,

              A strategy can call any indicator. If you expose the indicator values you are trying to access you will have no problem doing this directly within NinjaScript.



              Cross strategy is a different story and that is currently outside the scope of what we can support.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Thanks Josh,

                A valuable hint about the Update(). I will try to work something out...

                I understand that I can read any indicators, what I had in mind however is a cross strategy... I'll try to come up with another idea, I suppose...

                Cheers,

                Roman

                Comment


                  #9
                  Cross Strategy Idea

                  What if... Strategy "A" wrote the variable to a text file, then Strategy "B" read the variable from the text file?

                  Or, read/write the variable to a database (mySQL, SQL Server, Access, etc.)

                  Comment


                    #10
                    Hello,

                    This may work, but we do not provide support for it.

                    These links may help if you don't have them already:


                    DenNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    656 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    371 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    579 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X