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

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 jclose, Today, 09:37 PM
            0 responses
            5 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,414 views
            0 likes
            Last Post Traderontheroad  
            Started by firefoxforum12, Today, 08:53 PM
            0 responses
            11 views
            0 likes
            Last Post firefoxforum12  
            Started by stafe, Today, 08:34 PM
            0 responses
            11 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by sastrades, 01-31-2024, 10:19 PM
            11 responses
            169 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X