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

Gloabal Variables?

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

    Gloabal Variables?

    Is there a way making the feed data received through NT available to third party programs, other than the txt file approach? Is there such a thing as the say Global Variables, whereby NT could read from or place to?

    thanks

    #2
    Best approach is to use the OnMarketData() method of an indicator and use this to drive data to your application.
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray,
      that's great news, any hints on how it can be done please, just a couple of lines will do...as long as I get a lead on what needs to be studied.
      I'm familiar with the OnMarketData() part just need the hints on the "drive data to your application" part.

      thanks

      Originally posted by NinjaTrader_Ray View Post
      Best approach is to use the OnMarketData() method of an indicator and use this to drive data to your application.

      Comment


        #4
        Likely you would need to provide an interface (DLL) from your application that will allow you to push the data through.
        RayNinjaTrader Customer Service

        Comment


          #5
          Yes, I was aware of that interface possibilities, although the question was about how to write directly to some form of Global variables that could have been both approached by NT and the 3rd. party app. which would also NOT be limited to just the VERY limited Methods available by the NT DLL interface.

          Originally posted by NinjaTrader_Ray View Post
          Likely you would need to provide an interface (DLL) from your application that will allow you to push the data through.

          Comment


            #6
            There are no global variables.
            RayNinjaTrader Customer Service

            Comment


              #7
              hmmm..., are you sure though?!

              I'm thinking maybe the storage location can be a physical file, database or ASP.NET Cache, utilizing Serialization technology that enables an object to be converted into a linear stream of data that can be easily passed across process boundaries and machines, hence what is stopping us in the case of the NT?

              Originally posted by NinjaTrader_Ray View Post
              There are no global variables.

              Comment


                #8
                Let me approach this from a different perspective.

                NinjaTrader uses C# thus the capability of the entire C# language and Microsoft .NET framework is available to you. We only provide support in the context of NinjaScript methods and properties. We do not provide support or guidance on capabilities outside that which falls into general C# programming. Anything can be done for sure.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Yes exactly, I understand and there indeed exists various options that I am already looking into.

                  Originally posted by NinjaTrader_Ray View Post
                  Let me approach this from a different perspective.

                  NinjaTrader uses C# thus the capability of the entire C# language and Microsoft .NET framework is available to you. We only provide support in the context of NinjaScript methods and properties. We do not provide support or guidance on capabilities outside that which falls into general C# programming. Anything can be done for sure.

                  Comment


                    #10
                    Originally posted by mktrend View Post
                    Is there a way making the feed data received through NT available to third party programs, other than the txt file approach? Is there such a thing as the say Global Variables, whereby NT could read from or place to?

                    thanks
                    You can use Global Variable, which I believe was originally written for TS but works fine with NinjaTrader as well. It is simply a DLL that allows you to store/access values at your pleasure. You can communicate between charts etc. utilizing the program. If you don't have it, you should be able to find from google search, or I can email to you.

                    Comment


                      #11
                      You mean actually using the Global variables DLL supplied by TS?! How can that be done, it should be very interesting though.
                      I have found a few ways of achieving this by involving the shared memory or the WM_COPY but this is very interesting what you say and it makes lots of sense too, you would have C# read write to that DLL and have whatever else 3rd. party program do the same...hmmm, very clever.
                      I'll Pm you my email to please send me a sample code.
                      thanks

                      Originally posted by SystemTrading View Post
                      You can use Global Variable, which I believe was originally written for TS but works fine with NinjaTrader as well. It is simply a DLL that allows you to store/access values at your pleasure. You can communicate between charts etc. utilizing the program. If you don't have it, you should be able to find from google search, or I can email to you.

                      Comment


                        #12
                        mktrend,

                        As far as I understand it the DLL was not supplied by TS; someone made it.

                        In order to use it you will need to write some code in NT to interface to it, and its methods, and some code on the 3rd party side to do the same. I have actually done this with C++ and TS; the TS portion was already written for me.

                        mrlogik
                        mrlogik
                        NinjaTrader Ecosystem Vendor - Purelogik Trading

                        Comment


                          #13
                          mrlogik,

                          Yes this idea makes perfect sense, since the DLL resides in all desired processes and interfaces them through a Mapped-File, hence has nothing to do with TS and it can be used by any application.
                          I used to think that TS mad it since they supported it, but thanks to whomever did it.

                          I've read that under certain conditions it could even improve performance and retard it heavily in certain others. I wish NT would step in and comment on the potential performance effect and yes I know this subject is NOT supported.

                          I guess the C# load lib model should look similar to below after replacing the below with the GV prototype? I'll look into it.

                          [DllImport("user32.dll", SetLastError = true)]
                          static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

                          I wish someone would show us how to directly write to a Mapped-File though, that must be faster and it can be used to accumulate data into it before witting it to HDD and also make the data available to all other apps.

                          Comment


                            #14
                            [DllImport("GlobalVariable21.dll", SetLastError = true)]
                            static extern "C" int __stdcall GV_GetInteger( int iLocation ) ;

                            well something similar to the above???

                            Comment


                              #15
                              In my MFC program this is part of what I had.

                              First, the extern prototypes
                              Code:
                              HINSTANCE hDll;
                              extern "C" __declspec(dllexport) int __stdcall GV_GetInteger(int location);
                              extern "C" __declspec(dllexport) int __stdcall GV_SetInteger(int location, int value);
                              Then the get / set functions

                              Code:
                              /***********************************************************************/
                              /*****************       GetGVInteger     ******************************/
                              /***********************************************************************/
                              int getGvInteger(int location)
                              {
                                  typedef int (__stdcall*getIntegerPtr)(int);
                                  getIntegerPtr func;
                                  func = (getIntegerPtr)GetProcAddress(hDll, "GV_GetInteger");
                              
                                  int i = -1;
                                  if ( func )
                                      i = func(location);
                              
                                  return i;
                              }
                              
                              
                              /***********************************************************************/
                              /*****************       SetGVInteger     ******************************/
                              /***********************************************************************/
                              int setGvInteger(int location, int value)
                              {
                                  typedef int (__stdcall*getIntegerPtr)(int, int);
                                  getIntegerPtr func;
                                  func = (getIntegerPtr)GetProcAddress(hDll, "GV_SetInteger");
                              
                                  int i = -1;
                                  if ( func )
                                      i = func(location, value);
                              
                                  return i;
                              }
                              On init i did this
                              Code:
                              hDll = LoadLibrary("the dlls location");
                              And then I was able to use those functions I described above.

                              This was in MFC, I haven't looked into how to use a DLL with NT yet.

                              I hope this is a little helpful
                              mrlogik
                              NinjaTrader Ecosystem Vendor - Purelogik Trading

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post quantismo  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              8 responses
                              166 views
                              0 likes
                              Last Post jeronymite  
                              Started by cre8able, Today, 04:22 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post cre8able  
                              Started by RichStudent, Today, 04:21 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post RichStudent  
                              Working...
                              X