Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

'SetState' error

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

    'SetState' error

    Getting this error .. not sure why. Indicator 'Test01': Error on calling 'SetState' method: Exception has been thrown by the target of an invocation.

    Here's my OnStateChange() code:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Name = "Test01";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DrawOnPricePanel = false;
    IsSuspendedWhileInactive = true;
    PaintPriceMarkers = false;
    AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "Macd");
    AddPlot(new Stroke(Brushes.DarkViolet, 2), PlotStyle.Line, "Avg");
    AddPlot(new Stroke(Brushes.DodgerBlue, 4), PlotStyle.Line, "Diff");
    AddLine(Brushes.DarkGray,0, "Zeroline");
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    fastEma = new Series<double>(this);
    slowEMA = new Series<double>(this);
    diff = new Series<double>(this);
    }
    }

    #2
    Hello pman777,

    I am not able to reproduce this behavior with the provided code.

    Below is a public link to a video of the test.


    Attached is the script exported so that you may import easily on your end and test this script.


    As a tip, to export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
    Below is a link to the help guide on Exporting NinjaScripts.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thank you Chelsea

      Comment

      Latest Posts

      Collapse

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