protected override void OnBarUpdate() { if(currentTime <= tradeStartTime || currentTime >= tradeStopTime){ return; } else{ // Do all the logic for trading strategy } }
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
How to tell Backtest and Optimization to go to next trading day
Collapse
X
-
How to tell Backtest and Optimization to go to next trading day
I want to increase the speed of Optimization for my strategy. I have already done IsInstantiatedOnEachOptimizationIteration=false and coded my strategy to properly reset the variables. My strategy only trades during specific time of the day (e.g. between 9:30am to 12pm). Below is excerpt pseudo code of my strategy.
Code:Tags: None
-
Hello wzgy0920,
Thank you for your post.
OnBarUpdate() will be called whenever a bar is updated. There is no way to tell OnBarUpdate() not to update at all on a certain condition. Your return statement however will ensure that it will skip any further calculation.
Please let us know if you have any further questions.Gaby V.NinjaTrader Customer Service
-
Originally posted by NinjaTrader_Gaby View PostHello wzgy0920,
Thank you for your post.
OnBarUpdate() will be called whenever a bar is updated. There is no way to tell OnBarUpdate() not to update at all on a certain condition. Your return statement however will ensure that it will skip any further calculation.
Please let us know if you have any further questions.
Comment
-
I would also very much like this feature to be implemented.
I have a couple of specific time frames I want to create strategies for, that are between 10 minutes and half an hour.
You would of course need to have the minimum bars needed before the start to have all indicator values used in the strategy correctly reflected etc.
So I'm sure it's not trivial to implement.
It seems that a big improvement can be made for strategies like these if you could specify a start and stop time for the optimization per day (where the strategy can take trades).
- Likes 1
Comment
-
Originally posted by bmggchevalier View PostI would also very much like this feature to be implemented.
I have a couple of specific time frames I want to create strategies for, that are between 10 minutes and half an hour.
You would of course need to have the minimum bars needed before the start to have all indicator values used in the strategy correctly reflected etc.
So I'm sure it's not trivial to implement.
It seems that a big improvement can be made for strategies like these if you could specify a start and stop time for the optimization per day (where the strategy can take trades).
I have questions and suggestions related Strategy Analyzer. 1) Currently the analysis of Optimization results is very very slow and painful. Please improve this. I run Optimization on multiple variables that span multiple weeks. The Optimization itself takes few hours, after which I am presented with top results. When I am
I have few questions about using the Strategy Analyzer and some feedback for improvement. 1) How do I change the default strategy that appears when I go to New >> Strategy Analyzer >> General >> Strategy? Right it seems the list of strategies in the drop down box are alphabetically orders. Essentially I want
Comment
-
Hello wzgy0920,
IsInstantiatedOnEachOptimizationIteration only determines if the strategy should be re-instantiated (re-created) after each optimization run when using the Optimizer.
https://ninjatrader.com/support/help...niteration.htm
The optimal approach to "terminate" a strategy from OnBarUpdate() is to use a return statement. You can also call CloseStrategy().
https://ninjatrader.com/support/help...sestrategy.htm
Please let me know if you have any other questions.
Gaby V.NinjaTrader Customer Service
Comment
-
Originally posted by NinjaTrader_Gaby View Post
The optimal approach to "terminate" a strategy from OnBarUpdate() is to use a return statement. You can also call CloseStrategy().
Comment
-
Hello,
My apologies, I neglected to mention that CloseStrategy only works in real time. From the Help Guide page:
Warning: This method can only be call before the State has reached State.Terminated and after the State reaches State.Realtime
https://ninjatrader.com/support/help...sestrategy.htm
Instead of CloseStrategy(), you can use SetState(State.Terminated) to abort the strategy as it is running. Doing this in a Strategy Analyzer backtest will abort the backtest entirely, and no partial backtest results will be shown.
SetState() - https://ninjatrader.com/support/help...8/setstate.htm
Please let me know if you have any other questions.
Gaby V.NinjaTrader Customer Service
Comment
-
Originally posted by wzgy0920 View Post
Is it possible to request a feature to signal the Backtest/Optimization to terminate/skip the processing the strategy for the remaining bars of the trading session? As I mentioned I would like to Backtest/Optimize my strategy for specific time range of the trading session. During Bactest/Optimization NT is spending a lot of processing going through bars that doesn't actually result in strategy usage. This feature would help improve performance.
This request is being tracked under the number SFT-6312.
As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted on the Release Notes page of the Help Guide.
Release Notes —https://ninjatrader.com/support/help...ease_notes.htmGaby V.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by slightly, Today, 12:49 AM
|
0 responses
2 views
0 likes
|
Last Post
by slightly
Today, 12:49 AM
|
||
Started by sdauteuil, 09-23-2021, 10:16 AM
|
4 responses
1,208 views
0 likes
|
Last Post Yesterday, 11:41 PM | ||
Started by agclub, 04-21-2024, 08:57 PM
|
5 responses
34 views
0 likes
|
Last Post
by agclub
Yesterday, 09:47 PM
|
||
Started by ESHunter, Yesterday, 08:06 PM
|
2 responses
18 views
0 likes
|
Last Post
by ESHunter
Yesterday, 09:27 PM
|
||
Started by ETFVoyageur, 05-07-2024, 07:05 PM
|
19 responses
150 views
0 likes
|
Last Post
by ETFVoyageur
Yesterday, 09:14 PM
|
Comment