Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Gloabal Variables?
Collapse
X
-
This WORKS:
[DllImport("GlobalVariable.dll")]
public static extern int GV_SetInteger(int iLocation, int iVal);
[DllImport("GlobalVariable.dll")]
public static extern int GV_GetInteger( int iLocation) ;
int GV1 = GV_SetInteger(1, 33);
int GV2 = GV_GetInteger(1);
Comment
-
Could you show a bit more?
mktrend,
I am trying to understand how to use the code snipet you showed.
For example, on these two lines of code:
[DllImport("GlobalVariable.dll")]
public static extern int GV_SetInteger(int iLocation, int iVal);
Is that the EXACT syntax?
Do they go before the Using Declarations?
Do they go after the brace of the 'namespace NinjaTrader.Indicator' statement?
I have tried several combinations and keep getting compiler errors.
I assume the GlobalVariables.dll should go in:
C:\Program Files\NinjaTrader 6.5\bin right?
I appreciate any direction you can provide. Perhaps a link that I can refer to?
Thanks,
Gary
Comment
-
make sure dll in bin or wherever but both apps address the same path...Originally posted by GaryAlbers View Postmktrend,
I am trying to understand how to use the code snipet you showed.
For example, on these two lines of code:
[DllImport("GlobalVariable.dll")]
public static extern int GV_SetInteger(int iLocation, int iVal);
Is that the EXACT syntax?
Do they go before the Using Declarations?
Do they go after the brace of the 'namespace NinjaTrader.Indicator' statement?
I have tried several combinations and keep getting compiler errors.
I assume the GlobalVariables.dll should go in:
C:\Program Files\NinjaTrader 6.5\bin right?
I appreciate any direction you can provide. Perhaps a link that I can refer to?
Thanks,
Gary
Comment
-
I just found this thread working on an algorithm to have multiple strategies coordinate to best use my trading capital. You can read the details of that discussion here: http://www.ninjatrader-support2.com/...ad.php?t=12252Originally posted by GATT1 View PostCan somebody please provide a download link for GlobalVariable.dll?
Please don't post the TS link, I have no access to the TS forum!
Thank you
I found the GV file that people are looking for here and I'm attaching it to this message.
I will try it out and report back. It may take me a few days, I have a lot of work this week.
Thank you to everyone in this thread for sharing this idea and for posting the code examples. It's very helpful to me.Attached Files
Comment
-
Yep, you're on the right track! Just have each strategy entering a position to set a Global Variable to 1 and after exiting it to reset it back to 0 and all strategies to check the condition of the flag first and if it's a 1 it means the account is not available...etc.Originally posted by cunparis View PostThe problem is once a strategy enters a long position, I don't want the other strategies to enter any positions. My account size won't allow it. I can't figure out how to do this.
The solution of just trading one strategy doesn't work for me because I don't get many trades so I like to trade ES & NQ so that I get more trades.
A bit more sophisticated approach would be to make a custom event as in any strategy entering and exiting a trade would inform the others about it by raising a custom event.
I had a thread on this a few days ago!
here:
Last edited by mktrend; 01-13-2009, 06:55 AM.
Comment
-
Utilizing the snippet above or any of the many other functions available in the GV.dll you can send any data or even streams from one ind. strat, to others quite easily. Post if need more help. Make sure the same copy of the dll is referred to and no other copies of the same dll exist in your system files etc.Originally posted by mktrend View PostThis WORKS:
[DllImport("GlobalVariable.dll")]
public static extern int GV_SetInteger(int iLocation, int iVal);
[DllImport("GlobalVariable.dll")]
public static extern int GV_GetInteger( int iLocation) ;
int GV1 = GV_SetInteger(1, 33);
int GV2 = GV_GetInteger(1);
Comment
-
I don't think it's necessary. A static variable seems to do the same thing.Originally posted by bridenour View PostHi,
Did using this DLL actually work out for you guys? Do you think it would be appropriate/effective for storing an "available balance" variable across multiple live executing strategies?
Thanks,
Brandon
This GV is to communicate between different applications, not to communicate inside the same application when other methods (static variable) are possible.
Comment
-
I was not successful but it had nothing to do with the choice of static variable for GV. The reason I didn't succeed is because when you have several strategies accessing the same value there are timing issues. If you make a lock you have to synchronize the methods so that two strategies don't try to modify the lock at the same time. I eventually gave up because I determined that it's better to do my position sizing differently where I allocate a % of capital to each strategy.Originally posted by bridenour View Postcunparis,
i thought you had said you tried with a static variable but were not successful? thanks for the input!
br
It didn't take long to program but testing it took a long time. So my advice is re-examine your need for this and avoid it if possible. If you just want to communicate a msg between two strategies it's easy. but if you want to use some kind of lock where one strategy gets the lock and another strategy waits for it, then this is where it gets hard..
Comment
-
I just want to share an available balance among strategies. I have several distinct systems that trade reasonably infrequently, and to efficiently use my available funds I need it to be available cross strategy.
Unlike yours, mine is not all of none, so I need to recalculate and update the "available balance" each time an entry or exit occurs.
The odds of entries and exits happening simultaneously is rather low, so I think I might just give the static a shot and see how it plays out. Worst case it will try to open too many positions and likely get rejected due to margin limits.
Thanks for your feedback!
Comment
-
Unless you're trading a very small account size, you will probably find with position sizing and a 2% risk that it's impossible to use all of your money. In this case you may not need to share the account balance.Originally posted by bridenour View PostI just want to share an available balance among strategies. I have several distinct systems that trade reasonably infrequently, and to efficiently use my available funds I need it to be available cross strategy.
Unlike yours, mine is not all of none, so I need to recalculate and update the "available balance" each time an entry or exit occurs.
The odds of entries and exits happening simultaneously is rather low, so I think I might just give the static a shot and see how it plays out. Worst case it will try to open too many positions and likely get rejected due to margin limits.
Thanks for your feedback!
If you are trading a small account size then you could re-examine the % risk you're taking.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment