Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compilation Error - this code:

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

    Compilation Error - this 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>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class TestStrategy : Strategy
    {
    #region Variables
    private double highestHigh = 0;
    private double lowestLow = 0;
    private int barPeriod = 45;
    #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()
    {
    if (Bars.FirstBarOfSession && FirstTickOfBar)
    {
    highestHigh = High[0];
    lowestLow = Low[0];
    }
    // Stores the highest high from the first 30 bars
    if (Bars.BarsSinceSession < 30 && High[0] > highestHigh)
    {
    highestHigh = High[0];
    }
    // Stores the lowest low from the first 30 bars
    if (Bars.BarsSinceSession < 30 && Low[0] < lowestLow)
    {
    lowestLow = Low[0];
    }
    for (int i = 0; i < barPeriod; i++)
    if (Open[0][i] < Close[0][i] && Rising(Current[0]))
    {
    EnterLong();
    ExitShort();
    }
    else if (Currrent[0] >= highestHigh)
    {
    ExitLong();
    EnterShort();
    }
    }
    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Hello,

    Thank you for the post.

    There are multiple items that are not correct here, I will list them below:

    First it seems you are trying to use the Single series Open price in a Multi-Series way:

    Code:
    Open[0][i]
    Did you instead mean to use Opens[0][i] ? Open would only support a BarsAgo or: Open[i]. This would also apply to your use of Close[0][i].

    You have used something called Current, but this does not exist in the script. Can you tell me, was this intended to be a series that you are storing data to? Additionally you have two spellings of Current and Currrent.

    Finally, the variable myInput0 was removed, so the public property would need removed as well, at the bottom of the file the whole region below would need removed:

    Code:
    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    Please let me know if I may be of additional assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    630 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    566 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X