Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Opacity in Stroke Helper throwing errors

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

    Opacity in Stroke Helper throwing errors

    Hi everyone!

    So in the AddPlot method, upon creating a new Stroke, there is an argument for opacity. This does indeed change the opacity of my plot but there are a few issues with it.

    One thing is that when an indicator is using opacity as an argument in Stroke and it is added to the chart, changing the scale of my chart by dragging the right axis triggers an unhandled exception, object ref not set to an instance of object. This is more of an annoyance than anything else but it makes me wonder what else is going on behind the scenes that may be mucking things up and i would definitely like to clean this up if possible.

    The other thing is that if I create a user-input variable "Opacity" in SetDefaults so that I can tweak it upon adding an instance of the indicator to the chart, the visual opacity does not actually change at all. I understand that this is a feature not a bug, the only way to update the opacity to the new value is to remove the indicator, apply, and then add a new instance with a new value. Is there any way to get around this so that i can simply update the value in the indicators menu and hit apply?

    it's pretty simple code, but for reference i have included the problem child below.

    thanks for any insight you can offer, thanks guys!

    Code:
    AddPlot(new Stroke(Brushes.DimGray, DashStyleHelper.Dash, 1, Opacity), PlotStyle.Line, "Upper");
    AddPlot(new Stroke(Brushes.MediumTurquoise, DashStyleHelper.Solid, 2, Opacity), PlotStyle.Dot, "Midline");
    AddPlot(new Stroke(Brushes.DimGray, DashStyleHelper.Dash, 1, Opacity), PlotStyle.Line, "Lower");

    #2
    Hi lunardiplomacy, thanks for posting. I made a test script and it has no problems. Can you test this on your end and compare the differences between it and your script? Call AddPlot in State.Configure to accept user input for the opacity parameter.

    Kind regards,
    -ChrisL
    Attached Files

    Comment


      #3
      hi Chris,

      I did place addplot with the opacity parameter in State.Configure in order for it to accept the user input.
      but now the indicator will not save as template.

      is there a workaround to do that ?

      Comment


        #4
        Hi Amedeus,

        I believe the most viable workaround to this would be to simply update the code of the AddPlot method to the settings you want as your "template", if you need multiple then just make copy scripts. Maybe there is something through the UI that Chris can enlighten us to but I don't think so once it's in state.configure.

        Good luck!

        P.S. just to provide some closure, I still receive an unhandled exception obj ref error upon dragging the slider scale on the right of the chart but it's not a huge deal since I don't use that function often, esp if it doesn't have any unseen consequences.

        Comment


          #5
          hey lunardiplomacy, thank you,

          just to confirm and precise : I meant the indicator won't save as part of a chart template.
          But indeed I get an unhandled exception too, if I try to save the indicator's parameters in the indicator window.

          Sure, about multiple scripts.

          Any light, Chris ?

          Comment


            #6
            Hi Amedeus, thanks for posting. I can save a template with the example I posted here. Can you test that and compare/contrast with your script?

            Kind regards,
            -ChrisL

            Comment


              #7

              Hey Chris, thank you,

              You're right, your example saves itself fine.

              let me explain why for my participation in this thread be worth the while :
              The error was due to where I try to implement this opacity property.
              The error was "There was an error reflecting type 'NinjaTrader.NinjaScript.Indicators.indicatorName" , and did not allow to save the workspace either.

              I was trying to apply it to the SingleDotSwing "SwingHigh" Addplots :
              [Browsable(false)] [XmlIgnore()] public Series<double> SwingHigh { get { Update(); return swingHighSeries; } }

              After looking up this thread,

              I realized swingHighSeries had been made public for unrelated testing purposes.
              Once it had been made private again, saving the parameters, the chart template and the workspace worked ok. Make series private again, lol.

              It's all good then, thanks.
              have a great day, lunardiplomacy too

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              571 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              331 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              549 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              549 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X