Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Force Update Strategy
Collapse
X
-
Force Update Strategy
Is there a way to force update a strategy during a period in which there is no data coming in? I have a strategy that I want to cancel itself after 15 minutes if no trades occur. The issue I'm running into is that there are periods in which there is no data coming in for the stock I'm looking at(pre-and-post-market). During that time if a trade does not occur I need the strategy to re-calculate and terminate itself, but I can't figure out how to force it to calculate on a given interval.Tags: None
-
Hello magnatauren,
If there is not any data coming in that generally means your strategy is not able to execute its logic. You could potentially use a C# timer for this use case, you would need to figure out when to enable the timer so that it could execute after the data stopped.
Strategies have a CloseStrategy method that can be used to disable the strategy however I am not certain if this would work after hours due to it having to try and close positions: https://ninjatrader.com/support/help...=closestrategy
This may present an error message stating that it cannot close orders or there is no data to drive the simulation engine.
A possibly better solution would be to set a bool variable to true when you want to stop trading. If no trades occur in 15 minutes set the bool to true, later in your logic the bool can be used to prevent other logic form happening. That would allow the script to remain enabled and would otherwise just not trade going into the future sessions.
Please let me know if I may be of additional assistance.
-
Hey Jesse, that's actually what I have set up right now, The issue I'm having is that it will still execute if the stopwatch, which is created during the configure state, which I hope is where I want it, is less than the current time.
The issue is, if there's no data coming in then it won't calculate to terminate itself, and still requests data from kinetick. I need it to stop requesting from kinetick if nothing occurs after a certain period.Code:else if (State == State.Configure) { AddDataSeries(Data.BarsPeriodType.Volume, 5000); stopWatch = DateTime.Now.AddMinutes(15); } if ((stopWatch <= Time[0] && BarsSinceEntryExecution(1, "Entry", 1) == -1 )) { SetState(State.Terminated); return; }
- Likes 1
Comment
-
No, use a real timer.Originally posted by magnatauren View PostHey Jesse, that's actually what I have set up right now, The issue I'm having is that it will still execute if the stopwatch, which is created during the configure state, which I hope is where I want it, is less than the current time
Good discussion here.
Comment
-
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
46 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
66 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment