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

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 funk10101, Today, 12:02 AM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by GLFX005, Today, 03:23 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by nandhumca, Yesterday, 03:41 PM
              1 response
              13 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by The_Sec, Yesterday, 03:37 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by vecnopus, Today, 06:15 AM
              0 responses
              1 view
              0 likes
              Last Post vecnopus  
              Working...
              X