one load template, this error is thrown.
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
Exception - while running backtest
Collapse
X
-
Hello misova,
It is possible to apply a template before running a backtest so that the settings do not have to be setup each time.
The BarsRequiredToTrade, however, is not a property that is saved with the template as this must be hard coded.
Are you able to reproduce this behavior using the SampleMACrossOver script included with NinjaTrader?
If not, may I have an export of your script to test this on my end?
To export a NinjaTrader 8 NinjaScript do the following:- Click Tools -> Export -> NinjaScript...
- Click the 'add' link -> check the box(es) for the script(s) you want to include
- Click the 'Export' button
- Enter a unique name for the file in the value for 'File name:'
- Choose a save location -> click Save
- Click OK to clear the export location message
By default your exported file will be in the following location:- (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
Below is a link to the help guide on Exporting NinjaScripts.
Chelsea B.NinjaTrader Customer Service
Comment
-
I tested thoroughly now,
but I can't reproduce it now.
Probably- I did not evaluate cause of the error correctly.
an it isn't caused by aplying template.
It happened to me again, but now I see, it happens during my development work:
during changes of code, compilations and backtesting together.
Somewhere - in the mess of development work I see these exceptions in the Log.
Unable to create instance of NinjaScript 'ReversalOfBigCandleStrategy'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.InvalidOperationException: 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
And exactly here, the bug happens:
When this happens, I see, that ReversalOfBigCandleStrategy is missing from the compiled strategies, despite, the file is physically there and compilation went fine.
This explains, that something - after successful compilation goes wrong = some process, that follows successful compilation:- maybe some reloading of classes,
- or maybe having old strategies running, while compiling their new version - where new version is not compatible... (just thinking about options)
What fixes the problem:
After I restart NT8, and compile again, everything is fixed and NT8 works just fine.
I know,problem that happens, but exact conditions are tough to identify fow now.
Lets see, If I can spot more helpful details during my next workLast edited by misova; 05-27-2017, 09:40 AM.
Comment
-
Hello misova,
With the error:
"System.InvalidOperationException: 'BarsRequiredToTrade' cannot be set from this state"
This looks to be related with a collection editor.
Do you have a collection editor in your script?
Please create and export a reduced version of your script that only contains bare minimum code to reproduce this error and post the export with your next post.
To export a NinjaTrader 8 NinjaScript do the following:- Click Tools -> Export -> NinjaScript...
- Click the 'add' link -> check the box(es) for the script(s) you want to include
- Click the 'Export' button
- Enter a unique name for the file in the value for 'File name:'
- Choose a save location -> click Save
- Click OK to clear the export location message
By default your exported file will be in the following location:- (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
Below is a link to the help guide on Exporting NinjaScripts.
Regarding the behavior where the file is being excluded from the project, I would be highly interested in know the sequence of steps that led to this behavior as I am unable to reproduce.
(I'm wondering if this may also be related to the error message and I would like to test with your reduced version script.)Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johnMoss, 03-04-2024, 01:53 PM
|
3 responses
43 views
0 likes
|
Last Post
by AndyM
Today, 06:13 PM
|
||
Started by algospoke, Today, 06:01 PM
|
0 responses
6 views
0 likes
|
Last Post
by algospoke
Today, 06:01 PM
|
||
Started by cre8able, Today, 05:53 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 05:53 PM
|
||
Started by Wessel, 03-23-2024, 02:37 PM
|
3 responses
23 views
0 likes
|
Last Post Today, 04:58 PM | ||
Started by martini, Yesterday, 04:45 PM
|
4 responses
32 views
0 likes
|
Last Post
by martini
Today, 04:48 PM
|
Comment