Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsType Clone never called

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    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:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. 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.
    http://ninjatrader.com/support/helpG...-us/export.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      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


        #4
        Hello aslane,

        The Help Guide does not say that BarsType scripts are cloned (though I know they are at specific times behind the scenes).
        https://ninjatrader.com/support/help.../bars_type.htm

        Can you clarify what the bug is that is causing an error in your script?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          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


            #6
            Hello aslane,

            To confirm you are taking about the State property in OnStateChange is null?

            https://ninjatrader.com/support/help.../nt8/state.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              No, internal object state (i.e. private int x Thats why Clone is needed.

              Comment


                #8
                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 Files
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  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


                    #10
                    Hello aslane,

                    I'll have to ask our developers about that.

                    I appreciate your patience.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      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


                        #12
                        Thanks for the follow up. I can work with it, just needed to understand what was going on.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jerminedop, Today, 12:18 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post jerminedop  
                        Started by cnzaxtoil, Yesterday, 11:38 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post cnzaxtoil  
                        Started by cnzaxtoil, Yesterday, 11:37 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post cnzaxtoil  
                        Started by sukhob, Yesterday, 04:27 PM
                        1 response
                        14 views
                        0 likes
                        Last Post zacharydw00  
                        Started by Bmnaiorwsd, Yesterday, 07:52 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post Bmnaiorwsd  
                        Working...
                        X