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

Boxes

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

    Boxes

    I have been trying to find a way of placing a highligh box around a bar for a certain condition. At the moment all I can do is create a boxwhose edges are on the main body of the bar. I have attached a screen shot of what I mean. I have also placed an insert from another program that does what I wish

    if (CrossBelow(SMA(Close, 8), SMA(Open, 8), 1))
    DrawRectangle("My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Orange,BackColor,2);
    }

    The code above is what I have used. Can you suggest a way to alter code to achieve what I am looking for.
    Attached Files

    #2
    Hi cptrader, basically you look for a way to center the rectangles. Easiest would be to color your conditions by changing the BarColor and then uppen the thickness of the bar...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Boxes

      Thanks for your reply
      Not entirely sure what you mean.
      I have added code to change colour but not sure how to change the thickness.Are you saying that if condition bar is thicker then the boxes will be off centre?

      if (CrossBelow(SMA(Close, 8), SMA(Open, 8), 1))
      {BarColor = Color.Blue
      DrawRectangle("My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Orange,BackColor,2);
      }

      Comment


        #4
        You cannot create a box that has anchor points not on the center line of a bar. What you can try is outlining the bar via a box that encompasses the prior bar and the next bar.

        If this is unacceptable your only option is to override the Plot method and this is unfortunately advanced C# programming that we cannot offer support for.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          boxes

          Were you suggesting using CandleOutlineColor = Color.Purple; and thickening it

          Can you please explain how to increase thickness of an individual bar or the candle outline

          Comment


            #6
            No that was not what I was suggesting. I was suggesting you to use your DrawRectangle. CandleOutlineColor does not change width. It changes color.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by cptrader View Post
              I have been trying to find a way of placing a highligh box around a bar for a certain condition. At the moment all I can do is create a boxwhose edges are on the main body of the bar. I have attached a screen shot of what I mean. I have also placed an insert from another program that does what I wish

              if (CrossBelow(SMA(Close, 8), SMA(Open, 8), 1))
              DrawRectangle("My rectangle"+ CurrentBar , 1, Low[1] - 2 * TickSize, 0, High[0] + 2 * TickSize, Color.Orange,BackColor,2);
              }

              The code above is what I have used. Can you suggest a way to alter code to achieve what I am looking for.
              I can offer you another way to achieve what you want avoiding overrinding plot method.

              You can draw a line on the bar you want to highligh, just set line width more than bar width and set color opacity to the level you want.

              This way has a downside - "box" width won't change if you change x scale until you refresh indicator (f5). If this does not suit you - the only way remaining is to override the plot method.

              Attached is simple example.
              Hope it helps

              roonius
              Attached Files

              Comment


                #8
                Great suggestion roonius! Thanks.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Boxes

                  This was exactly the solution I was looking for. Thanks roonius

                  Just a few clarifications with code

                  Firstly

                  Color myColor = Color.FromArgb(50,0,0,255);

                  Can someone clarify what the inter imputs stand for?

                  DrawLine("line"+CurrentBar.ToString(),0,Low[0]-TickSize,0,High[0]+TickSize,myColor,DashStyle.Solid,
                  ChartControl.ChartStyle.GetBarPaintWidth(ChartCont rol.BarWidth)+
                  2);

                  GetBarPaintWidth(ChartControl.BarWidth)+2);

                  Can some please explain this function? I have altered the integer value (2) but there appears no change to chart.appearance.

                  Comment


                    #10
                    Argb = alpha red green blue

                    Unfortunately we cannot offer support for ChartControl.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Boxes

                      Ok. How can you use argb to set color opacity to the level you want.
                      Is there other ways to select opace colours?


                      Thanks

                      Comment


                        #12
                        Alpha = opacity
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Boxes

                          Thank you.
                          Is there a reference guide for the alpha integer values and the color integer values.

                          Comment


                            #14
                            You will have to search MSDN or Google because this is a C# method.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Roonius

                              That is a very elegant solution and so simple!
                              Brilliant.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, 03-04-2020, 03:11 PM
                              11 responses
                              3,227 views
                              0 likes
                              Last Post xiinteractive  
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              440 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post FAQtrader  
                              Working...
                              X