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

DrawLine Question

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

    DrawLine Question

    Hello, I've got this condition working right now but the plot isn't how I'd like it to look. Here's the code:

    if (High[0] > MAX(High,Strength)[1])
    {
    DrawLine("tag14",0, pp, 0, pp, Color.Black, DashStyle.Solid, 5);

    I actually don't want the line to start printing until the bar that triggeres the condition to be true.
    How do I get the line to start printing at the condition bar and up until this condition gets met again on another bar in the future and then starts printing a new one on that new bar at a different level of course? Is that possible?

    I've had a look at DrawHorizontalLine and I don't care much for it since I can't vary it's length or get rid of it.

    thank you
    Last edited by jjthetrader; 05-14-2009, 05:04 PM.

    #2
    Hi jjthetrader, for this you would need to set appropriate values derived from the bar count (CurrentBar) into the startBarsAgo and endBarsAgo parameters - http://www.ninjatrader-support.com/H.../DrawLine.html

    Since you're using just one draw object tag right now, you'll always modify one line as your condition evaluates to true, to get a history of drawn objects you can assign a unique tag ID to each by adding for example CurrentBar to it ("tag14" + CurrentBar).
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Hi jjthetrader, for this you would need to set appropriate values derived from the bar count (CurrentBar) into the startBarsAgo and endBarsAgo parameters - http://www.ninjatrader-support.com/H.../DrawLine.html
      Hi, yes I was aware of the startbarsago and endbarsago but what happens is that is sees the bar that my condition was met on as bar [0]. So if I draw it 10 bars back (startbarsago) to bar 0 and there's been 5 bars since that condition was met, I have no line from the condition bar to the current price bar. Do you know what I mean?
      I want the line to start plotting on the condition bar [0] and continue until we get another condition bar which will plot a new line.
      Is there a way to do that?
      thanks

      Comment


        #4
        Then you will need to program a counter that increments those values until you get another condition bar to start a new line.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Just to update this thread for others, for my issue below I just changed DrawLine to DrawRay to extend a line into the future. No counter necessary.

          Comment


            #6
            Originally posted by jjthetrader View Post
            Hi, yes I was aware of the startbarsago and endbarsago but what happens is that is sees the bar that my condition was met on as bar [0]. So if I draw it 10 bars back (startbarsago) to bar 0 and there's been 5 bars since that condition was met, I have no line from the condition bar to the current price bar. Do you know what I mean?
            I want the line to start plotting on the condition bar [0] and continue until we get another condition bar which will plot a new line.
            Is there a way to do that?
            thanks
            How about DrawRay()?

            Comment


              #7
              LOL, Roonius is late to the party with that one.
              eDanny
              NinjaTrader Ecosystem Vendor - Integrity Traders

              Comment


                #8
                Originally posted by eDanny View Post
                LOL, Roonius is late to the party with that one.
                That was very strange... I opened the thread, saw the question, posted an "answer", submitted, and after submission another post appeared dated 2 hours earlier... Where that post was 5 min's ago?

                Probably I am still sleeping...
                Last edited by roonius; 05-16-2009, 09:32 AM.

                Comment


                  #9
                  Originally posted by roonius View Post
                  That was very strange... I opened the thread, saw the question, posted an "answer", submitted, and after submission another post appeared dated 2 hours earlier... Where that post was 5 min's ago?

                  Probably I am still sleeping...
                  Either way your input is still appreciated.

                  Is there a way to get the value of the Ray to show up on the right in the price panel?

                  Thanks

                  Comment


                    #10
                    Originally posted by jjthetrader View Post
                    Either way your input is still appreciated.

                    Is there a way to get the value of the Ray to show up on the right in the price panel?

                    Thanks
                    Not really, you will have to come up with some kind of workaround to display value.

                    Comment


                      #11
                      Could I please get a nudge in the right direction here. I've used DrawHorizontalLine on this example. I have other indicators that use the same thing but get their prices to show up in the price scale. Where in the code can I find where this is set?
                      And if it's not as easy as that could you please point me in the right direction to get this constant line to work as a Plot?
                      thanks
                      Attached Files

                      Comment


                        #12
                        Hello,

                        What you are refering to is most likely an plot and not a draw object. I recommend plotting at a constant value to get what you want.
                        DenNinjaTrader Customer Service

                        Comment


                          #13
                          Hello, below is the code from SBG's high/low for a specific period of time.

                          Rather than plot the range of a specific time period I am looking for it to plot the range of the bar with the highest high in the last 5 bars (MAX(High,5)[1]).
                          Could someone please help me remove the time component and add in the max high? I've tried multiple changes but none work.
                          Thanks so much!

                          protected
                          override void OnBarUpdate()
                          {
                          id=ToDay(Time[
                          0]).ToString();
                          if(String.Compare(id,previd)==0)
                          { TheHigh.Set(h);
                          TheLow.Set(l);
                          return; //don't do the same day again, wait for new day
                          }
                          int BarDay = Time[0].Day;
                          int BarMonth = Time[0].Month;
                          int BarYear = Time[0].Year;
                          int StartBar = CurrentBar - Bars.GetBar(new DateTime(BarYear, BarMonth, BarDay, startTimeHr, startTimeMinute, 0));
                          int EndBar = CurrentBar - Bars.GetBar(new DateTime(BarYear, BarMonth, BarDay, endTimeHr, endTimeMinute, 0));
                          if(StartBar == EndBar) //if the time range is not on the chart, exit
                          { TheHigh.Set(h);
                          //carry forward the last known h and l values
                          TheLow.Set(l);
                          return;
                          }
                          if(EndBar>=0) //if the end of the timeframe has already arrived
                          { h=High[StartBar];
                          l=Low[StartBar];
                          for (int i=StartBar-1;i>=EndBar;i--)
                          {
                          if(High[i]>h) h=High[i];
                          if(Low[i]<l) l=Low[i];
                          }
                          if(StartBar<CurrentBar && EndBar<CurrentBar && StartBar>0)
                          {
                          //DrawRectangle("R"+Time[0].ToString(),false,StartBar,h,EndBar,l,Color.Blue, Color.Transparent, 1);
                          previd = id;
                          DrawLine(
                          "L1"+id,StartBar,h,EndBar,l,Color.Blue,DashStyle.D ot,1);
                          DrawLine(
                          "L2"+id,StartBar,l,EndBar,h,Color.Blue,DashStyle.D ot,1);
                          DrawLine(
                          "L3"+id,EndBar,l,EndBar,h,Color.Green,DashStyle.Do t,3);
                          DrawLine(
                          "L4"+id,StartBar,l,StartBar,h,Color.Red,DashStyle. Dot,3);
                          }
                          }
                          TheHigh.Set(h);
                          TheLow.Set(l);
                          }

                          Comment


                            #14
                            jjthetrader, unfortunately we don't provide custom coding services - for this I would suggest contacting a NinjaScript consultant - http://www.ninjatrader.com/webnew/pa...injaScript.htm
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Shansen, 08-30-2019, 10:18 PM
                            24 responses
                            942 views
                            0 likes
                            Last Post spwizard  
                            Started by Max238, Today, 01:28 AM
                            0 responses
                            9 views
                            0 likes
                            Last Post Max238
                            by Max238
                             
                            Started by rocketman7, Today, 01:00 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post rocketman7  
                            Started by wzgy0920, 04-20-2024, 06:09 PM
                            2 responses
                            28 views
                            0 likes
                            Last Post wzgy0920  
                            Started by wzgy0920, 02-22-2024, 01:11 AM
                            5 responses
                            33 views
                            0 likes
                            Last Post wzgy0920  
                            Working...
                            X