Seems like this should be a fundamental function of the life cycle process.
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
BarsType Clone never called
Collapse
X
-
BarsType Clone never called
I have a custom BarsType and can see NinjaTrader going thru the process of creating a large number of objects in the life cycle process. However, Clone() is never called. I realize most of these objects are temporary, but I need the Clone to be properly called to copy private bar state between "functional" objects (i.e. I suspect there are multiple objects to deal with historical and live data).
Seems like this should be a fundamental function of the life cycle process.Tags: None
-
Hello aslane,
This is a bit too general for me to enter a feature request for.
Is there a specific error this will resolve that we can provide to our development?
Can you please provide an export of a reduced script that demonstrates the issue?
o export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:- Click Tools -> Export -> NinjaScript...
- Click the 'add' link -> check the box(es) for the script(s) and reference(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
- (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
http://ninjatrader.com/support/helpG...-us/export.htmChelsea B.NinjaTrader Customer Service
-
It's not a feature request per se, really just trying to figure out why Ninja does not follow the documented life cycle process for a BarsType object.
If it did, Clone would be properly used.
If you just create a BarType with a Clone method and set a break point, you will see that Clone is never called as the large number of BarsType objects are created.
Clone is needed in order to properly track private state while bars are being built. So, if you need a feature request, there it is (although I would call it a bug since you are not following documented process).
Comment
-
While it does not say BarType is cloned, it is a NinjaScript object, which the life cycle does specifically talk about.
The error is if you require bar to bar state within a BarType, then using Clone is the only way to properly propagate that state. When Clone is not called, you are starting fresh with no prior state.
Comment
-
Hello aslane,
Any custom internal variables values should be related to the current instance.
As bars are being built the script instance does not need to be cloned and remains the same instance. Any internal variables would be kept in memory for that instance.
I've made a modification to the Unirenko bars to add a private bool variable that defaults to false. This variable is changed when the State is Active as the script enables. The value remains true after it is changed for the life of the script instance.
This would imply that the value is not being reset as bars are being built.Attached FilesChelsea B.NinjaTrader Customer Service
- Likes 1
Comment
-
Ok, doing some more checking, I agree there is only a single instance with bars data. So, no need for a clone.
The reason for the confusion on my part is the OnDataPoint member is called once during Configure State, and then subsequent calls are in Active State. Why?
I think I can make this work now, but would like to understand that first OnDataValue call in the Configure state. Should it be ignored or is that a valid first tick of data?
For my bar type, the bars.Count is different on those two initial OnDataValue calls (i.e. 1034 in Configure -> 976 in Active). Almost like a trim has happened. Interestingly, this does not happen with your UniRenko example. My bar type is built with tick data and allows caching.
Comment
-
Hello aslane,
Development says that the first OnDataPoint() is valid and processed.
I did not get a clear response on why State is State.Configure. If this is causing an issue with your code that cannot be worked around we can feature request for this to be changed.Chelsea B.NinjaTrader Customer Service
Comment
-
aslane
I am commenting here bcuz I cannot comment on your user app share post for Better Renko
in your barstype cs file, you are setting the new BarsPeriod enumerator value to 17.
That conflicts with my installation as I have a custom bar type at enum index 17.
You should set your enum value to a very high index, which is unlikely to conflict with existing custom bar type enum indexes, and include a note describing this potential conflict so other users can know how to handle it when they get the error message:
Multiple Bartypes with the same BarsPeriodType were found
Comment
-
Yes, people generally use higher values now (and should), but this code was developed long ago in in NT7 and needs to be backward compatible. You have the source, so can change.
I recently added in Ninja site, as it was no longer available elsewhere. At this point, it is really just a reference, as most people use much more exotic Renkos. If I ever update, I will add a comment explaining.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by andrewtrades, Today, 04:57 PM
|
1 response
5 views
0 likes
|
Last Post Today, 05:02 PM | ||
Started by chbruno, Today, 04:10 PM
|
0 responses
3 views
0 likes
|
Last Post
by chbruno
Today, 04:10 PM
|
||
Started by josh18955, 03-25-2023, 11:16 AM
|
6 responses
436 views
0 likes
|
Last Post
by Delerium
Today, 03:42 PM
|
||
Started by FAQtrader, Today, 03:35 PM
|
0 responses
7 views
0 likes
|
Last Post
by FAQtrader
Today, 03:35 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
5 responses
19 views
0 likes
|
Last Post Today, 03:33 PM |
Comment