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

;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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,403 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    94 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    6 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    158 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    8 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X