Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawTools and PriceLevel

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

    DrawTools and PriceLevel

    In reverse engineering DrawingTools in an attempt to learn NT8 development, I noticed that, for example, Lines.cs derive from DrawingTools : Line and GannFan derive from DrawingTools : PriceLevels. Can you explain this?

    #2
    All about the inheritance.

    PriceLevelContainer inherits from DrawingTool so it has the DrawingTool class as its base and adds some items in its class that are used to have multiple price levels.

    Now, GannFan inherits from PriceLevelContainer. So, now GannFan as all the inheritance classes that PriceLevelContainer uses. Fibonacci does the same thing.

    Line doesn't require to have all those extra price levels, so it just needs to inherit from DrawingTool itself.

    You can see what is added in the PriceLevelContainer by looking at the PriceLevels script in the editor.

    Let me know if that made sense.

    Comment


      #3
      GannFann, FiboanncciTools, AndrewsPtichfork, and TrendChannel all use the PriceLevel class, which derives from a DrawingTool just like the Line object.

      PriceLevel is used for storing multiple prices at different levels which can be configured in the UI. There is @PriceLevels.cs object you can review if you needed.

      I'm not sure what your specific question is so sorry if that's not helpful but perhaps enough to get you started. Let me know if you have specific questions.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Can you sum up when one would want to use PriceLevelContainer as opposed to just DrawingTools? What is that "little something extra" that would become a necessity in making a decision?

        Comment


          #5
          If you need to have a drawing tool that uses multiple price levels such as the Fibonacci does. You can add levels and remove them. The code then iterates through the price levels and draws a line or whatever you need it to. Note that this is done in the OnRender() method of the code.

          This also allows the properties portion of the PriceLevelContainer to show up in the UI and be able to adjust them.

          I strongly recommend taking a look at what Fibonacci, or even Andrews Pitchfork, is doing with the price level in the code. This gives a better idea of what to look for and how to effectively use them to your advantage.

          Comment


            #6
            I've been successful in extending FibonacciLevels in order to utilize the PriceLevels object (and move the param where I want).

            However, is it possible to have TWO PriceLevel parameters?

            If so, can anyone point me in the right direction?

            If I do something like this, it refers to the base.PriceLevels object. Is there a simple way to create another instance of this without duplicating all the underlying objects?

            PHP Code:
            [PropertyEditor("NinjaTrader.Gui.Tools.CollectionEditor")]
            [
            Display(ResourceType typeof(Custom.Resource), Name "Levels"Prompt "NinjaScriptDrawingToolsPriceLevelsPrompt"GroupName "My Group"Order 1)]
            [
            SkipOnCopyTo(true)]
            public new List<
            PriceLevelmyPriceLevels
            {
                
            get { return base.PriceLevels; }
                
            set base.PriceLevels value; }

            Any help is greatly appreciated!

            Comment


              #7
              Hello,

              Thank you for the question.

              This is certainly possible but you would need to duplicate some objects. Because you are inheriting from the GannAngleContainer which controls the property PriceLevels, you would need to duplicate the logic for the existing GannAngleContainer in order to do this.

              After duplicating the GannAngleContainer, you could then inherit from this instead which could contain any number of PriceLevel objects.

              I have composed a sample using the GannFan as its base, I just duplicated the logic used for the initial fan so the file is quite large. The changes or duplicated logic has the number 2 at the end of the name like GannAngleContainer2.


              I look forward to being of further assistance.
              Attached Files
              Last edited by NinjaTrader_Jesse; 11-16-2020, 09:19 AM. Reason: updated for current NT8
              JesseNinjaTrader Customer Service

              Comment


                #8
                Just a shot in the dark. Do you have any idea why additions or changes to a PriceLevel would not be saved? They always seem to revert back to their initial state after hitting OK and then going back into edit the params.

                Comment


                  #9
                  Hello,

                  Thank you for the reply.

                  I wanted to check, is this a sample you have created based on what was uploaded or the sample directly?

                  If the sample uploaded is in question, where specifically are you seeing that the levels are not saved? On my end I am seeing the sample I had uploaded is saving the levels and persisting between restarts with the workspace. I did not account for all of the template types so I certainly could have missed something you are now trying.

                  If this is your own version of the sample, I would suggest to compare the differences regarding the PriceLevelContainer used, where in the logic the second price levels is being used to see what may be missing.

                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Thank you for the quick reply. To answer your question, it's in my custom code. However, my first thought is it could be an issue with "order of events".

                    In my VenderLicense() call, I am populating the "PriceLevels" if they are empty. This is great for the very first time the tool is initiated. However, when editing the params, I think it's being called again, before being populated by whatever mechanism that stores and populates individual drawing object parameters. So, it thinks it's empty, and resorts to default.

                    However, I see in @FibonacciTools.cs that defaults are set when State.Configure, so my approach should be fine, which means something else is the issue...

                    I will look closer at details of what could be different. I'm sure I'm doing something wrong...

                    Thanks again!

                    Comment


                      #11
                      Hello,

                      Thank you for the additional details.

                      Please let me know what you locate in the script in this case, the vendor license was an unexpected test that I had not had in mind.

                      The states in NT8 do get called at various different times depending on what is happening in the platform and what menus are opened, so you certainly could be on to what is happening in your script or the order of operations.

                      I believe the sample I had posted was also having this happen before I was initializing the PriceLevels, you may want to check the Log tab or output window to check if while using the vendor licensing if you are getting any exceptions for the property being null. Because the vendor licensing is done in the constructor, that could certainly change the order of operations in the sample.

                      I look forward to being of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        I noticed in your example that the GannAngle2 class was not referenced (utilized the GannAngle class instead). Was this intentional?

                        Comment


                          #13
                          Hello,

                          That was actually intentional, I had intended to duplicate the tool completely so that was carried over but the original GannAngle is still used.

                          This could actually be removed from the sample as it is not really demonstrating anything but was only changed to not cause an error.

                          In order to actually create your own GannAngle class and also use it, you would also have to create your own PriceLevel class as well, kind of a cascade effect with this tool.

                          The PriceLevel class its self has an Attribute that specifically uses GannAngle [XmlInclude(typeof(GannAngle))], Technically GannAngle2 would work but would not be serialized. I felt this was outside of the scope of what was needed in the sample. I will update the sample to not include the extra code that is not needed.

                          I look forward to being of further assistance.
                          Last edited by NinjaTrader_Jesse; 07-01-2016, 11:15 AM.
                          JesseNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by frankthearm, Today, 09:08 AM
                          7 responses
                          29 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by NRITV, Today, 01:15 PM
                          1 response
                          5 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by maybeimnotrader, Yesterday, 05:46 PM
                          5 responses
                          25 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by quantismo, Yesterday, 05:13 PM
                          2 responses
                          17 views
                          0 likes
                          Last Post quantismo  
                          Started by adeelshahzad, Today, 03:54 AM
                          5 responses
                          33 views
                          0 likes
                          Last Post NinjaTrader_BrandonH  
                          Working...
                          X