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

has anyone used opentelemetry?

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

    has anyone used opentelemetry?

    I am trying to use Distributed tracing and using this site as starter. i did using System.Diagnostics; at begining. but my NT code cannot find ActivitySource object. I understand that NT support will not asist outside of thier code. Are there any other developers who have tried to use open telemetry. I am trying to figure out which version of open telemetry i need to use for NT

    testBreakout.cs The type or namespace name 'ActivitySource' could not be found (are you missing a using directive or an assembly reference?) CS0246 30 18

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    using System.Diagnostics;
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class testBreakout : Indicator
    {
    private bool longwind,shortwind;
    private static ActivitySource activitySource = new ActivitySource( "companyname.product.library", "semver1.0.0");
    
    protected override void OnStateChange()
    {
    
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "testBreakout";
    Calculate = Calculate.OnEachTick;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = false;
    
    AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Block, "TradeWindsLong");
    AddPlot(new Stroke(Brushes.Blue, 2), PlotStyle.Block, "TradeWindsShort");
    }
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Second, 1);
    AddDataSeries(BarsPeriodType.Day, 1);
    }
    }
    
    protected override void OnBarUpdate()
    {
    
    {
    
    
    
    using (var activity = activitySource.StartActivity("ActivityName"))
    {
    
    
    ///very complex operation
    
    
    }
    }
    }
    #region properties
    [Browsable(false)]
    [XmlIgnore]
    
    public Series<double> TradeWindsLong
    {
    get { return Values[0]; }
    }
    public Series<double> TradeWindsShort
    {
    get { return Values[1]; }
    }
    
    
    #endregion
    
    }
    }

    #2
    its a very old thread that i had started but i finally got some progress. For starters, i did a helloworld with Visual studio targetting .net 4.8 so i can apply the same to ninjatrader. The Helloworld works.
    Next step, i got a clean Ninjatader environment and added all the Dll's to \\My Documents\NinjaTrader 8\bin\Custom.
    i get error "Failed to load vendor assembly..."

    What step am i missing here as this is the way i have done for other dll's i have imported earlier.!!!

    I can upload all the files for reference if needed.
    Finally: i am still using NT 8.1.1.7 64-bit

    2024-04-06 11:53:46:739|1|4|Vendor assembly 'Google.Protobuf' version='3.19.4.0' loaded.
    2024-04-06 11:53:46:739|1|4|Vendor assembly 'Grpc.Core.Api' version='2.0.0.0' loaded.
    2024-04-06 11:53:46:739|1|4|Vendor assembly 'Grpc.Core' version='2.0.0.0' loaded.
    2024-04-06 11:53:46:740|1|4|Vendor assembly 'Honeycomb.OpenTelemetry' version='1.5.0.0' loaded.
    2024-04-06 11:53:46:740|1|4|Vendor assembly 'Microsoft.Bcl.AsyncInterfaces' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:740|1|4|Vendor assembly 'Microsoft.Extensions.Configuration.Abstractions' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:740|1|4|Vendor assembly 'Microsoft.Extensions.Configuration.Binder' version='3.1.0.0' loaded.
    2024-04-06 11:53:46:740|1|4|Vendor assembly 'Microsoft.Extensions.Configuration.CommandLine' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:740|1|4|Vendor assembly 'Microsoft.Extensions.Configuration' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:741|1|4|Vendor assembly 'Microsoft.Extensions.Configuration.FileExtensions ' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:741|1|4|Vendor assembly 'Microsoft.Extensions.Configuration.Json' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:741|1|4|Vendor assembly 'Microsoft.Extensions.DependencyInjection.Abstract ions' version='3.1.0.0' loaded.
    2024-04-06 11:53:46:747|0|4|Unable to retrieve type info for 'NinjaTrader.NinjaScript.AddOnBase' from assembly 'Microsoft.Extensions.DependencyInjection': Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    2024-04-06 11:53:46:748|3|4|Failed load vendor assembly 'D:\My Documents\NinjaTrader 8\bin\Custom\Microsoft.Extensions.DependencyInject ion.dll': The given key was not present in the dictionary.
    2024-04-06 11:53:46:748|1|4|Vendor assembly 'Microsoft.Extensions.FileProviders.Abstractions' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:748|1|4|Vendor assembly 'Microsoft.Extensions.FileProviders.Physical' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:748|1|4|Vendor assembly 'Microsoft.Extensions.FileSystemGlobbing' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:749|1|4|Vendor assembly 'Microsoft.Extensions.Logging.Abstractions' version='3.1.0.0' loaded.
    2024-04-06 11:53:46:750|0|4|Unable to retrieve type info for 'NinjaTrader.NinjaScript.AddOnBase' from assembly 'Microsoft.Extensions.Logging.Configuration': Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    2024-04-06 11:53:46:750|3|4|Failed load vendor assembly 'D:\My Documents\NinjaTrader 8\bin\Custom\Microsoft.Extensions.Logging.Configur ation.dll': The given key was not present in the dictionary.
    2024-04-06 11:53:46:750|1|4|Vendor assembly 'Microsoft.Extensions.Logging' version='3.1.0.0' loaded.
    2024-04-06 11:53:46:751|0|4|Unable to retrieve type info for 'NinjaTrader.NinjaScript.AddOnBase' from assembly 'Microsoft.Extensions.Options.ConfigurationExtensi ons': Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    2024-04-06 11:53:46:751|3|4|Failed load vendor assembly 'D:\My Documents\NinjaTrader 8\bin\Custom\Microsoft.Extensions.Options.Configur ationExtensions.dll': The given key was not present in the dictionary.
    2024-04-06 11:53:46:751|1|4|Vendor assembly 'Microsoft.Extensions.Options' version='3.1.0.0' loaded.
    2024-04-06 11:53:46:751|1|4|Vendor assembly 'Microsoft.Extensions.Primitives' version='7.0.0.0' loaded.
    2024-04-06 11:53:46:752|1|4|Vendor assembly 'OpenTelemetry.Api' version='1.0.0.0' loaded.
    2024-04-06 11:53:46:752|1|4|Vendor assembly 'OpenTelemetry.Api.ProviderBuilderExtensions' version='1.0.0.0' loaded.
    2024-04-06 11:53:46:753|0|4|Unable to retrieve type info for 'NinjaTrader.NinjaScript.AddOnBase' from assembly 'OpenTelemetry': Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
    2024-04-06 11:53:46:753|3|4|Failed load vendor assembly 'D:\My Documents\NinjaTrader 8\bin\Custom\OpenTelemetry.dll': The given key was not present in the dictionary.
    2024-04-06 11:53:46:753|1|4|Vendor assembly 'OpenTelemetry.Exporter.Console' version='1.0.0.0' loaded.​

    Comment


      #3
      You can attempt to remove the Assemblyinfo.cs file from you //Custom folder and restart then compile and try that script again. If that does not work you can place the assembly back into the same folder.

      Comment


        #4
        Hello junkone,

        Thanks for writing in.

        Support for 3rd party assemblies is limited in the Support department at NinjaTrader.

        Our team is able to assist with adding the dll and a reference to the dll, however, we cannot assist with its use, or with any errors or unexpected behavior that may occur.

        The 3rd party or custom dll assembly file should be added to the Documents\NinjaTrader 8\bin\Custom folder.

        Once the assembly file is added to the Documents\NinjaTrader 8\bin\Custom folder, you will need to add a reference to the dll file. To do this, open a NinjaScript Editor window (New > NinjaScript Editor) in NinjaTrader, right-click within the NinjaScript Editor window, and select 'References' to bring up the References window.

        In the References window, select 'add', select the dll assembly you want to add a reference for, click 'Open' in the File Explorer window, and click 'OK' in the References window.

        Any referenced managed assembly will need to target .NET Framework 4.8 or lower. Other versions of .NET will not work, such as .NET Core or .NET 5.

        ​Here is a link to the help guide on referencing a 3rd party assembly dll.


        This forum thread will be open for other community members to share their insights on the topic.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Brandon, I did all of this. Its not the first time that i have added a 3rd party library. Infact, what i did works well on Visual studio on .Net 4.8.
          Based on what i am looking it, the Ninjatrader compiler acts differently vs the one that Visual studio ships with.
          In this case, I cannot troubleshoot why NT compiler cannot find the dll that it added via "In the References window, select 'add', select the dll assembly you want to add a reference for, click 'Open' in the File Explorer window, and click 'OK' in the References window"

          Comment


            #6
            Hello junkone,

            Thanks for your notes.

            Visual Studio is a separate application external to NinjaTrader and could behave differently than the NinjaScript Editor window.

            Did you add the third-party dlls to the Documents\NinjaTrader 8\bin\Custom folder?

            Do the managed assemblies target .NET Framework 4.8 or lower? Note that other versions of .NET will not work, such as .NET Core or .NET 5.

            To clarify, you added a reference to the assemblies in the NinjaScript Editor after adding it to the Documents\NinjaTrader 8\bin\Custom folder. Is that correct?

            If you update to the latest version of NinjaTrader (8.1.2.1), does the behavior persist?
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Did you add the third-party dlls to the Documents\NinjaTrader 8\bin\Custom folder? yes

              Do the managed assemblies target .NET Framework 4.8 or lower?yes

              To clarify, you added a reference to the assemblies in the NinjaScript Editor after adding it to the Documents\NinjaTrader 8\bin\Custom folder. Is that correct?yes
              I did not even attempt to goto 8.1.2.1 now. My first experience with that version was bad enough that it did not complete the compile for long long long time. Until there is a proven relief, i have no intention of upgrading NInjatrader.
              Pl note: i have a dev box that i am experimenting and moving up version will take away productive time when i sit watching it to compile.​

              Comment


                #8
                Hello junkone,

                Thanks for your notes.

                The support for using third-party assemblies is limited.

                We are able to give general direction on how to reference an assembly but we cannot provide assistance with using a third-party library.

                This would go outside the scope of support we would be able to provide you with in the Support department at NinjaTrader.

                The forum thread will be open for other community members to share their insights on the topic.
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Brevo, Today, 01:45 AM
                0 responses
                2 views
                0 likes
                Last Post Brevo
                by Brevo
                 
                Started by aussugardefender, Today, 01:07 AM
                0 responses
                3 views
                0 likes
                Last Post aussugardefender  
                Started by pvincent, 06-23-2022, 12:53 PM
                14 responses
                238 views
                0 likes
                Last Post Nyman
                by Nyman
                 
                Started by TraderG23, 12-08-2023, 07:56 AM
                9 responses
                384 views
                1 like
                Last Post Gavini
                by Gavini
                 
                Started by oviejo, Today, 12:28 AM
                0 responses
                4 views
                0 likes
                Last Post oviejo
                by oviejo
                 
                Working...
                X