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!
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
NinjaTrader
Limit trades in strategy
Collapse
X
-
Limit trades in strategy
hi...what code do I need to use to limit the amount of trades? for example, i want to enable over 20 instruments to be ready to trade once conditions are met, but i also woul like to limit the number of individual separate trades for any one account. how would i do that? so, just want to enable 20 or so but tell it to trade only if i have less than, say, 7 open positions...sorry sent with mobile device....Tags: None
-
Hello birdog,
To clarify further are you trying to apply 20+ different strategies on different instruments and want to open positions in 7 strategy only at one time, (even if more than 7 (say 12) strategies generate signals to go long/short.
If so then you can use the unsupported code to know that you have 7 open position for different instruments.
Code:this.Account.Positions.Count > 7 return;
JoydeepNinjaTrader Customer Service
-
Hey Joy:
It is only 1 Strategy enabled on 20 or so instruments, but I want to limit the amount of open instruments of the 20 as they execute to, say, under 7 open total positions. If 6 are open, then the next trade signal should not execute a 7th, 8th, 9th, etc until the total trade positions of the 20 drop below 6 etc. So, basically, I want the code to act, simply, as another filter...total account positions must be < 7 in order for the next signal/trade to actually execute. What code should I use for that behavior?
Greg
Comment
-
Joy...getting code compiling error...What is the simplest, preferably, "one line code" I can put immediately after:
Code:protected override void OnBarUpdate() { if (Historical) return; if (Position.MarketPosition == MarketPosition.Flat) ---here---
Last edited by birdog; 01-30-2013, 04:51 PM.
Comment
-
Hello Greg,
Both the codes are same and you can use any of them.
Code:this.Account.Positions.Count < 7 Account.Positions.Count < 7
Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.
I look forward to assisting you further.
*The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.JoydeepNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by cutzpr, Today, 08:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by cutzpr
Today, 08:54 AM
|
||
Started by benmarkal, Today, 08:44 AM
|
0 responses
4 views
0 likes
|
Last Post
by benmarkal
Today, 08:44 AM
|
||
Started by Tin34, Today, 03:30 AM
|
2 responses
26 views
0 likes
|
Last Post
by Tin34
Today, 04:11 AM
|
||
Started by sastrades, Yesterday, 09:59 AM
|
2 responses
38 views
0 likes
|
Last Post Today, 04:06 AM | ||
Started by ETFVoyageur, Today, 12:52 AM
|
1 response
21 views
0 likes
|
Last Post Today, 03:36 AM |
Comment