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

Instead of using "Bars Ago"

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

    Instead of using "Bars Ago"

    Hello,
    If I want to write a code for drawing a simple "Ray" or "Segment Line" , instead of using High[15] can I specify a specific bar with it's time stamp.
    For example if I want the segment line to start at the high of the 9:32:00 bar and end at the high of 10:16:00 bar , how can this be coded?

    #2
    Hi yellowTrader - you can use GetBar() for this - http://www.ninjatrader-support.com/H...V6/GetBar.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,
      I just can't figure out whats wrong with the code below.
      It is intended to draw a line from the high of the "barsAgo" to the high of the current bar but for some reason it doesn't work!!! what seems to be the problem?

      if (ToDay(Time[0]) >= ToDay(2009, 2, 10)
      && ToTime(Time[
      0]) >= ToTime(8, 30, 0))
      {
      int barsAgo = GetBar(new DateTime(2009, 2, 11, 9, 40, 0));
      DrawLine(
      "My line" + CurrentBar, barsAgo, High[barsAgo], 0, High[0], Color.White, DashStyle.DashDot, 2);
      }

      Comment


        #4
        Doesn't work as in how does it not work? Please clarify on what behavior you are seeing. Always remember to check Control Center for errors too. Thank you.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I mean that it draws a line from the high of "barsAgo" to the high of all the bars while I only need to draw a line to the high of the current bar. And obviously as a new bar is created it should adjust to that new bar. Right?

          Comment


            #6
            If this is the behavior you want please do not use unique object names. Remove the "+ CurrentBar" from the name string.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Ok. That worked but isn't it suppose to update each time a new bar is added?
              High[0] means the high of the current bar. Right? so how come it doesn't draw to the high of the current? (Note :current bar is changing every time a new bar is generated)

              Comment


                #8
                Are you running this on CalculateOnBarClose = true? If you want this to updated on every tick set this to false in your indicator settings or Initialize() in the code.

                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  I got it ."calculateonBarsClose" was the problem.
                  How about if I want it to be drawn to the high of a specific bar and end there ( i.e. a specific bar with a time stamp) just like the starting point of the line?

                  Comment


                    #10
                    You can use the same procedure as for the starting point of the line. You will need to use the endBarsAgo and endY parameters then - http://www.ninjatrader-support.com/H.../DrawLine.html
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks.
                      If I want to draw a line from the highest point or lowest point of a range of bars like from 10:20 AM to 11:40 AM , How can I code the range? Can you send me a link regarding this issue?

                      Comment


                        #12


                        You need to mix and match different techniques. We do not have sample code we can show you to do exactly what you want.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          That file was very helpful. Thank you.
                          But what do you do when so many lines are overlapping and there is no way to tell what's underneath what? Is there any way to have some kind of data window or to hover the mouse over the lines one could see how many lines are overlapping say @ 820.75 level?

                          Comment


                            #14
                            Unfortunately not, but you could try minimizing lines by only using a unique tag id when you need a new line created.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              How can these llines be armed so when crossed , an order is sent?
                              Can this be done by additional indicators?
                              If it is a complicated task , can you recommend anyone doing the project for me? and get paid ofcourse.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              12 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by nandhumca, Today, 03:41 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post nandhumca  
                              Started by The_Sec, Today, 03:37 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post The_Sec
                              by The_Sec
                               
                              Started by GwFutures1988, Today, 02:48 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X