Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Suggestion to draw "trailing lines" a fixed number of ticks away from High of a bar

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

    Suggestion to draw "trailing lines" a fixed number of ticks away from High of a bar

    Hello, I'm trying to find a way to draw lines(horizontal lines or any other line) that automatically shows a point a fixed number of ticks above the last bar, as soon as the bar closes.
    I thought of using a 1 period moving average and then set a "displacement" of "X" ticks, but the only displacement available is horizontal or "in time".
    MA envelopes use %...
    I'm sure there's an easy way to do this, but I'm not seeing anything in the already built in indicators from NT that allows me to do this.
    Any suggestions?

    #2
    Hello NeoTrader86,

    Thank you for your note.

    I put together an indicator which will draw a horizontal XTicks above the previous bars high. XTicks is a variable you can define when applying the indicator.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you! I'll try to apply the same to the low of bars after importing it to NT. I hope this works

      Comment


        #4
        Sorry. I'm trying to import the file to NT, but the file doesn't appear on the folder that I know it is located in. What is the procedure to integrate the indicator to NT?

        Comment


          #5
          Hello NeoTrader86,

          I have attached the indicator with the .zip format which will allow you to import it via Control Center>Tools>Import>NinjaScript Addon.

          Please let us know if you need further assistance.
          Attached Files
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            It worked perfectly... Thank you very much.... I have a little experience with Java and Python, but not enough to interpret C# and make the same indicator, only to be "X" ticks below the low of the last bar(I know only REALLY basic stuff). I took a look at the source code, but it is way more complicated than I thought. Would it be possible to send me a file with this other indicator, as I described? Drawing a line "X" ticks below the low of the last bar?

            Comment


              #7
              Try adding something like this to the indicator's code:

              Code:
              Draw.HorizontalLine(this, "LLine", Low[1] - XTicks*TickSize, Brushes.Lime);

              Comment


                #8
                I did... I put this right below "Draw.HorizontalLine(this, "HLine", High[1] + XTicks*TickSize, Brushes.Red);".
                I zip the file and try to import it to NT, but when I do, I get this message: "This NinjaScript archive as made from an older, incompatible version of NinjaTrader."

                Comment


                  #9
                  Hello, I thank you once again for sending me this sample code. After digging up a lot, I thought that what I was doing wrong was altering the Script directly with the Notepad++ editor, so I just went to the NT Sript Editor and did it all over again, just copying the logic. It compiled, but the lines are being dra based on the High and Low of the BAR BEFORE THE LAST THAT ALREADY CLOSED, and not on the LAST BAR THAT CLOSED, as it supposed to.
                  I think that this has to do with the Statement "if (CurrentBar < 5) return;", I didn't understand this statement and since there's no identifiable variable on the code with this name (CurrentBar), I couldn't trace it back in the code.
                  Could you explain me the logic of this statement?

                  Comment


                    #10
                    The number within the brackets [1] refers to bars ago, so [1] means 1 bar ago, whereas [0] would mean the current bar.

                    The statement "if (CurrentBar < 5) return;" simply means do nothing if there are fewer than 5 bars on the chart.

                    Comment


                      #11
                      Then it doesn't make sense, the logic that I copied is this:

                      if (CurrentBar < 5) return;
                      Draw.HorizontalLine(this, "HLine", High[1] + XTicks*TickSize, Brushes.Blue);
                      Draw.HorizontalLine(this, "LLine", Low[1] - XTicks*TickSize, Brushes.Red);
                      But when I plot the indicator, it plots on the bar before the last.(I put Ten ticks above and below). I put an image here to show what I mean.
                      When I changed the number between the brackets to "0", it worked, but how can this be? Yesterday it plotted correctly with "1" between the brackets.
                      Attached Files

                      Comment


                        #12
                        The Calculate value will affect the timing: you have 3 choices Calculate.OnBarClose, Calculate.OnPriceChange, or Calculate.OnEachTick.

                        Comment


                          #13
                          Hello NeoTrader86,

                          I have provided a screen shot with the line within the indicator that you would have to modify.

                          We do not build custom indicators or strategies for customers however if you’d like I could have someone from our business development team pass over a list of professional Ninja Script consultants that you could contact about developing this for you.

                          Please let us know if you’d like that information.
                          Attached Files
                          Alan P.NinjaTrader Customer Service

                          Comment


                            #14
                            Thank you very much Alan and tradesmart, I got it... I was able to configure the indicator as I wanted and understood the code... I used today throughout the day and it worked just as I wanted it...
                            Thank you for your time and attention!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by twitch251, Today, 05:14 PM
                            1 response
                            4 views
                            0 likes
                            Last Post NinjaTrader_ShawnB  
                            Started by robforee2, Today, 05:07 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post robforee2  
                            Started by blar58, Today, 03:16 PM
                            1 response
                            6 views
                            0 likes
                            Last Post NinjaTrader_Melissa  
                            Started by alcorr247, Today, 02:52 PM
                            2 responses
                            8 views
                            0 likes
                            Last Post robforee2  
                            Started by Radano, Today, 02:30 PM
                            1 response
                            4 views
                            0 likes
                            Last Post NinjaTrader_ChrisL  
                            Working...
                            X