protected override void Initialize() { AccountSize = 10000; }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Is it possible to limit total position size for all strategies?
Collapse
X
-
Is it possible to limit total position size for all strategies?
I see the help for AccountSize:
Code:Tags: None
-
Hi cunparis,
Accessing your brokerage account values is not supported in the current 6.5 release, however we will add it in our upcoming NinjaTrader 7 release.
Also - it is not possible to push the current strategy position over to another strategy, therefore both cannot 'talk' to each other...
If you only want to trade for example one contract per signal, you could explicitly code this in with -
Code:EnterLong(1)
BertrandNinjaTrader Customer Service
-
Bertrand,
I guess this is another feature request for NT7... but something like GetStrategies(), which returns a set of all currently (started) strategies would be very helpful.
We should then be able to cast the objects in the strategy to the native class type, and then make calls back and forth.
Comment
-
Originally posted by NinjaTrader_Bertrand View PostHi cunparis,
Accessing your brokerage account values is not supported in the current 6.5 release, however we will add it in our upcoming NinjaTrader 7 release.
Also - it is not possible to push the current strategy position over to another strategy, therefore both cannot 'talk' to each other...
If you only want to trade for example one contract per signal, you could explicitly code this in with -
Code:EnterLong(1)
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.
Comment
-
Hi cunparis,
Then I would suggest coding it into a MultiInstrument strategy, so you have one strategy and have the option to add 2 different entry signals and go from there...
Please see this link - http://www.ninjatrader-support.com/H...struments.htmlBertrandNinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Bertrand View PostHi cunparis,
Then I would suggest coding it into a MultiInstrument strategy, so you have one strategy and have the option to add 2 different entry signals and go from there...
Please see this link - http://www.ninjatrader-support.com/H...struments.html
All that is really 1 strategy that I run multi-instrument. I have another strategy that I'm working on, so as you can see once one has several different strategies that are each multi-instrument and multi-timeframe it'd be really complicated to combine them all into one big strategy.
Heech - I thought of this, but there could be race conditions if two strategies tried to go long at the same time. Worst case I'd end up with 2 contracts OR the broker would refuse the 2nd order due to insufficient margin. This seems more elegant than the monolithic strategy suggestion. I will look into this. I suppose the real way to do it would be using a database and transactions. That's way beyond my C# knowledge.
Comment
-
Originally posted by NinjaTrader_Josh View Postcunparis,
We cannot offer you any other solutions at this point in time. Sometimes you just have to buck down and code it out if that is the behavior you want.
Maybe with NT 7 being able to get the account balance that would solve the problem. Hopefully.
I think I'll code heech's idea of writing to a file. Seems simple enough.
Comment
-
Originally posted by cunparis View PostI suppose the real way to do it would be using a database and transactions. That's way beyond my C# knowledge.
FWIW, working with a simple database like MySQL is pretty trivial. And if nothing else, engineers who can code up a simple+reliable query/insert system for you should be a dime a dozen. I'll probably code it myself, but if you want help with something like this, look into something like rentacoder... many C# programmers in the developing world who'll work for cheap. ($100-$250 for what you want?)
Comment
-
Originally posted by heech View PostYep, as I mentioned in a different thread, I just had an epiphany and decided that's the behavior I need.
FWIW, working with a simple database like MySQL is pretty trivial. And if nothing else, engineers who can code up a simple+reliable query/insert system for you should be a dime a dozen. I'll probably code it myself, but if you want help with something like this, look into something like rentacoder... many C# programmers in the developing world who'll work for cheap. ($100-$250 for what you want?)
Thanks for sharing your ideas. You seem to be a bit further along than I am. I'm going to look for your other threads.
Comment
-
Originally posted by cunparis View PostI'm a Java developer but so far I've been able to figure everything out in C# all by myself. Well myself and google. So hitting MySQL in Java or PHP is quite easy, but C# I'd have to learn the APIs. The equivalent of JDBC for Java. I'll look into and if it's not much more effort than writing to a file then I can try that. I think it'd be cleaner than a file, and it'd be transactional.
Thanks for sharing your ideas. You seem to be a bit further along than I am. I'm going to look for your other threads.
I'm actually not that comfortable in raw JDBC, having always used a framework (Hibernate) in my past professional life. I'm thinking about using a framework in C# too... let's trade notes, if you find anything useful.
Comment
-
Originally posted by heech View PostAnother possibility.. use C# to read/write a file on the local hard-drive. Look into C# file handling examples (widely available online... just google). Your two strategies can coordinate that way.
Not perfect code but quick example:
string dailylimitlogfile = @"c:\windows\temp\ninja\dailylimit (" + Time[0].Month + "-" + Time[0].Day + "-" + Time[0].Year + ").txt";
string longpositionlogfile = @"c:\windows\temp\ninja\position_es_long (" + Time[0].Month + "-" + Time[0].Day + "-" + Time[0].Year + ").txt";
string shortpositionlogfile = @"c:\windows\temp\ninja\position_es_short (" + Time[0].Month + "-" + Time[0].Day + "-" + Time[0].Year + ").txt";
-------------------------
// create file to indicate daily limit reached
TextWriter dailylimitlog = new StreamWriter(dailylimitlogfile);
dailylimitlog.WriteLine(DateTime.Now + " - Daily limit reached");
dailylimitlog.Close();
--------------------------
// when flat
// delete position file
if (File.Exists(longpositionlogfile)) File.Delete(longpositionlogfile);
---------------------------
// when about to enter new position
if (File.Exists(shortpositionlogfile)) { Print (logprefix + "In a short position it seems, doing nothing."); return; }
if (File.Exists(dailylimitlogfile)) { Print (logprefix + "Daily limit reached on another strategy it seems, doing nothing."); return; }
---------------------------
// when entered position
// create file to indicate in long position for es
TextWriter position = new StreamWriter(longpositionlogfile);
position.WriteLine(DateTime.Now + " - In long position");
position.Close();
Comment
-
Originally posted by ctrlbrk View PostExactly, this is what I do with all my strategies now so they can talk to each other.
Not perfect code but quick example:
The question is each strategy run in the same "JVM" (not sure what the C# equivalent is), or is each one totally separate (with its own copy of the static variables)? If they're separate then the file approach is the next choice.
heech - I love Hibernate and the ORM idea in general. But in this case if I only had 1 table I'd just use JDBC to keep it simple. I imagine .NET has something similar to JDBC for simplicity.
I have to do a test for the static idea and if it doesn't work then my next goal is the file and eventually database.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kempotrader, Today, 08:56 AM
|
0 responses
6 views
0 likes
|
Last Post
by kempotrader
Today, 08:56 AM
|
||
Started by kempotrader, Today, 08:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by kempotrader
Today, 08:54 AM
|
||
Started by mmenigma, Today, 08:54 AM
|
0 responses
2 views
0 likes
|
Last Post
by mmenigma
Today, 08:54 AM
|
||
Started by halgo_boulder, Today, 08:44 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 08:44 AM | ||
Started by drewski1980, Today, 08:24 AM
|
0 responses
4 views
0 likes
|
Last Post
by drewski1980
Today, 08:24 AM
|
Comment