Also, is it possible to cap my number of day trades at three for the week?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Under 25K
Collapse
X
-
Under 25K
I am under 25K, so I am looking to swing trade rather than day trade. I thus need to make sure the position is exited on a day that is different than the day entered, but I can't find in the Ninjascript library where to get the day a position was entered or the current day. Can any one help?
Also, is it possible to cap my number of day trades at three for the week? -
Hello CriticalMind,
Sledge is correct in that with futures you do not have a minimum account balance to day trade so what you are asking may not even apply.
Both items you have mentioned however are perfectly possible within NinjaTrader using NinjaScript. To get the time an order was filled (the same as when a position is entered) you check the OnExecution method for order fills and then create a DateTime variable to hold the time the order filled. For example:
The code you would use to cap the number of day trades at three for the week would depend significantly on how the rest of your strategy was setup and whether you were planning on leaving your strategy running all week or not. This is because when you close the strategy, it does not save the variables so you would have to have a resource like a file created by your strategy to hold the current number of trades that have been submitted this week and the start or end date of the week which it would reload each time it was enabled.Code:#region Variables DateTime orderFilled; IOrder myOrder; #endregion protected override void OnBarUpdate() { if(myOrder == null) { myOrder = EnterLong(); //Submits the order } } protected override void OnExecution(IExecution e) { if(e.Order.OrderState == OrderState.Filled && e.Order == myOrder) { orderFilled = DateTime.Now; //Set the orderFilled time } }
Please let me know if you have any questions or if I may be of further assistance anytime.Michael M.NinjaTrader Quality Assurance
Comment
-
Thank you very much. I'll backtest both the futures and swing trading stocks, and find which is most effective.
Does anyone on the forum know a good place to get the symbol list for NYMEX? I entered some manually, and I got error messages for half of them.
Comment
-
You can find a list on the CME website at the following link: http://www.cmegroup.com/trading/prod...lse&exch=NYMEX
Please let me know if you cannot find one of these under Tools > Instrument Manager: http://ninjatrader.com/support/helpG...nt_manager.htm
Comment
-
-
-
Hello CriticalMind,
For backtesting you will likely want to replace the following code:
with something like:Code:orderFilled = DateTime.Now; //Set the orderFilled time
Please let me know if this does not resolve the issue or if I may be of further assistance.Code:orderFilled = Time[0]; //Set the orderFilled time
Michael M.NinjaTrader Quality Assurance
Comment
-
Thanks for the reply. It looks like it still doesn't work. Backtested the NASDAQ 100 since Jan 2015 and only one stock traded once. It normally trades about 20 times a week. Any other ideas. Thanks for your help.
Comment
-
Hello CriticalMind,
So that I can assist in the most efficient manner possible, can you please attach your code in an email to platformsupport[AT]ninjatrader[DOT]com with the subject line: "ATTN: Michael M http://www.ninjatrader.com/support/forum/showthread.php?t=78518"?
Thank you in advance.Michael M.NinjaTrader Quality Assurance
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
83 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
47 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
29 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
66 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment