Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem using External DLL

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

    Problem using External DLL

    Hi,

    I'm trying to use NCalc (http://ncalc.codeplex.com/) in my indicator.

    - I've added the using directive
    - I've placed NCalc.dll into ...\NinjaTrader 7\bin\Custom
    - I've added the assembly reference

    It compiles ok, but when I try to call one of the methods

    Expression e = new Expression("2 * 3");
    or
    Expression e = new NCalc.Expression("2 * 3");

    I get the error

    Error on calling 'OnBarUpdate' method for indicator 'MyIndy' on bar 0: Could not load file or assembly 'NCalc, Version=1.3.8.0, Culture=neutral, PublicKeyToken=973cde3f1cafed03' or one of its dependencies. The system cannot find the file specified.

    The .dll is created in c#.

    Any ideas?

    Thanks,
    Will.

    #2
    Originally posted by dontpanic View Post
    Hi,

    I'm trying to use NCalc (http://ncalc.codeplex.com/) in my indicator.

    - I've added the using directive
    - I've placed NCalc.dll into ...\NinjaTrader 7\bin\Custom
    - I've added the assembly reference

    It compiles ok, but when I try to call one of the methods

    Expression e = new Expression("2 * 3");
    or
    Expression e = new NCalc.Expression("2 * 3");

    I get the error

    Error on calling 'OnBarUpdate' method for indicator 'MyIndy' on bar 0: Could not load file or assembly 'NCalc, Version=1.3.8.0, Culture=neutral, PublicKeyToken=973cde3f1cafed03' or one of its dependencies. The system cannot find the file specified.

    The .dll is created in c#.

    Any ideas?

    Thanks,
    Will.
    What version of .NET is it compiled against and for?

    Comment


      #3
      Hi,

      didn't think of that... according to dotpeek its .net v4.0. So, I'll have to try and recompile it.

      Thanks.

      Comment


        #4
        sorry,

        I was looking at the wrong assembly. dotpeek says its .net 3.5.

        Anything else I should check for?

        Ta,
        Will.

        Comment


          #5
          Working now.

          NCalc needs antl3.runtime.dll

          The error message is a bit deceptive, it just says 'the file ... is missing', it doesn't say which one.

          Thanks for the suggestions,
          Will.

          Comment


            #6
            To get NCalc working :-

            - copy NCalc.dll and Antlr3.runtime.dll into the custom directory where the other .dll's are.
            - add to using declarations : using NCalc;
            - in variables section :
            Expression myExpression;
            string myExpressionString="(1+2)";
            - in Initialize() :
            myExpression = new Expression(myExpressionString);
            optionally add custom function delclarations :
            myExpression.EvaluateFunction += delegate(string name, FunctionArgs args) {
            ... add custom functions as per NCalc doco ...
            }
            - in OnBarUpdate() :
            myExpression.Evaluate();
            above returns an object of the type of the evaluation, typically numeric or boolean



            NCalc works very well, its fast and efficient and if you are using boolean expressions it has the intelligence to terminate evaluation when the result is determined. For example if you have a boolean expression (A && B) and A is false it will return false without trying to evaluate B.

            All NT variables and functions are available in the delegate functions.

            Enjoy.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            557 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 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
            545 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