• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by superkolleech, Today, 12:46 AM
    1 response
    11 views
    0 likes
    Last Post MojoJojo  
    Started by davidwade, Today, 02:51 AM
    0 responses
    3 views
    0 likes
    Last Post davidwade  
    Started by aviat72, 04-26-2020, 09:41 PM
    10 responses
    91 views
    0 likes
    Last Post kissandfly  
    Started by healthooa, Today, 01:28 AM
    0 responses
    7 views
    0 likes
    Last Post healthooa  
    Started by harjinderjit, Yesterday, 08:24 PM
    0 responses
    20 views
    0 likes
    Last Post harjinderjit  
    Working...
    X