Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ZenCortexCLICK, Today, 04:58 AM
                0 responses
                5 views
                0 likes
                Last Post ZenCortexCLICK  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                172 responses
                2,280 views
                0 likes
                Last Post sidlercom80  
                Started by Irukandji, Yesterday, 02:53 AM
                2 responses
                17 views
                0 likes
                Last Post Irukandji  
                Started by adeelshahzad, Today, 03:54 AM
                0 responses
                5 views
                0 likes
                Last Post adeelshahzad  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                13 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X