![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 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 |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Best approach is to use the OnMarketData() method of an indicator and use this to drive data to your application.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Likely you would need to provide an interface (DLL) from your application that will allow you to push the data through.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
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.
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
There are no global variables.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
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? |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 | |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
Yes exactly, I understand and there indeed exists various options that I am already looking into.
Quote:
|
|
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Aug 2008
Location: Orlando, Florida
Posts: 166
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#11 | |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
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 Quote:
|
|
|
|
|
|
|
#12 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
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
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"
PureLogikTrading |
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Apr 2008
Posts: 123
Thanks: 0
Thanked 1 time in 1 post
|
[DllImport("GlobalVariable21.dll", SetLastError = true)]
static extern "C" int __stdcall GV_GetInteger( int iLocation ) ; well something similar to the above??? |
|
|
|
|
|
#15 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
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); 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;
}
Code:
hDll = LoadLibrary("the dlls location");
This was in MFC, I haven't looked into how to use a DLL with NT yet. I hope this is a little helpful
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"
PureLogikTrading |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using variables | eswap0 | General Programming | 2 | 06-07-2008 05:56 PM |
| Global variables | monpere | Strategy Development | 1 | 03-10-2008 07:06 PM |
| importing variables from .txt | sandro | Indicator Development | 1 | 05-15-2007 06:59 AM |
| where should variables be declared? | Folls | Indicator Development | 2 | 05-04-2007 11:12 AM |
| Plotting variables | MAX | Indicator Development | 2 | 10-30-2006 10:19 PM |