Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Primary Series Color Transparency

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

    Primary Series Color Transparency

    In NT7 I am able to change color transparency of the main data series by changing

    'Color for down lines' to 96, 255,192,192
    'Color for up lines' to 96, 255,192,192

    The first number 96 controls the transparency. How do I perform this same operation in NT8?
    Attached Files
    Last edited by habibalex; 11-03-2015, 06:37 PM.

    #2
    I do like this
    Code:
    Brush brushCopy = brush.Clone();
    brushCopy.Opacity = opacity / 100.0;
    brush = brushCopy;
    where the "brush" has a desired color

    Comment


      #3
      Where do you put that code?

      Comment


        #4
        NT8 does not use the Color Class but using a Brush Class. Accordingly, transparency is defined in another way.
        For example
        Code:
                private void DrawShape(double price, long sizeIce, long size, float x, MarkerShape marker, float markerSize, float height, int opacity, [B]Brush brush[/B], bool showSummary, SimpleFont font)
                {
                    [B]Brush brushCopy = brush.Clone();
                    brushCopy.Opacity = opacity / 100.0;
                    brush = brushCopy;[/B]
                    int yByPrice = chartScale.GetYByValue(price);
                    this.PlotShape(false, x, yByPrice, markerSize, height, [B]brush[/B], marker);
                    if (showSummary)
                    {
                        string text = sizeIce.ToString();
                        if (font.Equals(this.labelFontSqueeze))
                            text = sizeIce.ToString();
                        else
                            text += " " + size.ToString();
                        Size sizetext = GetTextSize(text, font, brush);
                        float xstr = (float)(x - sizetext.Width - markerSize / 2 - 2);
                        RenderTarget.DrawText(text, GetTextFormat(font), new RectangleF(xstr, (float)(yByPrice - sizetext.Height / 2), (float)sizetext.Width, (float)sizetext.Height), [B]brush.ToDxBrush(RenderTarget)[/B], DrawTextOptions.None);
                    }
                }
        or you have something else in mind?
        Last edited by alexr; 11-03-2015, 07:58 PM.

        Comment


          #5
          I am talking about the primary dataseries of the chart. Like the price candlesticks or line on the chart.

          Comment


            #6
            I don't get a picture like you in NT7. I don't know how to use the window settings specify the transparency Programmatically this can be done.
            Attached Files

            Comment


              #7
              Hello habibalex,

              Thanks for your posts.

              To extend member alexrs' example and applying it to changing a candle.

              Code:
              if (Close[0] > Open[0])    
              {
                  Brush mybrush = Brushes.Blue;             // init a new Brush as name = mybrush
                  Brush abrushCopy = mybrush.Clone();  // Clone mybrush into abrushCopy
                  abrushCopy.Opacity = 30 / 100.0;          // change the opacity of the copy
                  mybrush = abrushCopy;                        // copy the clone back the brush
                  BarBrush = mybrush;                            // set the color of the Bar
              }
              You can change the ratio 30/100 to adjust the opacity of the brush.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Where does this code go? Is it in an a new indicator? This function doesn't appear to be an override of the OnRender. What is DrawShape?

                Comment


                  #9
                  Hello habibalex,

                  Thanks for your reply.

                  I'm not sure if you are replying to me or member alexr, but to be clear, the example I provided would be in the OnBarUpdate section and it is an example of changing a candle color when it is an up candle.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by habibalex View Post
                    What is DrawShape?
                    I just gave an example of how to implement advanced features change transparency.

                    Comment


                      #11
                      Paul the code you specified below doesn't work properly, it leaves the last bar painted the original color. Only after the bar closes does it revert back to the color I want, the rest of the indicator needs to run at the Bar close. How do I change the color for all the bars without doing it bar by bar?



                      I want to do something similar to that, but instead set the Opacity to .3. Where do I put the code:
                      Code:
                      ChartBars.Properties.ChartStyle.DownBrush = Brushes.Transparent;


                      Originally posted by NinjaTrader_Paul View Post
                      Hello habibalex,

                      Thanks for your posts.

                      To extend member alexrs' example and applying it to changing a candle.

                      Code:
                      if (Close[0] > Open[0])    
                      {
                          Brush mybrush = Brushes.Blue;             // init a new Brush as name = mybrush
                          Brush abrushCopy = mybrush.Clone();  // Clone mybrush into abrushCopy
                          abrushCopy.Opacity = 30 / 100.0;          // change the opacity of the copy
                          mybrush = abrushCopy;                        // copy the clone back the brush
                          BarBrush = mybrush;                            // set the color of the Bar
                      }
                      You can change the ratio 30/100 to adjust the opacity of the brush.

                      Comment


                        #12
                        Hello habibalex,

                        Thanks for your reply.

                        In the OnStateChange():

                        Code:
                        if (State == State.Configure)
                        			{
                        				Brush abrushCopy = ChartBars.Properties.ChartStyle.DownBrush.Clone();
                        				abrushCopy.Opacity = 30 / 100.0;
                        				ChartBars.Properties.ChartStyle.DownBrush = abrushCopy;
                                                        [COLOR="Green"]ChartBars.Properties.ChartStyle.DownBrush.Freeze()[/COLOR]
                        			}
                        EDIT: 11/11/15 9:09 mst, Per member Kogman's reminder, added the freeze() method as changing the opacity is creating a custom brush color, please see: http://ninjatrader.com/support/helpGuides/nt8/en-us/?brushes.htm
                        Last edited by NinjaTrader_PaulH; 11-11-2015, 10:12 AM.
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Paul View Post
                          Hello habibalex,

                          Thanks for your reply.

                          In the OnStateChange():

                          Code:
                          if (State == State.Configure)
                          			{
                          				Brush abrushCopy = ChartBars.Properties.ChartStyle.DownBrush.Clone();
                          				abrushCopy.Opacity = 30 / 100.0;
                          				ChartBars.Properties.ChartStyle.DownBrush = abrushCopy;
                          			}
                          Remember to Freeze() the brush.

                          ref: http://ninjatrader.com/support/forum...ad.php?t=77304

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by arvidvanstaey, Today, 02:19 PM
                          0 responses
                          2 views
                          0 likes
                          Last Post arvidvanstaey  
                          Started by mmckinnm, Today, 01:34 PM
                          3 responses
                          5 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by f.saeidi, Today, 01:32 PM
                          2 responses
                          5 views
                          0 likes
                          Last Post f.saeidi  
                          Started by alifarahani, 04-19-2024, 09:40 AM
                          9 responses
                          55 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by Conceptzx, 10-11-2022, 06:38 AM
                          3 responses
                          60 views
                          0 likes
                          Last Post NinjaTrader_SeanH  
                          Working...
                          X