• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawingTools w/PriceLevels Issue

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

    DrawingTools w/PriceLevels Issue

    Effects all fibs, trendlines, pitchforks, any DrawingTool that utilizes PriceLevels, and can be duplicated in 8.11.1 and 8.12.0

    1.) Manually Draw a FibonacciRetracements on any Chart Tab
    2.) Modify Price Levels to Something Completely Different than default
    3.) Now Apply those changes, and Save them as the Default Template..
    4.) Open NS editor and compile anything
    5.) Reload NinjaScript on Chart Tab with Manual DrawObect
    6.) Move Original FibonacciRetracements

    All PriceLevel's Lost..

    Video Demonstration can be found here...

    https://www.screencast.com/t/iddDQ5i4


    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    #2
    Hello -=Edge=-,

    Thank you for the report!

    I have been able to reproduce and will write back with more information as it becomes available.

    Thanks again for bringing this to our attention.
    JimNinjaTrader Customer Service

    Comment


      #3
      Since we are talking about pricelevels here.. I have couple more questions??

      Not sure it should matter, but all my testing was done not connected to data...

      1.) Open OutPut Window
      2.) Open New Chart
      3.) Draw FibonacciRetracement
      4.) Apply the test indy attatched below

      It should work fine, and you'll see 3 print statements in output window..

      1.) Now Reload NinjaScript

      Why is DrawObjects.Count always 0 on any subsequent NinjaScript Reload???


      1.) Now remove all drawobjects
      2.) Remove the indy...
      3.) Draw another FibonacciRetracement
      4.) Apply the test indy again

      Works fine on initial apply, but never seeing any drawobjects on ninjascript reload????


      1.) Now Compile indy to dll assembly and repeat above steps..

      I've tried numerous ways of declaring dynamics and such, but I can't seem to make this work in compiled assembly???



      Attached Files
      -=Edge=-
      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

      Comment


        #4
        Hello -=Edge=-,

        Thanks for your patience.

        The issue boils down to the NinjaScript being cloned upon recompile and the class level properties not being copied over to the new instance. This is more of an issue with the NinjaScript not handling this with the Clone() override. There would not be an ideal solution for the Development team to handle this internally for all NinjaScripts.

        Since the issue has to do with the NinjaScript and not the platform, the task falls on our NinjaScript team and won't be marked with a ticket ID to feature request the additional functionality. We will take on this task as resources allow.

        This particular matter can be understood more in the LifeCycle page of the help guide.

        Note: If you plan to utilize complex class properties on NinjaScript, you can specify your own clone method. However when NinjaScript is compiled in NinjaTrader a new DLL holding the compiled IL code is 'hot-loaded' into NinjaTrader. As a user or developer would try to reload NinjaScript or configure an existing NinjaScript object, any complex class will not resolve since the class will be residing in two different assemblies. This problem cannot be solved with custom clone method and workarounds for this are setting Browsable(false) attribute on that property so it is not cloned or putting the property it its own dedicated assembly.
        NinjaScript LifeCycle - https://ninjatrader.com/support/help...fecycle_of.htm

        Clone() - https://ninjatrader.com/support/help...n-us/clone.htm

        If there is anything else I can do to assist, please let me know.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          The issue boils down to...
          OK.. I've worked with drawobjects quite a bit and guess I'm a bit confused here...

          https://ninjatrader.com/support/help...assemblies.htm

          which issue, of the 3 total, are you referring too?


          I have one issue in post #1
          1.) Lost Price Levels

          and we will call it two and three in post #3...
          2.) DrawObjects.Count = 0 on ninjascript reload
          3.) add pricelevel to drawingtool in dll assembly



          -=Edge=-
          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

          Comment


            #6
            Hello -=Edge=-,

            I had missed the last part of your reply, sorry about that. It looks like item 3 is an issue with writing to dynamic types. I don't have a problem reading from the dynamic type but I have not been able to successfully write to the dynamic type. I'm still working on this and I will get back to you.

            Items 1 and 2 boil down to the same matter where the values are not guaranteed after recompile.

            We have KB'd the matter for the DrawObjects collection:
            When pressing F5 indicator and strategies are created again before the draw objects -> the DrawObjects collection does no longer hold the old instances, but neither does it hold the new instances yet.

            This is an expected behavior currently.
            I'll reach back again on item 3.
            JimNinjaTrader Customer Service

            Comment


              #7
              Hello Edge,

              Reaching to Michael on our QA team, he provided a solution using System.Reflection:

              Code:
              if(dt.ToString().Equals("NinjaTrader.NinjaScript.DrawingTools.FibonacciRetracements"))
              {
              	Print("Found Fib");
              	Print(dt.PriceLevels.Count);
              	
              	Type type 			= dt.PriceLevels.GetType().GetGenericArguments()[0];
              	Assembly assembly 	= type.Assembly;
              	var pl 				= assembly.CreateInstance(type.FullName, false, BindingFlags.CreateInstance, null, new object[] { 55.5, Brushes.Red, 2 }, new System.Globalization.CultureInfo("en-US"), new object[] {});
              	dt.PriceLevels.GetType().GetMethod("Add").Invoke(dt.PriceLevels, new object[] { pl } );
              	
              	Print(dt.PriceLevels.Count);
              	plSet = true;
              	Print("All Good");
              	this.ForceRefresh();
              }
              I've requested that we include information to suggest using System.Reflection for these cases in the Considerations For Compiled Assemblies page of the help guide.

              Please let us know if we can be of further assistance.
              Last edited by NinjaTrader_Jim; 02-16-2018, 03:06 PM.
              JimNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Jim View Post
                Please let us know if we can be of further assistance.
                Thank You Jim!!!.. Works just fine.. Yes, you can do one more thing for me..

                An Easy to Implement, No Brainer, Request...

                In the DrawingTools PriceLevels.cs file, add this constructor just under line 131 in next release!
                Code:
                 
                public PriceLevel(double value, Brush brush, DashStyleHelper dashStyle, float strokeWidth, int opacity)
                {
                     ValueFormatFunc = v => (v / 100).ToString("P", Core.Globals.GeneralOptions.CurrentCulture);
                     Value = value;
                     IsVisible = true;
                     Stroke = new Stroke(brush, dashStyle, strokeWidth, opacity);
                     IsValueVisible = true;
                }
                This will provide the easiest solution to control each pricelevel's DashStyle and Opacity as well...


                Thanks Again!!


                -=Edge=-
                NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                Comment


                  #9
                  Hello Edge,

                  I've submitted your request and will update this thread with a ticket ID when available.

                  Ticket ID: SFT-3050

                  I also wanted to note that discussions with Product Management are leaning against supporting using Reflection and there may be a better solution advised to avoiding using "new" with dynamic types and compiled assemblies at a later point.

                  We hope you are enjoying your holiday!
                  Last edited by NinjaTrader_Jim; 02-20-2018, 02:24 PM.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ralett, Today, 07:29 PM
                  1 response
                  2 views
                  0 likes
                  Last Post NinjaTrader_Marco  
                  Started by bboyle1234, Today, 10:46 PM
                  0 responses
                  1 view
                  0 likes
                  Last Post bboyle1234  
                  Started by swcooke, Today, 04:29 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post swcooke
                  by swcooke
                   
                  Started by bboyle1234, Today, 04:27 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post bboyle1234  
                  Started by swcooke, Today, 03:31 PM
                  2 responses
                  11 views
                  0 likes
                  Last Post swcooke
                  by swcooke
                   
                  Working...
                  X