Announcement
Collapse
No announcement yet.
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:
then executable "if & else if & then statements"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.
The code compiles fine at my end. Are you able to resolve it, If not then please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]comCode: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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
633 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
364 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
567 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
568 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment