Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CS0103 Compilation Error...

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

    CS0103 Compilation Error...

    Hello,
    I'm new to the NinjaTrader/Script platform and I'm trying to make a simple strategy using OBV. After I had completed my strategy I get a compile error on several different lines throughout the entire program, some falling under "Wizard Settings" in the code. I created the entire thing with the wizard and haven't changed anything in the actual code. The full code is below, up to line 67 where the Wizard Settings start. Thanks for your time and any help you can offer.

    Regards,
    TheProfitcy

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// Buy when OBV crosses average, sell when it crosses below.
        /// </summary>
        [Description("Buy when OBV crosses average, sell when it crosses below.")]
        public class OBVStrat : Strategy
        {
            #region Variables
            // Wizard generated variables
            private int positionSize = 500; // Default setting for PositionSize
            // User defined variables (add any user defined variables below)
            #endregion
    
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
    
                CalculateOnBarClose = true;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                // Condition set 1
                if (CrossAbove(OBV(), WMA(OBV(), 21), 1))
                {
                    EnterLong(PositionSize, "Long");
                }
    
                // Condition set 2
                if (CrossBelow(OBV(), WMA(OBV(), 21), 1))
                {
                    EnterShort(PositionSize, "Short");
                }
            }
    
            #region Properties
            [Description("Shares To Buy/Sell")]
            [GridCategory("Parameters")]
            public int PositionSize
            {
                get { return positionSize; }
                set { positionSize = Math.Max(100, value); }
            }
            #endregion
        }
    }

    #2
    Hello TheProfitcy,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    The Strategy compiles on my end, the errors are likely from another file. Please take a screenshot of the errors you are receiving and attach the screenshot to your response here.

    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image.

    For detailed instructions please visit the following link

    How to take a screenshot on your smartphone, tablet, notebook or desktop computer

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello TheProfitcy,

      Thank you for your post and welcome to the NinjaTrader Support Forum!

      The Strategy compiles on my end, the errors are likely from another file. Please take a screenshot of the errors you are receiving and attach the screenshot to your response here.

      To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image.

      For detailed instructions please visit the following link

      http://take-a-screenshot.org/
      Image is attached!
      Attached Files

      Comment


        #4
        Hello TheProfitcy,

        Thank you for your response.

        The error is not coming from your strategy it is coming from the anaAwesomeOscillator indicator. If you double click on any of the errors it will open the indicator that is generating the errors.

        All NinjaScript files are compiled together, so if one has an error it will be reported on all NinjaScript files.

        We have also collected more comprehensive steps for resolving NinjaScript programming errors in this tip on our forums - http://www.ninjatrader.com/support/f...ead.php?t=4678

        If you need assistance resolving this error please send a note to support[at]ninjatrader[dot]com with 'ATTN: Patrick - 968926' in the subject line and your telephone number and a time we may reach you (include your time zone).

        Comment


          #5
          Thanks, that reinstall did the trick and is working now. Could you tell me how to edit the following code so that the signal will be generated if the crossover is more or less than 0.5%? I tried it with the wizard but no luck there, it doesn't seem like I can add that as an option. Now diving manually into the code and I can't seem to figure it out.

          Code:
          protected override void OnBarUpdate()
                  {
                      // Condition set 1
                      if (CrossAbove(OBV(), WMA(OBV(), 21), 1))
                      {
                          EnterLong(PositionSize, "Go Long");
                          ExitShort("ExitShort", "");
                      }
          
                      // Condition set 2
                      if (CrossBelow(OBV(), WMA(OBV(), 21), 1))
                      {
                          ExitLong("Exit", "");
                          EnterShort(PositionSize, "Get Short");
                      }
                  }

          Comment


            #6
            Hello TheProfitcy,

            Thank you for your response.

            You would need to do the following:
            Code:
            			double wmaPlusHalf = WMA(OBV(), 21)[0] + (0.5*WMA(OBV(), 21)[0]);
            			double wmaMinusHalf = WMA(OBV(), 21)[0] - (0.5*WMA(OBV(), 21)[0]);
            			
                        if (CrossAbove(OBV(), wmaPlusHalf, 1))
                        {
                            
                        }
            
                        if (CrossBelow(OBV(), wmaMinusHalf, 1))
                        {
                            
                        }
            Please let me know if I may be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X