Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need Help w/ Simple Horizonal Line Indicator

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

    Need Help w/ Simple Horizonal Line Indicator

    I have no clue as to how to program indicators.

    I want to be able to input a price, and have the indicator draw a horizontal line 2 points above and 2 points below the the input price.

    I need the entire indicator code if anyone is willing to help.

    Thank you.

    #2
    jdlaw47, welcome to our forums - unfortunately we could not custom create this study for you, but I'm leaving the thread open if anyone from the community picks it up. Alternatively if you seeked to have this created professionally for you, then you could always contact a NinjaScript consultant -

    Comment


      #3
      Problem with Indicator

      I have programmed an indicator that allows me to input a price level, and the indicator then plots a horizontal line at the input price, and 3 lines above and 3 lines below the price level.

      If I do not originally set the indicator to plot all seven lines, it does not plot any lines.
      If I then set the indicator to plot seven lines, I can then change the number of lines plotted.

      I am unable to fix this anomaly.

      Also in the plots box, line 7 shows up twice.

      Any help would be appreciated.

      The indicator is attached.

      Thanks
      Attached Files

      Comment


        #4
        Originally posted by jdlaw47 View Post
        I have programmed an indicator that allows me to input a price level, and the indicator then plots a horizontal line at the input price, and 3 lines above and 3 lines below the price level.

        If I do not originally set the indicator to plot all seven lines, it does not plot any lines.
        If I then set the indicator to plot seven lines, I can then change the number of lines plotted.

        I am unable to fix this anomaly.

        Also in the plots box, line 7 shows up twice.

        Any help would be appreciated.

        The indicator is attached.

        Thanks
        You are unconditionally setting your Plot colors. You should make them conditional, just as you did when you declared them. You will likely be seeing errors in your log about index out of bounds.

        Comment


          #5
          Hi. Thanks for the reply.

          I know almost nothing about programming. This is my first attempt. I do not know how to set the plot colors conditionally.

          Comment


            #6
            Originally posted by jdlaw47 View Post
            Hi. Thanks for the reply.

            I know almost nothing about programming. This is my first attempt. I do not know how to set the plot colors conditionally.


            Your Plots are declared conditionally.
            Code:
            if (lineCount >= 1)  Add(new Plot(Color.Crimson, PlotStyle.Line, "Line1"));
            et.c.,

            You are setting them conditionally.
            Code:
            if (lineCount >= 2)  Line2.Set(midPoint + 2.75);
            et.c.,

            Now change the colors in the same way, conditionally.
            Code:
             
            if (lineCount >= 2) Plots[2].Pen.Color = Color.DarkOrange;
            et.c.,

            For someone who thinks that you cannot program, that is a pretty good first effort. Methinks that you shall soon be a master.

            Comment


              #7
              Thank you so much for the information, koganam. I'll let you know how it turns out after I make the changes.

              Comment


                #8
                Good morning kogonam. I set the color and linewidths conditionally as you suggested and the indicator now works well.

                Thank you so much for your input and willingness to help. You explanation of how to set conditionally was excellent.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                557 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X