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

QQQ TO NQ Indicator (Need help with errors)

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

    QQQ TO NQ Indicator (Need help with errors)

    So I have been working on a code that converts QQQ levels to NQ and will make a new indicator that will convert SPY to ES. Reason for doing this is because SPY & QQQ tend to have better volume levels compared to ES/NQ. I have developed a code to convert these levels, but for some reason am getting a error code and for life of me can't figure out what it is. I have imported all the correct 3rd party systems, but still can't figure it out. Any help would be greatly appreciated. Code posted down below. Error code also posted

    NinjaScript File Error Code Line Column MyCustomIndicator1.cs
    The type or namespace name 'Ticker' could not be found (are you missing a using directive or an assembly reference?) CS0246 28 17

    HTML 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
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class QQQToNQ : Indicator
        {
            private Ticker qqqTicker;
            private double diff;
            private SMA line_lpt1;
            private SMA line_lpt2;
            private SMA line_lpt3;
            private SMA line_lpt4;
            private SMA line_lpt5;
            private SMA line_spt1;
            private SMA line_spt2;
            private SMA line_spt3;
            private SMA line_spt4;
            private SMA line_spt5;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description = "This indicator converts QQQ price targets to NQ.";
                    Name = "QQQ to NQ";
                    Overlay = true;
                    input_date = "";
                    input_smoothing = 25;
                    input_line_lpt1 = 0.0;
                    input_line_lpt2 = 0.0;
                    input_line_lpt3 = 0.0;
                    input_line_lpt4 = 0.0;
                    input_line_lpt5 = 0.0;
                    input_line_spt1 = 0.0;
                    input_line_spt2 = 0.0;
                    input_line_spt3 = 0.0;
                    input_line_spt4 = 0.0;
                    input_line_spt5 = 0.0;
                    AddPlot(Brushes.Green, "Long PT 1");
                    AddPlot(Brushes.Green, "Long PT 2");
                    AddPlot(Brushes.Green, "Long PT 3");
                    AddPlot(Brushes.Green, "Long PT 4");
                    AddPlot(Brushes.Green, "Long PT 5");
                    AddPlot(Brushes.Red, "Short PT 1");
                    AddPlot(Brushes.Red, "Short PT 2");
                    AddPlot(Brushes.Red, "Short PT 3");
                    AddPlot(Brushes.Red, "Short PT 4");
                    AddPlot(Brushes.Red, "Short PT 5");
                }
                else if (State == State.Configure)
                {
                    qqqTicker = new Ticker("Nasdaq", "QQQ", SessionState.Extended);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (CurrentBar == 0)
                {
                    diff = 1.0;
                }
                else if (BarsInProgress == 0)
                {
                    double nqClose = Close[0];
                    double qqqClose = qqqTicker.GetClose(Time[0], Time[1]);
                    diff = Symbol.Name == "QQQ" ? 1.0 : nqClose / qqqClose;
                }
    
                line_lpt1 = SMA(input_line_lpt1 * diff, input_smoothing);
                line_lpt2 = SMA(input_line_lpt2 * diff, input_smoothing);
                line_lpt3 = SMA(input_line_lpt3 * diff, input_smoothing);
                line_lpt4 = SMA(input_line_lpt4 * diff, input_smoothing);
                line_lpt5 = SMA(input_line_lpt5 * diff, input_smoothing);
                line_spt1 = SMA(input_line_spt1 * diff, input_smoothing);
                line_spt2 = SMA(input_line_spt2 * diff, input_smoothing);
                line_spt3 = SMA(input_line_spt3 * diff, input_smoothing);
                line_spt4 = SMA(input_line_spt4 * diff, input_smoothing);
                line_spt5 = SMA(input_line_spt5 * diff, input_smoothing);
    
                // Plot lines
                PlotBrushes[0][0] = Brushes.Green;
                Values[0][0] = line_lpt1[0];
                PlotBrushes[1][0] = Brushes.Green;
                Values[1][0] = line_lpt2[0];
                PlotBrushes[2][0] = Brushes.Green;
                Values[2][0] = line_lpt3[0];
                PlotBrushes[3][0] = Brushes.Green;
                Values[3][0] = line_lpt4[0];
                PlotBrushes[4][0] = Brushes.Green;
                Values[4][0] = line_lpt5[0];
                PlotBrushes[5][0] = Brushes.Red;
                Values[5][0] = line_spt1[0];
                PlotBrushes[6][0] = Brushes.Red;
                Values[6][0] = line_spt2[0];
                PlotBrushes[7][0] = Brushes.Red;
                Values[7][0] = line_spt3[0];
                PlotBrushes[8][0] = Brushes.Red;
                Values[8][0] = line_spt4[0];
                PlotBrushes[9][0] = Brushes.Red;
                Values[9][0] = line_spt5[0];
            }
    
            #region Inputs
            [Browsable(false)]
            [XmlIgnore()]
            public string input_date { get; set; }
    
            [Range(1, 600), NinjaScriptProperty]
            [Display(Name = "Line Smoothing", Order = 1, GroupName = "Parameters")]
            public int input_smoothing { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Long PT 1", Order = 2, GroupName = "Parameters")]
            public double input_line_lpt1 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Long PT 2", Order = 3, GroupName = "Parameters")]
            public double input_line_lpt2 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Long PT 3", Order = 4, GroupName = "Parameters")]
            public double input_line_lpt3 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Long PT 4", Order = 5, GroupName = "Parameters")]
            public double input_line_lpt4 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Long PT 5", Order = 6, GroupName = "Parameters")]
            public double input_line_lpt5 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Short PT 1", Order = 7, GroupName = "Parameters")]
            public double input_line_spt1 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Short PT 2", Order = 8, GroupName = "Parameters")]
            public double input_line_spt2 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Short PT 3", Order = 9, GroupName = "Parameters")]
            public double input_line_spt3 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Short PT 4", Order = 10, GroupName = "Parameters")]
            public double input_line_spt4 { get; set; }
    
            [Range(Double.MinValue, Double.MaxValue), NinjaScriptProperty]
            [Display(Name = "Short PT 5", Order = 11, GroupName = "Parameters")]
            public double input_line_spt5 { get; set; }
            #endregion
        }
    }
    ​

    #2
    You have to add reference to namespace where Ticker class is defined. Do you have an indicator that uses this class? Look at declarations in it (where "using" keywords).

    Comment


      #3
      Hello josh18955,

      Thanks for your post.

      This error can occur when an imported DLL (could be a 3rd party indicator) you are referencing no longer exists / has been removed.

      To resolve this the DLL must be re-imported.

      To re-import a 3rd party dll:
      • Open the NinjaScript Editor via New > NinjaScript editor.
      • Right mouse click in the NinjaScript Editor main window and select the menu name "References"
      • In the "References" dialog window press the button "Add"
      • Select the 3rd party DLL
      ​See this help guide page for more information about CS0246: https://ninjatrader.com/support/help...nt8/cs0246.htm

      Please let me know if I may assist further.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_BrandonH View Post
        Hello josh18955,

        Thanks for your post.

        This error can occur when an imported DLL (could be a 3rd party indicator) you are referencing no longer exists / has been removed.

        To resolve this the DLL must be re-imported.

        To re-import a 3rd party dll:
        • Open the NinjaScript Editor via New > NinjaScript editor.
        • Right mouse click in the NinjaScript Editor main window and select the menu name "References"
        • In the "References" dialog window press the button "Add"
        • Select the 3rd party DLL
        ​See this help guide page for more information about CS0246: https://ninjatrader.com/support/help...nt8/cs0246.htm

        Please let me know if I may assist further.
        How do I know which DLL I am supposed to import and where can I find them?

        Comment


          #5
          Hello josh18955,

          Thanks for your note.

          In the code you shared, you are calling 'private Ticker qqqTicker'.

          Ticker is not a C# Keyword like double, int, bool, etc. Ticker is also not a class or indicator that comes default with NinjaTrader. A reference to the namespace where Ticker is being defined would likely need to be added to your script.

          Do you have an indicator that uses this 'Ticker' class?

          Is this 'Ticker' class from a third-party indicator?

          Do you have an indicator named 'Ticker' that you are trying to use in the script? How is 'Ticker' defined in the indicator script you are trying to access?

          Let me know if I may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            What was the resolution to this? A DLL reference? If so, what was the DLL?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by traderqz, Today, 12:06 AM
            3 responses
            6 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by RideMe, 04-07-2024, 04:54 PM
            5 responses
            28 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by f.saeidi, Today, 08:13 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by DavidHP, Today, 07:56 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by kujista, Today, 06:23 AM
            3 responses
            11 views
            0 likes
            Last Post kujista
            by kujista
             
            Working...
            X