• 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

OnRender doesn't appear to respect plot's StrokeStyle

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

    OnRender doesn't appear to respect plot's StrokeStyle

    If if initialize a plot with the following code:

    Code:
            Stroke upperStroke = new Stroke(Brushes.Lime, DashStyleHelper.DashDotDot, 3);
            AddPlot( upperStroke, PlotStyle.Line, "HVN Upper" );
    Shouldn't this line of code in OnRender use the attributes of the stroke that was used to initialize the plot?
    Code:
            RenderTarget.DrawLine(startPoint.ToVector2(), endPoint.ToVector2(), plot.BrushDX, plot.Width, plot.StrokeStyle);
    Because it doesn't. No matter what I used to initialize the plot, the line is drawn with a width of one and a dash style of solid. It does respect the color however. Why wouldn't it pass along the width or the dash style?

    #2
    Hello traderpards,

    Thanks for your post.

    When I test the code, I get the results we would expect. (Granted I changed plot.BrushDX to Plots[0].BrushDX and used my own coordinates, but the concept should be the same.)

    Code:
    public class MyCustomIndicator2 : Indicator
    {
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description                                    = @"Enter the description for your new custom Indicator here.";
                Name                                        = "MyCustomIndicator2";
                IsOverlay                                     = true;
                Stroke upperStroke = new Stroke(Brushes.Lime, DashStyleHelper.DashDotDot, 3);
                AddPlot( upperStroke, PlotStyle.Line, "HVN Upper" );
            }
        }
    
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
            RenderTarget.DrawLine(new SharpDX.Vector2(ChartPanel.X, ChartPanel.Y), new SharpDX.Vector2(ChartPanel.W, ChartPanel.H), Plots[0].BrushDX, Plots[0].Width, Plots[0].StrokeStyle);
        }
    }
    Let me know if you are seeing different results with the same test.
    JimNinjaTrader Customer Service

    Comment


      #3
      Well, it would if I completely delete the old indicator and load a brand new one, upon completion of the implementation. I guess this was one of those cases where this wasn't the kind of change where refreshing the chart applies the new indicator changes. I had to completely delete the indicator from the chart and reload a fresh one... Then it works.

      Sorry... and thanks!

      Comment


        #4
        Hello traderpards,

        If you were creating the plot in State.SetDefaults this would be definitely be the case. This state will be used to add default values to the property grid and will also be used if we are adding a plot and want a user to be able to edit that plot. Any changes here require removing and readding to test. If you create the plot in State.Configure then it would add the plot upon a reload of the chart's NinjaScripts.

        Publicly available information on the State System can be found here - https://ninjatrader.com/support/help...tatechange.htm

        Let us know if there is anything else we can do to help.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cocopod, Today, 04:47 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_JoshG  
        Started by digibob, Today, 02:47 AM
        2 responses
        14 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by mntemel, Today, 03:31 PM
        4 responses
        20 views
        0 likes
        Last Post mntemel
        by mntemel
         
        Started by mrlucky1x, Today, 03:14 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by ninjo, Today, 02:42 PM
        4 responses
        9 views
        0 likes
        Last Post ninjo
        by ninjo
         
        Working...
        X