• 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

Hiding a plotted DataSeries in an indicator

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

    Hiding a plotted DataSeries in an indicator

    I have an indicator which calculates support/resistance levels and displays them with DrawHorizontalLine. These "levels" are not "Plotted", therefore they are not used in AutoScale.

    However, as prices approach one of these levels I would like the S/R line to come on screen prior to the currentbar actually reaching that line, so I can observe price behaviour as it approaches S/R.

    I can do this by adding a plot, and letting AutoScale=true make the S/R line visible. This would then make public those plotted values, and there is no reason, since they are used only for controlling "white space" on the chart.

    Ideas?

    #2
    imported post

    You can control the chart white space by override the GetMinMaxValues() function,
    let me know if you need help.

    Muly
    Final
    http://fin-alg.com/

    Comment


      #3
      imported post

      Thanks for the reply. I'm not a good enough programmer to take this nugget of wisdom and run.

      If the market is at 801.1 and I have a Resistance at 802.5 (15 ticks away), I want to make the Resistance Line appear on screen (if it is not already visible).

      More help please.

      Comment


        #4
        imported post

        Why not go with your second approach, and try something like:
        AutoScale = Math.Abs(Close[0] - supportLineValue)/ TickSize> 14 ? true: false;
        I have never tried this but I believe that AutoScale property can be set dynamically.

        Ray
        RayNinjaTrader Customer Service

        Comment


          #5
          imported post

          Thanks Ray,

          I was trying to make the S/R lines visible without making public useless data.

          If I understand your code sample, it will only work if there is a plotted element that AutoScale can process. If I do that, those values are made public, but they have no value to the public.

          Is there a way to Plot without making the plotted values public, and still have those values considered by AutoScale?

          I get the idea that AutoScale evaluates all plots (Where AutoScale is true) and produces the values held by GetMinMaxValues(), Raditz was proposing to Directly set GetMinMaxValues(), effectively bypassing AutoScale. This approach (if I understand it right) will do what I want. However I still can't figure out the Syntax.


          Comment


            #6
            imported post

            Adding a plot always increments the Values[] array by adding an object. The Values array is always public.

            GetMinMaxValues() will work as Muly suggested but this is outside of what NinjaTrader will support at this time. Muly might be able to provide you with a sample that will point you in the right direction.

            Ray
            RayNinjaTrader Customer Service

            Comment


              #7
              imported post

              Use this as a psedo code, it is not complete nor tested code

              Code:
              public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
              {
               //Go over all the visible bars in the chart
               for (int i = 0; i < ChartControl.BarsPainted; i++)
               {
                int barNo = ((chartControl.LastBarPainted - chartControl.BarsPainted) + 1) + i;
                if (barNo>= 0) && (barNo< Bars.Count)
                {
                 if (R2.Get(num3) - max < 5 * TickSize)
                 {
                  //R2 is within 5 ticks from the visible area of the chart, make it visible
                  max = Math.Max(max, R2.Get(num3)+2*TickSize);
                 }
              
                 if (min - R2.Get(num3) < 5 * TickSize)
                 {
                  //R2 is within 5 ticks from the visible area of the chart, make it visible
                  min = Math.Min(min, R2.Get(num3)-2*TickSize);
                 }
                 
                }
               }
              }
              Muly
              Final
              http://fin-alg.com/

              Comment


                #8
                imported post

                Muly Thanks,

                This is the code I ended up with. I removed your loops checking all bars on the chart, evidently AutoScale does this. Working well so far.
                [line] OnBarUpdate()
                {
                (FoundValue)= Next Resistance above Close[0]
                (FoundIncr)=Distance from FoundValue to Support below Close[0]
                }

                public override void GetMinMaxValues(ChartControl chartControl, ref double min, ref double max)
                {
                // define variables using values from OnBarUpdate()
                if (Math.Abs(ChartControl.LastBarPainted-Bars.Count)<10)
                {
                double above=FoundValue;
                double below=FoundValue-FoundIncr;
                if (above - High[0] < FoundIncr/ 2 )
                max = Math.Max(max, above + 2*TickSize);
                if (Low[0] - below < FoundIncr/ 2 )
                min = Math.Min(min, below - 2*TickSize);
                }
                }

                [line]

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by lavalampmj, Today, 06:07 PM
                1 response
                6 views
                0 likes
                Last Post bltdavid  
                Started by Sameer, Today, 04:40 PM
                1 response
                35 views
                0 likes
                Last Post NinjaTrader_EricB  
                Started by Teebone21, Today, 04:34 PM
                0 responses
                9 views
                0 likes
                Last Post Teebone21  
                Started by KarstenKafl, Today, 03:34 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by punkiy2111, Today, 03:29 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_BrendanC  
                Working...
                X