• 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

Custom drawing tool, advice please

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

    Custom drawing tool, advice please

    Hi,

    I would like to create a custom drawing tool, a variant of "Line". My line is supposed to anchor to a specific bar and price and then go horizontally all the way to the right only (not the left, as "horizontal line" does). So the line has only a single anchor. I will then make the line display some additonal information attached to it.

    After looking through the Line.cs file, I am unsure of how to go about creating a new "MyLine" tool. It seems that all chart line types derive from the Line class, but the actual mechanics of each line is not coded into the derived classes, but into the Line class itself. The selection of available line types is a hardcoded enum within Line.

    Other than copying the whole file and pruning it down to what I need, is there a better method? Could I derive from Line and override the ChartLineType enum to add my own?

    Any advice or a short code outline is much appreciated!

    Thank you,
    Stefan.

    #2
    Hello Stefan,

    In needing to test various drawing tool script methods I actually pulled out the line from the @Lines.cs file.

    This should save you considerable time.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      now that is cool. Thank you very much, I think I get it. Let me look at the code for a while and I should be able to get along. Great!

      Kind regards,
      Stefan.

      Comment


        #4
        maybe something like this.
        Attached Files

        Comment


          #5
          Hi,

          I'm trying to create a new modified "custom" line.
          I'm not an expert with NT, but I try to learn.

          I would like to draw a second line after drawing the first line with the above drawing tool "customline".
          For example: I select two points with the mouse, drawing a line, and as I click the second point and finish drawing the line, NT will draw this line, and another second line starting from the last point I selected and going 5 bars to the right.

          Do you have an idea, where could I continue?
          I studied the CustomLine_NT8 but I don't know where to continue...

          Thanks!

          Comment


            #6
            Hello artson,

            I would recommend viewing the TrendChannel drawing tool script included with NinjaTrader.

            Your script is going to need custom logic to add anchors and control which anchor IsEditing.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks a lot Chelsea

              I'll try to check it.

              Comment


                #8
                Hi,

                I've been looking through your documentation and the example of TrendChannel (and RegressionChannel also..) but I don't reach my target.

                I cannot find the way to create a line (horizontal) starting from a High (for example) of a bar located 10 bars back from the bar I selected.
                I don't understand the way of switching from bar coordinates (price and time) to screen coordinates (x,y)....
                I use "SharpDX.Vector2" and "RenderTarget.DrawLine" and more but I cannot find it....

                Maybe you can help me or give me some advices....

                Thanks in advance!!

                Comment


                  #9
                  Hello arston,

                  Thanks for your question.

                  ChartControl.GetXByBarIndex and ChartScale.GetYByValue can be used to convert chart values into chart coordinates. Keep in mind when using these methods, we are using BarIndexes as opposed to Bars Ago indexes, so a "BarsAgo" reference would be an index of CurrentBar - 10.

                  Also to note, when you are referencing values from a Series or PriceSeries object outside of OnBarUpdate, you should use the GetValueAt() method. So referencing the Close of the current bar would look like:

                  Close.GetValueAt(CurrentBar)

                  Publicly available documentation on the items discussed can be referenced below.

                  ChartControl.GetXByBarIndex - https://ninjatrader.com/support/help...bybarindex.htm

                  ChartScale.GetYByValue - https://ninjatrader.com/support/help...etybyvalue.htm

                  GetValueAt - https://ninjatrader.com/support/help...getvalueat.htm

                  Please let us know if we can be of further assistance.
                  JimNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks for the help Jim,

                    I'm still trying it......

                    I', at "public override void OnRender(ChartControl chartControl, ChartScale chartScale)" (creating a DrawingTool)
                    and using "double highPrice = Bars.GetClose(10);"
                    I get the error CS0120 -> a reference is required for the field, method or property not static 'NinjaTrader.Data.Bars.GetClose(int)....

                    why?.....????

                    Thanks,

                    Comment


                      #11
                      Ok, I finally managed to solve it!

                      I have to define previously the bars:
                      Bars baseBars = GetAttachedToChartBars().Bars;

                      Thanks a lot!!

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Nat11, Today, 04:30 AM
                      1 response
                      12 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by Option Whisperer, Yesterday, 11:50 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post Option Whisperer  
                      Started by TraderJim618, Yesterday, 01:20 PM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_ChrisL  
                      Started by drpapp, 01-24-2019, 06:57 AM
                      6 responses
                      74 views
                      1 like
                      Last Post brucerobinson  
                      Started by ttodua, 12-06-2019, 11:40 PM
                      1 response
                      13 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X