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

BarsTypes, Custom Type, Valid States ?

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

    BarsTypes, Custom Type, Valid States ?

    Hello,
    I am farting around with creating a custom bar type.
    I am using Playback Connection, Market Replay, and Tick Replay is enabled for the Data series. NT version is 8.0.27.1 64-bit, SIM License

    In my "BarsType" script file, I am using the Print() method for simple debugging.

    I wrote some Print() commands inside State.Configure
    Code:
    Print(DateTime.Now.ToString("HH:mm:ss.fff") +", BarsTypes State= "+ State.ToString() );
         // 12:44:08.213, BarsTypes State= Configure
    Print("BarsTypes Name= "+ Name +", DataBarsTypeRange= "+ Custom.Resource.DataBarsTypeRange +", Value= "+ BarsPeriod.Value +", MDtype= "+ BarsPeriod.MarketDataType );
         // BarsTypes Name= 20 Range, DataBarsTypeRange= {0} Range{1}, Value= 20, MDtype= Last​
    Then saved and compiled.
    I have the Output window open.

    I noticed when I moved my mouse to hover over the chart using this custom bar type, I get a continuous stream of lines being written in the output window. This happens when the Playback head is NOT running.

    Is this expected? Does that mean the bars object is constantly in the state of Configure? Or could my NinjaTrader installation be corrupted?

    After I disconnect the Playback Connection, and move my mouse into the chart area again, the print statements continue, same as before.


    I read in the Help Guide that I shouldn't try to access the Bars object until the state of DataLoaded, but I assume that concept is for "Indicator" types.
    But I tried it anyway.
    In my custom BarsType script, I added a state for DataLoaded, but none of the Print commands I put inside there do anything, so I'm wondering if that is not a valid state for a BarsType ?


    Thank you.

    #2
    Hello, thanks for writing in. The State.Configure section will only run when the data series menu is pulled up. You may have print statements in some mouse move or on window focused event of the same bar type script or in another script if you are seeing prints occur when you move or click the mouse.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Update:
      I noticed it is printing 2 Bar Objects,
      Code:
      13:02:47.633, BarsTypes State= Configure
      BarsTypes Name= 1 Range, DataBarsTypeRange= {0} Range{1}, Value= 1, MDtype= Last
      13:02:47.633, BarsTypes State= Configure
      BarsTypes Name= 20 Range, DataBarsTypeRange= {0} Range{1}, Value= 20, MDtype= Last
      13:02:47.738, BarsTypes State= Configure
      BarsTypes Name= 1 Range, DataBarsTypeRange= {0} Range{1}, Value= 1, MDtype= Last
      13:02:47.738, BarsTypes State= Configure
      BarsTypes Name= 20 Range, DataBarsTypeRange= {0} Range{1}, Value= 20, MDtype= Last​
      But on my chart, DataSeries, there is only 1 set of data attached to the chart.

      Comment


        #4
        Thanks Chris, I assumed it would only be in Config state when the Properties dialog box was displayed, that is why I wrote in.
        But this is the only BarsType script which I have ever touched, so I can't imagine there are any other scripts doing this. And it does not do this for other chart windows built from time, nor tick bars.

        The prints I am seeing are the statements I have put in my custom bar config state, so it's not some other script being triggered on mouse move. etc.


        Something has not been working correctly for many weeks.

        If I want to nuke my NinjaTrader installation, and start over completely fresh, are there any Windows Registry Keys that need to be removed before a new installation?

        I'll make a backup, but I suspect that backup will have some bad corruption in it.

        I'll also copy all files under "MyDocuments/Ninjatrader 8" to a separate storage location, and then import my indicators one-by-one as needed.

        Thanks

        Comment


          #5
          Hi, Could you reproduce this with this simple copy of the Tick bars type?
          Attached Files
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Yes, same result
            after I added these 2 print commands at the end of state.Config...

            Code:
            Print(DateTime.Now.ToString("HH:mm:ss.fff") +", BarsTypes State= "+ State.ToString() );
            Print("BarsTypes Name= "+ Name +", DataBarsTypeRange= "+ Custom.Resource.DataBarsTypeRange +", Value= "+ BarsPeriod.Value +", MDtype= "+ BarsPeriod.MarketDataType );​
            16:36:20.586, BarsTypes State= Configure
            BarsTypes Name= 1 Tick, DataBarsTypeRange= {0} Range{1}, Value= 1, MDtype= Last
            16:36:20.586, BarsTypes State= Configure
            BarsTypes Name= 150 Tick, DataBarsTypeRange= {0} Range{1}, Value= 150, MDtype= Last
            16:36:20.710, BarsTypes State= Configure
            BarsTypes Name= 1 Tick, DataBarsTypeRange= {0} Range{1}, Value= 1, MDtype= Last
            16:36:20.710, BarsTypes State= Configure
            BarsTypes Name= 150 Tick, DataBarsTypeRange= {0} Range{1}, Value= 150, MDtype= Last
            16:36:20.853, BarsTypes State= Configure
            BarsTypes Name= 1 Tick, DataBarsTypeRange= {0} Range{1}, Value= 1, MDtype= Last
            16:36:20.853, BarsTypes State= Configure
            BarsTypes Name= 150 Tick, DataBarsTypeRange= {0} Range{1}, Value= 150, MDtype= Last
            16:36:20.955, BarsTypes State= Configure
            BarsTypes Name= 1 Tick, DataBarsTypeRange= {0} Range{1}, Value= 1, MDtype= Last
            16:36:20.955, BarsTypes State= Configure
            BarsTypes Name= 150 Tick, DataBarsTypeRange= {0} Range{1}, Value= 150, MDtype= Last​
            it is only 1 dataset on the chart, using 150 as BarsPeriod.Value, but a 2nd bar set of value 1 is being printed.
            and I restarted the NinjaTrader app.

            it is still behaving this way.


            can you answer my question about the re-installation?

            Comment


              #7
              Hi, I do see the 1 being printed. The SetDefault state has this line in it where it sets the Value to 1 during initialization, changing this to 150 or whatever default you want will fix that:

              BarsPeriod = new BarsPeriod { BarsPeriodType = (BarsPeriodType) 2023, BarsPeriodTypeName = "MyTickBarsType(2023)", Value = 1 };

              Sorry I did not see your question about a clean installation. You do not need to edit the registry, all the user data is stored within Documents\NinjaTrader 8, so uninstalling does not touch this folder. Below are instructions on setting up a completely clean environment:

              1.Close all running applications.

              2. Navigate to your Documents folder > Right-click on the 'NinjaTrader 8' folder > Rename > rename the folder to 'NinjaTrader 8 OLD'. DO NOT delete this folder.

              3. Log into your user dashboard and click "Download" at the bottom left of the page to download the latest installer, run this installer while NinjaTrader is closed.

              [https://account.ninjatrader.com/welcome]

              4. ​This will generate a brand new "NinjaTrader 8" folder in the Documents. This is where all your user data is stored, just uninstalling from the Control Panel will not modify this folder. To revert back to your old installation, rename "NinjaTrader 8" to "NinjaTrader 8PREV" and rename "NinjaTrader 8OLD" back to "NinjaTrader 8" NinjaTrader looks for a folder called "NinjaTrader 8" in the documents to operate.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                That's in the SetDefaults state, so I expected that would be superseded by the override

                Code:
                public override void ApplyDefaultValue(BarsPeriod period)
                {
                   period.Value = 150;
                }​
                When does that override get called to set the period value to 150 ?


                ===================
                One more question about the renamed folder OLD, if I copy or move a *.cs file, from OLD into NT 8 folder, and then compile from the NT Editor, will NT have my .cs file compiled into NinjaTraderCustom.dll ?

                Or do I need to use Tools > Import and import that cs file into NinjaTrader?

                I plan on reinstalling everything this weekend.

                I am only going to import the cs files one at a time, to try to isolate which file might be causing this bad behavior.

                Comment


                  #9
                  In addition to the instance of the BarsType on the chart isn't there another instance created to appear in the dropdowns on Data Series properties? You're getting a State.Configure in both of those.

                  Think about this - it has to instantiate every BarsType just to get the BarsType's name so it can show them all in the dropdown. That means every BarsType gets a State.Configure whether it's on the chart or not. And, if it is on the chart, it gets an extra one so it can appear in the dropdown.

                  I think, for this reason, you're chasing your tail here.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Hi, there are many instances of the script created that are not used like the final instance that you see on the chart, see the description of the lifecycle of NinjaScript objects here:



                    For the re-installation process, if you have loose .cs files that are in your Indicator/Strategy/Addon/Bartype folders, you can just move those into the respective folder from the Windows file explorer. If you have a DLL and .cs together that are in your NinjaTrader 8\bin\Custom folder, you will need to move both of the files (DLL and .cs) into the respective folder of the new installation and also right click the NinjaScript Editor>References>Add the reference to the dll after you have moved it over. You can only use Tools>Import on .zip files.
                    Chris L.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks. I guess I didn't explain my situation well enough. When I move my mouse over the chart area, there is no DataSeries dialog box open, it is just a chart without any UI configure elements open, therefore I don't expect it to be triggering the State of Config.
                      I think that the lack of other posts in the forum describing this behavior, indicates this is just a weird bug happening in a defective installation environment.
                      I will report back next week to clarify after I reinstall.
                      Thanks for the tip on being able to move .cs files into the bin /* folders without needing to import...

                      Comment


                        #12
                        Well, after a rename of the custom folder, and a fresh installation, I am still having problems with market replay, but it does not relate to this thread regarding the custom bar type, I have not even used that custom bar type cs file yet, but I will create a new thread which describes the write lock error which freezes the playback.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by BarzTrading, Today, 07:25 AM
                        2 responses
                        24 views
                        1 like
                        Last Post BarzTrading  
                        Started by devatechnologies, 04-14-2024, 02:58 PM
                        3 responses
                        20 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by tkaboris, Today, 08:01 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post tkaboris  
                        Started by EB Worx, 04-04-2023, 02:34 AM
                        7 responses
                        163 views
                        0 likes
                        Last Post VFI26
                        by VFI26
                         
                        Started by Mizzouman1, Today, 07:35 AM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Working...
                        X