• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawRectangle

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

    DrawRectangle

    Is there anyway under Ninja script control to change the

    1) Outline width that is drawn by Drawrectangle() either directly or indirectly by
    accessing the draw object or other some other method.

    2) Change the outline dashStyle.

    Both of these can be modified manually after the fact, so while the DrawRectangle() command does not seem to include an overload for Pen width or style I am thinking there has to be some way to do it.

    Thanks
    J~
    Last edited by JerryWar; 06-29-2015, 09:54 AM.

    #2
    Hello,

    While there is not technically a supported way to accomplish this, you may have luck by assigning your rectangle to a variable, then changing the object's Pen property, like so:

    Code:
    var rect = DrawRectangle("yo",5,High[5],1,Low[1],Color.Blue);
     rect.Pen.DashStyle = DashStyle.Dash;
    There are a variety of visual properties that you can change using this method, as well.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Originally posted by NinjaTrader_Dave View Post
      Hello,

      While there is not technically a supported way to accomplish this, you may have luck by assigning your rectangle to a variable, then changing the object's Pen property, like so:

      Code:
      var rect = DrawRectangle("yo",5,High[5],1,Low[1],Color.Blue);
       rect.Pen.DashStyle = DashStyle.Dash;
      There are a variety of visual properties that you can change using this method, as well.

      Dave
      It works perfectly but it causes problems elsewhere, I use the indicator within another indicator. When that indicator is applied I get an Object reference not set to an instance of an object. Possibly I could create a special version to get around this unless you have another way around it.

      J~

      Comment


        #4
        Hello,

        Hopefully it's as simple as the second indicator trying to access the object before it exists. If this is the case, you should be able to get around this by checking to ensure that the object is not null before referencing it, like so:

        Code:
        if (rect != null) rect.Pen.DashStyle = DashStyle.Dash;
        Please let me know if you still see the same issue after trying this.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Dave
          That worked perfectly. But it also raises some questions.
          1) Using var versus IRectangle to define the variable. I am assuming var knows what object type to become where as IRectangle tells it what type of object it is. Is this correct ?

          2) I am using an indicator within an indicator to access public variables exposed and updated within. However one drawback seems to be that it creates a second copy of the indicator even though there is one running which doubles the overhead. It is very calculation intensive. Is there a better way.

          ~j

          Comment


            #6
            Hello,

            You are correct about "var," and it may be more precise to just assign it to an IRectangle explicitly.

            One option that I can think of to reduce the overhead of duplicating indicators would be to create a second, slimmed down version of the first indicator which does not do any plotting, drawing, etc., but only stores, calculates, and provides the specific variables and state that the second indicator needs. This would be just like a data-driven state controller, rather than a full-fledged indicator.
            Dave I.NinjaTrader Product Management

            Comment


              #7
              Originally posted by NinjaTrader_Dave View Post
              Hello,

              You are correct about "var," and it may be more precise to just assign it to an IRectangle explicitly.

              One option that I can think of to reduce the overhead of duplicating indicators would be to create a second, slimmed down version of the first indicator which does not do any plotting, drawing, etc., but only stores, calculates, and provides the specific variables and state that the second indicator needs. This would be just like a data-driven state controller, rather than a full-fledged indicator.
              That's what I was thinking but I wanted to confirm before undertaking the task.

              Thanks for your help
              J~

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mike Winfrey, Today, 11:27 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Jim  
              Started by swcooke, Yesterday, 07:35 PM
              3 responses
              23 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by brownsfan019, Today, 10:45 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by brownsfan019, Today, 10:41 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by bchip, Today, 09:25 AM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X