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 funk10101, Yesterday, 09:43 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            5 responses
            551 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by rtwave, 04-12-2024, 09:30 AM
            5 responses
            37 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by funk10101, Today, 12:02 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by GLFX005, Today, 03:23 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X