• 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

High Low Plot Pricemarker

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

    High Low Plot Pricemarker

    I have an indicator that draws a line at the low or high of a bar (depending on other conditions) while the bar is in progress. I'd like to add a price marker to that line. From what I have read that is not possible as to have a price marker requires a Plot.

    Thus my question: Is there a plot method for Highs and Lows of a bar, and if so, what is it or where could I find it?

    sandman

    #2
    Hello sandman,

    Thanks for your post.

    Correct, to show a price marker you would need to use a plot. If you did not want to use a plot one alternative is to use Draw.Text().

    There are no plot methods for the highs/lows of the bar. One way you can do this (and you can test with coding) is to use a 1 period SMA set to the High or Low data series. Set the Plotstyle to HLine. This will draw a horizontal line with price marker at whatever data series you select of the current bar. You can set the Calculate mode to be OnEachTick for a more dynamic move on the currently forming bar.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Paul.

      Thanks. Works fine with that 1 period SMA applied once each for High and Low DataSeries. I changed the PlotStyle to Hash and use PlotsColors for 1 bar back as Transparent so that I don't get a line but just the price marker and a tiny hash.

      protected override void Initialize()
      {
      Add(new Plot(Color.Silver, PlotStyle.Hash, "RoundedEMA"));
      Plots[0].Pen.Width = 1;

      Overlay = true;
      PaintPriceMarkers = true;
      CalculateOnBarClose = false;
      }

      protected override void OnBarUpdate()
      {
      if (CurrentBar < 1)
      return;
      RoundedEMA.Set(Instrument.MasterInstrument.Round2T ickSize(EMA(period)[0]));

      PlotColors[0][1] = Color.Transparent;
      }

      Now I'd like to amend this further to only show this price marker depending on the slope of a LinReg. I'd like to see the low pricemarker when the LinReg is rising, and the high pricemarker when the LinReg is falling. I can achieve that with this:

      if (Rising (LinReg(7)))
      PlotColors[0][0] = Plots[1].Pen.Color;

      if (Falling(LinReg(7)))
      PlotColors[0][0] = Plots[2].Pen.Color;

      Only problem I have is that it now of course takes the LinReg based on the High or Low DataSeries. But I'd like it to use the LinReg from the Close Input Series.
      Question: Is it possible to pull in a "Close Data Series" into this indicator, and if so, how? I hope I am somewhat understandable with my question.

      sandman

      Comment


        #4
        Hello sandman,

        Thanks for your reply.

        I don't see where you are applying the high or Low data series in your code so unless you do this when you apply the indicator (through the indicator panel) the code would by default refer to and use the the Close data series.

        Using the LinReg() as an example, look at the helpguide here: http://ninjatrader.com/support/helpG...regression.htm

        When you use LinReg(7) it will default to LinReg(Close, 7). If you really want this to be the High or Low data series you would need to specify in the code LinReg(Low, 7) or LinReg(High, 7).

        The same would apply to EMA(Period) which defaults to EMA(Close, Period)
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul. May thanks for your input. I was able to put it all together now in one indicator. It shows a hash line and pricemarker at the Low of a Bar if a chosen LinReg is Rising, and the High of a Bar if the LinReg is falling (using a High and Low EMA1).

          The only remaining problem I have is that the plot colors and width are not configurable. I would appreciate if you could look this over and tell me what I need to correct. To that end I have included an image of the code I used, a well as a copy of the full indicator if that is easier for you to look at.

          sandman
          Attached Files

          Comment


            #6
            Hello sandman,

            Thanks for your reply

            You can set the width of a plot, for example: Plots[0].Pen.Width = 3;

            You are setting the color to transparent when you don't want to see it. You are setting it to a color when you do want to see it. By setting it to a color in the code section you cannot then change it in the user interface (well you can change it but it will only plot according to what you have set in the code). If you use Color.Empty instead of Color.Gainsboro the plotted color will be as set in the user interface.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thanks for the reply.

              That does not work. When I use "Color.Empty" in the Code it applies "Transparent" throughout -- see attached. Also when I open the indicator panel, the chosen colors have been replaced with "Transparent".

              Any further input?

              sandman
              Attached Files

              Comment


                #8
                Hello sandman,

                Thanks for your reply.

                Try using PlotColors, for example:

                if (Falling(LinReg(Close,period))) // Plots the HIGH hash line and pricemarker when the LinReg falls
                PlotColors[0][0] = Color.Empty;
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by mestril, Yesterday, 10:22 AM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by hir04068, Yesterday, 09:29 PM
                5 responses
                17 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by bubblegum, Today, 03:51 AM
                1 response
                3 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by johnnybegoode, 05-24-2019, 10:16 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by manugarc, Today, 01:15 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X