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

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 -

    BertrandNinjaTrader Customer Service

    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 ScottWalsh, Today, 06:52 PM
                4 responses
                32 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                4 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                19 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                6 views
                0 likes
                Last Post cre8able  
                Started by Haiasi, Today, 06:53 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X