Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

;Receiving Code errors, but code runs fine

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

    ;Receiving Code errors, but code runs fine

    When I compile, I get 3 errors. CS1502, NT1503, and CS1503 all on Line 57, which I have highlighted below. Thing is, the strategy runs without problems. Any ideas why? I cannot back up NT until I fix the code. Thanks!


    #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>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class The10dayNHNL : Strategy
    {
    #region Variables
    // Wizard generated variables
    private double enter = 0.800; // Default setting for Enter
    private double exit = 0.75; // Default setting for Exit
    private int nHNLsma = 10; // Default setting for Exit
    private DataSeries nHNLSeries;
    // 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()
    {
    Add ("NYSE_NEW_HIGHS", PeriodType.Day, 1);
    Add ("NYSE_NEW_LOWS", PeriodType.Day, 1);


    nHNLSeries = new DataSeries(this);


    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    double NH1 = BarsArray[1][0];
    double NL1 = BarsArray[2][0];
    double NHNLavg = (NH1/(NH1 + NL1));
    double NHNLsma = SMA(NHNLavg, NHNLsma)[0];


    // Condition set 1
    if (NHNLsma >= Enter);

    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (nHNLSeries[0] <= Exit)

    {
    ExitLong("", "");
    }
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public double Enter
    {
    get { return enter; }
    set { enter = Math.Max(0.5, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public int NHNLsma
    {
    get { return nHNLsma; }
    set { nHNLsma = Math.Max(5, value); }
    }

    [Description("")]
    [GridCategory("Parameters")]
    public double Exit
    {
    get { return exit; }
    set { exit = Math.Max(0.5, value); }
    }
    #endregion
    }
    }

    #2
    Thanks for the post, NHNLavg is a double variable only - you could not run an SMA over that, as the SMA method would expect a DataSeries as input, as it's needs history as well to perform it's calculations over your period amount set.



    To backup now, you could simply comment this code line out via putting a // in front. Then you should be able to compile your files and could check into debugging this piece later at your convenience.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    583 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    339 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    552 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X