• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


How to connect to external library "Html Agility Pack"?

  • Filter
  • Time
  • Show
Clear All
new posts

    How to connect to external library "Html Agility Pack"?

    Hello. Please, save me from another restless night!

    I want to use Html Agility Pack to grab CME data from indicator.

    Html Agility Pack consist of 9 folders:
    • [Net20]
    • [Net40]
    • [Net40-client]
    • [Net45]
    • [sl3-wp]
    • [sl4]
    • [sl4-windowsphone71]
    • [sl5]
    • [winrt45]

    Each folder contain 3 files:
    • HtmlAgilityPack.dll
    • HtmlAgilityPack.pdb
    • HtmlAgilityPack.xml

    ([winrt45] folder contain, also, "HtmlAgilityPack.pri" file)

    I put "using HtmlAgilityPack;" string to my indicator.
    Then I made right click -> References in indicator window (i tried HtmlAgilityPack.dll from all folders.

    After that I compilled my simplest code with no errors.
    string url = "http://www.cmegroup.com/trading/energy/crude-oil/light-sweet-crude_quotes_globex_options.html?exchange=XNYM&foi=OPT&venue=G&productCd=CLX3&underlyingContract=CL&floorContractCd=CLX3&expMonth=201311&prodid=";
    string htmlCode = "";
    HtmlWeb webGet = new HtmlWeb();
    HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();			
    document = webGet.Load(url);			
    Print( htmlCode );
    But when I put indicator on chart I get this error: "Error on calling 'OnBarUpdate' method for indicator 'iOptionsVolume01' on bar 0: Could not load file or assembly "HtmlAgilityPack, Version =, Culture = neutral, PublicKeyToken = bd319b19eaf3b43a" or one of its dependencies. Can not find the file specified.".

    (I also tried to put HtmlAgilityPack.dllfiles to [c:\Users\Andrei\Documents\NinjaTrader 7\bin\Custom\] folder - no result).
    And I tried to use "gacutil.exe" to register library in system.

    I using Windows 8 x64.

    Please, tell me what else I have to do to use Html Agility Pack objects in NinjaScript?

    Thank You!
    NinjaTrader Ecosystem Vendor - fx.practic

    fx.practic, NT7 would support anything up to target framework of 3.5 so my suggestion would be using the 2.0 dll version as reference. Copy it into bin > custom as well and then restart NT7 so it can be loaded when you start up, would you see the same issue working with a basic call from it then in your project?
    BertrandNinjaTrader Customer Service


      Restart NT! Key feature!
      Thank You very march!!
      NinjaTrader Ecosystem Vendor - fx.practic


        Hello fx.practic,

        I'm running into this exact same issue with NinjaTrader 8. Whatever you were originally trying to accomplish in NT7, were you able to successfully recreate within NT8?

        I am getting the same error, "Error on calling 'OnBarUpdate' method for indicator 'myindicator' on bar 0: Could not load file or assembly "HtmlAgilityPack,..."

        I added the HtmlAgilityPack via NuGet manager within Visual Studio. I've tried referencing each different framework version (within my VS project and within NinjaTrader References), many restarts of NinjaTrader, etc. The project builds just fine, but fails at run-time with the error above.

        Any help is greatly appreciated.


          Hello neoikon,

          It looks like fx.practic may have previously solved this by placing the dll in the bin/custom directory along with restarting the platform once the reference was corrected to the bin/custom dll. It may also have been the version of the dll being used, NT7 requires 3.5 or less. fx.practic would need to comment on the specific solution here, however, this would be my observation based on the given details.

          For nuget packages, you will need to use the actual DLL's for NinajTrader rather than trying to use nuget. Nuget would only be relevant toward your own custom projects in visual studio, if you are loading the NinjaTrader.Custom project, nuget will not directly work in that context. You would instead need to copy the .dll files into the bin/custom folder and reference that dll inside of NinjaTrader. For NT7 if you also use visual studio, you will additionally need to reference this dll when you load the NinjaTrader.Custom project. I posted more details about using nuget for NT8 in the following link however this is still relevant for 7: https://ninjatrader.com/support/foru...72#post1042872

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service


          Latest Posts


          Topics Statistics Last Post
          Started by Induna, Today, 08:44 AM
          1 response
          Last Post NinjaTrader_ChelseaB  
          Started by TangoTX, Today, 08:36 AM
          1 response
          1 view
          Last Post NinjaTrader_Tyler  
          Started by abdullah, 11-15-2017, 08:44 PM
          11 responses
          Last Post NinjaTrader_Kate  
          Started by brunoviveiros, Today, 04:31 AM
          3 responses
          Last Post NinjaTrader_Jesse  
          Started by foxy_rav, Today, 06:31 AM
          2 responses
          Last Post foxy_rav