• 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

Plot a dot "x" points above high and below low

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

    Plot a dot "x" points above high and below low

    I would like an indicator to plot "x" points above the high and below the low of the bar.

    Where x is an input.

    So the indicator would have 2 plots. Ideally dot above the high would be green and dot below the low would be red.

    Would appreciate code to do the above.

    #2
    skiguy, easiest would be expressing your distance in ticks, since in NinjaScript you could natively access the TickSize - http://www.ninjatrader.com/support/h...7/ticksize.htm

    So you can make yourself an indicator with one input and two plots for example and add in your input as multiples of the ticksize.

    i.e. Plot0.Set(High[0] + (YourInput * TickSize));

    The colors for the plot could be set from the initial config screen of the indicator wizard as well.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by skiguy View Post
      I would like an indicator to plot "x" points above the high and below the low of the bar.

      Where x is an input.

      So the indicator would have 2 plots. Ideally dot above the high would be green and dot below the low would be red.

      Would appreciate code to do the above.
      Alternatively to a plot method you can also use DrawDot.

      DrawDot("tag1", true, 0, Low[0] - 3* TickSize, Color.Red);
      DrawDot("tag2", true, 0, High[0] + 3* TickSize, Color.Green);

      These examples would draw a dot 3 ticks above or below. You can of course make the 3 into a variable. This example would only draw two dots on the most current bar and because the tags are the same bar to bar it would automatically erase the dots on the previous bar(s).

      If you wanted to keep each and every dot, you would need to make the "tag" name unique. this can be done with the code "tag1"+CurrentBar.

      DrawDot("tag1"+CurrentBar, true, 0, Low[0] - 3* TickSize, Color.Red);
      DrawDot("tag2"+CurrentBar, true, 0, High[0] + 3* TickSize, Color.Green);

      Hope this helps.

      Comment


        #4
        I am new to this. Only managed to colour code an existing oscillator before. Rising versus falling (with some help).

        I have not coded an indicator from scratch.

        Would someone be good enough to create an indicator for me based on the below posts.

        My email is [email protected] if you prefer email.

        Any help would be appreciate.

        Comment


          #5
          So here is what I came up with and it seems to work.

          I used the Wizard to come up with the initial code then modified the code.

          So far so good

          ///<summary>
          /// This method is used to configure the indicator and is called once before any bar data is loaded.
          ///</summary>
          protectedoverridevoid Initialize()
          {
          Add(
          new Plot(Color.FromKnownColor(KnownColor.DarkGreen), PlotStyle.Square, "HighFilter"));
          Add(
          new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Square, "LowFilter"));
          Overlay =
          true;
          // Calculate on the close of each bar
          CalculateOnBarClose = false;
          }
          ///<summary>
          /// Called on each bar update event (incoming tick)
          ///</summary>
          protectedoverridevoid OnBarUpdate()
          {
          // Use this method for calculating your indicator values. Assign a value to each
          // plot below by replacing 'Close[0]' with your own formula.
          HighFilter.Set(High[0]+myInput0);
          LowFilter.Set(Low[0
          ]-myInput0);
          }

          Comment


            #6
            Why one approach over the other?

            Why would one use this approach as opposed to using the Plot0.Set(High[0] + (YourInput * TickSize)); approach?

            Originally posted by Tasker-182 View Post
            Alternatively to a plot method you can also use DrawDot.

            DrawDot("tag1", true, 0, Low[0] - 3* TickSize, Color.Red);
            DrawDot("tag2", true, 0, High[0] + 3* TickSize, Color.Green);

            These examples would draw a dot 3 ticks above or below. You can of course make the 3 into a variable. This example would only draw two dots on the most current bar and because the tags are the same bar to bar it would automatically erase the dots on the previous bar(s).

            If you wanted to keep each and every dot, you would need to make the "tag" name unique. this can be done with the code "tag1"+CurrentBar.

            DrawDot("tag1"+CurrentBar, true, 0, Low[0] - 3* TickSize, Color.Red);
            DrawDot("tag2"+CurrentBar, true, 0, High[0] + 3* TickSize, Color.Green);

            Hope this helps.

            Comment


              #7
              Originally posted by skiguy View Post
              Why would one use this approach as opposed to using the Plot0.Set(High[0] + (YourInput * TickSize)); approach?
              Great question, 2 answers:

              A) I was taking the approach that you may be unfamiliar with coding and drawdots is quite straightforward it its use. NinjaTrader did a great job a looking at what specific tools would be easiest for user implementation, thus Drawdots, drawTriangleUp, and many others if you look at the listing in the user help file. Plot can be any number of things and thus can be more complex.

              B) If you are drawing dots on every candle the plots is a good way to go. If you are drawing the occasional dot, say to mark a specific event or occurrence, then Drawdots is the way to go.

              So in summary, in other terms, Plots is like a tool chest full of tools to do dang near anything while Drawdots is a 7/16" wrench.

              Hope this helps.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Emma1, Today, 02:42 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_DrewO  
              Started by fx.practic, Today, 03:10 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by jertrade, Today, 02:50 PM
              2 responses
              10 views
              0 likes
              Last Post jertrade  
              Started by RedDuke, Today, 01:59 PM
              1 response
              18 views
              0 likes
              Last Post NinjaTrader_Kate  
              Started by MarianApalaghiei, Today, 01:18 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_PatrickG  
              Working...
              X