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 love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    36 views
    0 likes
    Last Post love2code2trade  
    Started by alifarahani, Today, 09:40 AM
    2 responses
    13 views
    0 likes
    Last Post alifarahani  
    Started by junkone, Today, 11:37 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by pickmyonlineclass, Today, 12:23 PM
    0 responses
    1 view
    0 likes
    Last Post pickmyonlineclass  
    Started by frankthearm, Yesterday, 09:08 AM
    12 responses
    44 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X