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

Keeping rectangles

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

    Keeping rectangles

    I am drawing a rectangle in an area and after a certain number of bars the beginning of the rectangle disappears and starts moving forward. I want the rectangle to stay from the days opening till the close and also want it to stay and have a new rectangle plotted the next day with new parameters. I should be able to scroll back through the days and see the different rectangles still plotted.

    Sample here:

    Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), "Zone"));


    {
    {
    if (CurrentBar == 0)
    return;
    }

    Zone.Set(0);

    daystart = Bars.BarsSinceSession;

    DrawRectangle("Zone", false, daystart, Zone, 0 , Zone + 3, Color.OrangeRed, Color.OrangeRed, 2);
    }
    Last edited by eDanny; 07-25-2008, 12:48 PM.
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    #2
    This might help: http://www.ninjatrader-support.com/v...ead.php?t=3419

    Comment


      #3
      No help at all, and have read it before. If you refer to my code you can see I do plot a rectangle but it doesn't behave as I would like. I tried this and had bad results:

      DrawRectangle("Zone" + CurrentBar, false, daystart, Zone, 0 , Zone + 3, Color.OrangeRed, Color.OrangeRed, 2);

      It turned my rectangle solid until about the last 10 price bars, and then gradually lightened up. Also a rectangle was plotted for the previous day at the same level. I need one long rectangle plotted throughout the day, from beginning till close, and stay on chart even when the next days rectangle is starting to plot at a different level.
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        The key factor is the
        "Zone" + CurrentBar
        which you figured out already by the link I provided. This makes your rectangle unique. You now would need to figure out the startBar and endBar. As soon as CurrentBar==endBar you can issue the DrawRectangle function.

        Comment


          #5
          That makes sense but I can't see how to define "endbar".

          Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), "Zone"));


          {
          {
          if (CurrentBar == ???) << endbar?
          {
          if (CurrentBar == 0)
          return;
          }

          Zone.Set(0);

          daystart = Bars.BarsSinceSession;

          DrawRectangle("Zone" + CurrentBar, false, daystart, Zone, 0 , Zone + 3, Color.OrangeRed, Color.OrangeRed, 2);
          }
          }
          Last edited by eDanny; 07-25-2008, 01:15 PM.
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment


            #6
            Sorry, I don't know by what logic your rectangle would get "closed" (which is the endBar).

            Comment


              #7
              Exactly. I don't know if it would, looks like not. Just using this for the first time today and trying to debug.
              Look at edited post above yours.
              eDanny
              NinjaTrader Ecosystem Vendor - Integrity Traders

              Comment


                #8
                You need to define and code the logic on when the "endBar" would get reached.

                Comment


                  #9
                  Originally posted by NinjaTrader_Dierk View Post
                  You need to define and code the logic on when the "endBar" would get reached.
                  I see that but don't know how to define the end of day.
                  eDanny
                  NinjaTrader Ecosystem Vendor - Integrity Traders

                  Comment


                    #10
                    You can try checking DateTime.Now against the bar's timestamps to determine if the day is over.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      It would be nice to be able to provide a StartDateTime/EndDateTime (instead of BarsAgo) & let DrawXXX do the rest...

                      (with EndDateTime being able to draw into the future)

                      Comment


                        #12
                        I still have resolved this issue. I have no idea how to stop the rectangle and start a new one the next day while keeping the old.
                        eDanny
                        NinjaTrader Ecosystem Vendor - Integrity Traders

                        Comment


                          #13
                          Each Rectangle is identified by its Tag.

                          To start a new Rect; change the Tag.

                          The hard part (and undesireable use of resources) is to redraw the Rect with every OnBarUpdate event, having to calc the BarsAgo field.

                          It would be nice to draw it once...and use DateTime to define the left & right sides.

                          Comment


                            #14
                            You could use the GetBar() method which accepts a time parameter and retuns n bars ago.

                            RayNinjaTrader Customer Service

                            Comment


                              #15
                              Why doesn't something like this work? Doesn't the tag effectively change every day and begin a new rectangle?


                              daystart = Bars.BarsSinceSession;


                              DrawRectangle("Test" + Time[0].DayOfWeek, false, daystart, TestLow, 0 , TestLow + 2, Color.Orchid, Color.Orchid, 1);
                              eDanny
                              NinjaTrader Ecosystem Vendor - Integrity Traders

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RubenCazorla, Today, 09:07 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post RubenCazorla  
                              Started by BarzTrading, Today, 07:25 AM
                              2 responses
                              28 views
                              1 like
                              Last Post BarzTrading  
                              Started by devatechnologies, 04-14-2024, 02:58 PM
                              3 responses
                              21 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tkaboris, Today, 08:01 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post tkaboris  
                              Started by EB Worx, 04-04-2023, 02:34 AM
                              7 responses
                              165 views
                              0 likes
                              Last Post VFI26
                              by VFI26
                               
                              Working...
                              X