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

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 jaybedreamin, Today, 05:56 PM
        0 responses
        2 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Working...
        X