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

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 rocketman7, Today, 02:12 AM
    3 responses
    20 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    7 responses
    27 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by samish18, 04-17-2024, 08:57 AM
    17 responses
    65 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by briansaul, Today, 05:31 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by PaulMohn, Today, 03:49 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X