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!
See more
See less

Partner 728x90

Collapse

Indicator Voodoo

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

    Indicator Voodoo

    This is driving me nuts.

    I load an indicator, during the startup method. I assign a property on the indicator to something. I then switch timeframes on the chart. The property I set before is related to the timeframe and I expect the property to be updated. I see it in the "watch window", the startup method runs again, the afforementioned property gets assigned its new value. Them BAM! It goes back to the freaking old value!

    I'm going nuts here! Is there some kind of voodoo serialization at work? I've tried calling dispose() on just about everything I can, but it won't forget the previous value.

    How can I make the indicator start with a clean slate and forget EVERYTHING before I changed the timeframe? I want to start afresh...

    #2
    I have tracked this voodoo down to the attached stacktrace to the Clone and CopyTo methods of the IndicatorBase class.

    How can exclude a property in my indicator from this cloning/copying process? I don't want the property to be set in this manner I need to control the value myself - the fact that the indicator has restarted means that the previous property is now incorrect so I don't want it to be re-set.
    Attached Files

    Comment


      #3
      Hello reach4thelasers,

      I'd like to clarify what you are trying to do.

      You have a public property that is set by the user. Then in OnStartUp you are setting this value using a calculation and ignoring what is set by the user, is this correct?

      (Is this to prevent the user from being able to make certain selections based on the timeframe?)
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello reach4thelasers,

        I have made a simple script to test this.

        The script will print to the output window the interval of the bar of the chart..

        Please add this indicator to a chart and try setting the value and then changing the interval, instrument, or any other data series settings.

        Does the value of the ATestProperty public variable reflect the user set value or the interval of the chart?

        (Please include a screenshot of the output window and a screenshot of the chart)

        To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

        Click here for instructions

        Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

        Click here for detailed instruction
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hey Chelsea,

          I've modified your script and stripped out various parts from my system to illustrate the problem.

          in the Intitalise method I am inspecting the BarsPeriod.Id and Value from the primary data source and using this to make a decision in a nested switch statement about what my Intermediate and HigherTimeframes are going to be.

          I used Add(instrument, period, value) to add the intermediate timeframe.

          and I assign a field on the indicator to store the higher timeframe Period object. I want this property to be public as I need the value exposed to several other parts of the system, including a "MetaDataRender" which prints various information on the chart and debug window.

          I've added part of the code for the MetaDataRenderer to the indicator to print out the timeframe info.

          As you will see, when you add the indicator to a chart, the three timeframes are printed correctly. If you then switch timeframes, the switch statement runs again, the intermediate timeframe is re-assigned, the HigherTimeFrame Period property changes correctly, but then is miraculously overwritten by the voodoo clone and copyTo methods I describe.

          If you place a debug watch on that field/property, and also put a breakpoint on the set{} of the Property you can see that despite this property being assigned correctly is being overwritten by some unwanted voodoo magic.
          Attached Files

          Comment


            #6
            Hi reach4thelasers,

            Just to clarify, the _higherTimeframePeriod is the variable you are referring to, correct?

            I can see where you are setting this, however, where are you printing the value of this to see that it has changed? (Are you wanting me to look at the draw text that is appearing on the chart?)

            Below is a link to a video for what I am seeing when I change the interval on the chart.
            (I made a video because these are not being printed so I couldn't copy and paste)

            http://screencast.com/t/JfUFDivZ

            So you have some hard coded intervals that are allowed. When I use one of the intervals, the time frame draw text reflects the primary bar.

            Am I testing this incorrectly?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hey Chelsea. Thanks for your time investingating this.

              Yes, the primary bar series changes correctly. As does the intermediate. When you change the primary from 1m to 2m to 3m.... notice that the Intermediate timeframe changed from 5m to 10m to 15m. The Higher timeframe is stuck on 15m - despite being explicitly set in the switch statement.

              Steps to reproduce:
              Add the indicator to a different instrument (don't use one you've used before), use a 3m timeframe
              - note the highertimeframe value (should be about 45m)
              - switch to 1m / 2m / 1h (htf is still 45m)
              - place a breakpoint in the switch statement at and also on the set {} section of HigherTimeFramePeriod property
              - put a 'watch' on _higherTimeframePeriod field

              - switch timeframes and debug the switch statement - note the _higherTimeframePeriod field being assigned to correctly as per the logic in the switch
              - continue to run the script, debugger will break into the assignment section of the property and assign it back to the previous value of 45m (stack trace shows that it has been triggered by Copy/clone methods)
              - switch between any timeframes - note that the field is assigned by the switch statement correctly and voodoo switches it back to 45m

              I'm in the process of porting over to NT8 - hopefully it won't be an issue. I did get around this oddity by exposing the field via a public method rather than a property GetHigherTimeFrame() { return _higherTimeFramePeriod; }
              the voodoo can't touch that.

              It needs to be public as I'm accessing it from other classes, I didn't need or expect it to be assigned externally though..

              BTW you guys are the most technically adept customer support team I've ever dealt with. I was wondering if the support team is actually manned by the engineering team?
              Last edited by reach4thelasers; 09-21-2015, 05:49 PM.

              Comment


                #8
                Hello reach4thelasers,

                Try the attached indicator SecondarySeriesSwitch.

                Below is a link to a video test of this.
                http://screencast.com/t/3J89rEKiNEM
                Attached Files
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  that doesn't solve my requirement of having the value exposed as public - you're assigning it to a private field which the voodoo cannot access.

                  The problem is that when you assign a public property to a value it gets overwritten automatically by the value of the previous period selection.

                  It doesn't matter now anyway because I got around the problem by exposing it as a public method:

                  Period GetHigherTimeframe() { return _highterTimeFrame; }

                  Comment


                    #10
                    Hello reach4thelasers,

                    Here is the same script with a public variable to return this added in. (You of course would not want this to be settable)
                    Attached Files
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Ok cheers for your help - glad we got to the bottom of that. Looks like NT8's state-based setup will allow us to prevent this weirdness in the future as it has different states for defaults/configure and its more obvious what is happening and when!
                      Last edited by reach4thelasers; 09-24-2015, 02:36 AM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by geotrades1, Today, 07:54 AM
                      5 responses
                      11 views
                      0 likes
                      Last Post geotrades1  
                      Started by Aviram Y, Today, 06:03 AM
                      1 response
                      7 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by leonardomocci, Today, 08:28 AM
                      0 responses
                      2 views
                      0 likes
                      Last Post leonardomocci  
                      Started by prisonbreaker82, 02-24-2024, 11:16 AM
                      3 responses
                      36 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by bill2023, Today, 08:21 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post bill2023  
                      Working...
                      X