Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Expection Binding a Dynamic Operation

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

    Expection Binding a Dynamic Operation

    Hello,

    Trying to access and compare the CalculationMethod of an andrewPitchfork draw object so that it can be changed on command. Since this will be a compiled assembly, the use of dynamic type is required. When the code is in it's non-compiled form, the indicator will bug out. "Unhandled exception: An unexpected exception occurred while binding a dynamic operation". Upon refreshing the indicator (F5), the indicator starts to behave as normal. In its compiled form, it always throws this error.

    At first, I thought it had to do with comparing enums, however, the same method is used for the RiskReward tool to check the display unit, and that works 100% of the time. I also tried a different method of comparing the enums (list, dynamic list, direct comparison). Made sure to only add the elements to the lists when the chart is loaded.

    I've checked to see if the method is spelled correctly and it is. Checked to make sure that it checks the object type via name and it's doing that correctly.

    Code:
    dynamic andrewsPitchfork = chartObjectToChange;
    andrewsPitchfork.CalculationMethod == NinjaTrader.NinjaScript.DrawingTools.AndrewsPitchfork.AndrewsPitchforkCalculationMethod.StandardPitchfork
    
    dynamic riskReward = chartObjectToChange;
    riskReward.DisplayUnit == NinjaTrader.NinjaScript.DrawingTools.ValueUnit.Price;
    The same method is used for the risk reward and pitchfork, the difference being the names and properties that are accessed. (compiled)


    Exact same code but not compiled. (still using dynamic types)


    When the code is not working before the refresh of the non-compiled version, it failes when it's retrieving the calculation method. I really don't know what's going on here.

    Thanks
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable, thanks for writing in.

    Could you make a reduced version of the script and send it to me so I can test? You may send it to platformsupport at ninjatrader.com, please reference "2832890 ATTN ChrisL" in the body of the email.

    I look forward to hearing from you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    563 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    329 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
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X