Andy
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Max Number of Trade Per Day
Collapse
X
-
Max Number of Trade Per Day
I'm running a strategy on 100 stock symbols. Is there a way I can limit the number of trades per day ? I don't want the strategy to make more than 10 transactions per day. Thanks.
Andy -
Hello Andy,
Thank you for your post.
You can create a int to track the number of entries per day. For example:
Code:#region Variables private int previousTrades = 0; #endregion protected override void OnBarUpdate() { if(Bars.FirstBarOfSession) { previousTrades = Performance.AllTrades.Count; } if(Performance.AllTrades.Count - previousTrades == 10) return;
Please let me know if I may be of further assistance.
-
Will this work if I'm running the strategy against 100 different stock symbols ? Does the Performance.AllTrades.Count get updated for any trade in the list of 100 stocks ? I tried this previously in backtesting and it didn't seem to work. Thanks.
Andy
Comment
-
Originally posted by mechinvestor View PostWill this work if I'm running the strategy against 100 different stock symbols ? Does the Performance.AllTrades.Count get updated for any trade in the list of 100 stocks ? I tried this previously in backtesting and it didn't seem to work. Thanks.
Andy
"private int previousTrades = 0;"
with
"private static int previousTrades = 0;"
Comment
-
Log("Time = " + Time[0] + ", Performance.AllTrades.Count = " + Performance.AllTrades.Count, NinjaTrader.Cbi.LogLevel.Information);
It's always returning 0 during a backtest. Maybe this variable is only updated during live execution ?
Andy
Comment
-
Hello mechinvestor,
Thank you for your response.
Performance.AllTrades.Count will pull all trades historical or and real-time, so this will work in backtesting. You can pull only real time trades with Performance.RealtimeTrades.Count.
Are all 100 stocks added into the one strategy's code? Or is this a basket test of 100 instruments? If it is a basket test then Performance.AllTrades.Count will not pull each instrument, but will pull all trades for the instance of the strategy running or instrument in the basket test.
Does the value return as zero even after trades are placed? Is the backtest done on Daily data (Day, Week, Month or Year intervals)?
I look forward to assisting you further.
Comment
-
Hi everyone!
Look at my code, please. I run it on demo account (not strategy analyser, only realtime) but Performance.AllTrades.Count always returns zero.
My sample code is in attachment.Attached Files
Comment
-
Hello handlar,
Thank you for your post.
SystemPerformance will be pulled for the strategy instance itself. This means it will not have information if the strategy, like yours, is not placing trades. Please visit the following link for more information: https://ninjatrader.com/support/help...erformance.htm
There is not a supported means to pull Account Performance in NinjaScript.
Please let me know if you have any questions.
Comment
-
Hello handlar,
Thank you for your response.
The Performance.AllTrades will pull all trades the strategy calculates historically and in realtime.
You can also pull just Long, Short, or Realtime Trades as well. Please see the following link for more information: https://ninjatrader.com/support/help...erformance.htm
Please let me know if you have any questions.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Tekie, Today, 11:33 AM
|
0 responses
5 views
0 likes
|
Last Post
![]()
by Tekie
Today, 11:33 AM
|
||
Started by davidib2001, Today, 11:30 AM
|
0 responses
3 views
0 likes
|
Last Post
![]()
by davidib2001
Today, 11:30 AM
|
||
Started by davidib2001, Today, 11:28 AM
|
0 responses
7 views
0 likes
|
Last Post
![]()
by davidib2001
Today, 11:28 AM
|
||
Started by whomval, Today, 09:08 AM
|
0 responses
15 views
0 likes
|
Last Post
![]()
by whomval
Today, 09:08 AM
|
||
Started by herzogvladimir2, Yesterday, 08:10 PM
|
0 responses
19 views
0 likes
|
Last Post
![]() |
Comment