• 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

place a midpoint line on an autoscaled indicator

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

    place a midpoint line on an autoscaled indicator

    Hi everyone,
    I would like to place a floating horizontal mid-point line on the ADL indicator (I will re-save it as another name). Since it auto-scales, (and I want it to continue to do so...), how do you read the axis properties to place the line in the middle?

    Thanks in Advance!

    whiterhino

    #2
    Hello,

    You could do this by adding a line in the Initialize() section of the indicator.

    Example:

    Add(new Line(Color.Gray, 30, "Lower"));//where 30 is the default line value

    http://www.ninjatrader.com/support/h...x.html?add.htm

    Let me know if I can further assist.
    Lance B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Lance View Post
      Hello,

      You could do this by adding a line in the Initialize() section of the indicator.

      Example:

      Add(new Line(Color.Gray, 30, "Lower"));//where 30 is the default line value

      http://www.ninjatrader.com/support/h...x.html?add.htm

      Let me know if I can further assist.
      Hi NinjaTrader_Lance,
      Thank you for your reply, I will look into that solution. But I am wary as ADL auto-scales (which is what I want it to do), so the line I wish to place will have to vary with the scale to stay at the mid-point.

      I am thinking I need to access the scale's Max and Min values per bar and calculate the midpoint. Any ideas how it might be done, or another way?

      Thank you!

      Comment


        #4
        If the line needs to be dynamic try adding the following plot and updating the plot value accordingly. The add line I mentioned is not intended to be dynamic.

        Add(new Plot(Color.Blue, PlotStyle.HLine, "myPlot"));// HLine will be a horizontal line

        When setting the plot you would need to define what would constitute the mid point. Would it be the high low of the visible region, or the high low of the past X bars

        Let me know if I can further assist.
        Lance B.NinjaTrader Customer Service

        Comment


          #5
          Hi NinjaTrader_Lance,
          I am looking to do the calculation of the midpoint using the high and low of the visible region.

          Something like: ( ( Max(x) - Min(x) ) / 2 ) + Min(x).

          What are the properties of the visible region's scale? I haven't found anything like that while researching c# so far.

          Comment


            #6
            There isn't a supported way to do this however you can try playing around with ChartControl.Height and see if you can find values that work for you. ChartControl is an unsupported feature so we won't be able to provide assistance in using it but I believe this should help out in your situation.

            Let me know if I can further assist.
            Lance B.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              Is there a way to do this in NT8 now? I have a plot where I need to find the dynamic midpoint, as the scale changes with different timeframes, instruments and price movements.

              Thank you.

              Comment


                #8
                Hello GeorgeW,

                Thank you for your post.

                This is possible in NinjaTrader 8 utilizing OnRender in the indicator. I have attached an example to this post.

                Please refer to the following links for more information:
                Please let me know if you have any questions.
                Attached Files
                Patrick H.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello GeorgeW,

                  Thank you for your post.

                  This is possible in NinjaTrader 8 utilizing OnRender in the indicator. I have attached an example to this post.

                  Please refer to the following links for more information:
                  Please let me know if you have any questions.
                  Hello,
                  The visible scale for the indicator I am using currently goes up to 16-20, but the line is being drawn at about 800, well above what is visible on my screen. Is there a way to restrict the midpoint to what is visible? If not, how do I set up the Onrender code so that it only looks back at the scale over a certain number of bars or period?

                  Thank you.

                  Comment


                    #10
                    Hello GeorgeW,

                    Thank you for your update on this matter.

                    I am not seeing the same behavior on my end. Can you attach a screenshot of the chart as you are seeing it to your response?

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

                    Click here for instructions: http://windows.microsoft.com/en-us/w...#1TC=windows-8

                    Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot 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: http://take-a-screenshot.org/

                    I look forward to your response.
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Partick,

                      I have uploaded screen shots #1 and #2. I have used your exact code, just changing the colour of the line to green. On my normal screen, the left scale only goes up to 13, and the line cannot be seen #1. If I drag the left hand scale down I can see the green line at 600 - #2. The indicator is set up for scale justification to the left.
                      Attached Files

                      Comment


                        #12
                        Hello GeorgeW,

                        Thank you for your response.

                        Can you save this chart template and attach it to your response?
                        You can save the file by right clicking in your chart > selecting Templates > Save As > name the file Support. Then go to Documents\NinjaTrader 8\templates\Chart. Please attach the 'Support.xml' file to your response.

                        I look forward to your response.
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello Patrick,

                          The Xml file cannot be uploaded as it is not supported. I will email it to support for your attention.

                          Thanks.

                          Comment


                            #14
                            Just to update for future reference, I finally got PatrickH's ExampleMidpoint indicator to work while other indicators are loaded by substituting one of his lines. See below.

                            Code:
                            //			float chartScaleYValue = chartScale.GetYByValue(ChartPanel.MinValue + ((ChartPanel.MaxValue - ChartPanel.MinValue)/2));
                            			float chartScaleYValue = chartScale.GetYByValue((chartScale.MaxMinusMin)/2); //WH added 27/05/2917 - this works, original above does it off the visible chart

                            Comment


                              #15
                              Hello,
                              As indicate in my previous post, the middle line now works. The issue I now need to resolve is how to identify when one of my plots crosses this middle line. The middle line position is in pixels due to being created in OnRender, and the plots are based on the left hand scale, so I would assume that I need to convert one to the other so that I can code the condition for when one crosses the other. How would I go about this?

                              Also, can OnRender go before OnBarUpdate so that I can use the position of the line in the CrossBelow of CrossAbove code in the OnBarUpdate section?

                              Thank you.
                              Last edited by GeorgeW; 05-29-2017, 06:05 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by uiwislth, Yesterday, 11:25 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post uiwislth  
                              Started by Steve L, Yesterday, 10:04 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post Steve L
                              by Steve L
                               
                              Started by marianfed, Yesterday, 09:47 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post marianfed  
                              Started by hir04068, Yesterday, 09:29 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post hir04068  
                              Started by iq200, 03-11-2018, 07:49 PM
                              24 responses
                              1,022 views
                              0 likes
                              Last Post mrlucky1x  
                              Working...
                              X