Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compile Error CS0102

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

    Compile Error CS0102

    Hi,
    I am running through the Ninjascript at link http://www.ninjatrader-support.com/H...BarsSinceEntry. When I compile, I get a Compile error CS0102. My Code is shown below. Can you please show me what I am doing wrong. 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>
    /// RSI WITH STOP LOSS AND PROFIT TARGET
    /// </summary>
    [Description("RSI WITH STOP LOSS AND PROFIT TARGET")]
    public class TUTORIAL2 : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int RSIPERIOD = 14; // Default setting for RSIPERIOD
    private int RSISMOOTH = 3; // Default setting for RSISMOOTH
    private int PROFITTARGET = 12; // Default setting for PROFITTARGET
    private int STOPLOSS = 6; // Default setting for STOPLOSS
    // 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()

    {
    CalculateOnBarClose = true;

    //This will ad the RSI indicator to the chart for visualisation
    Add(RSI(RSIPeriod, RSISmooth));

    //Add stop loss and profit target
    SetStopLoss(CalculationMode.Ticks, StopLoss);
    SetProfitTarget(CalculationMode.Ticks, ProfitTarget);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CurrentBar < RSIPeriod)
    return;

    if (CrossAbove(RSIPeriod, RSISmooth,20, 1))
    EnterLong();


    }

    #region Properties
    [Description("RSI PERIOD")]
    [Category("Parameters")]
    public int RSIPERIOD
    {
    get { return rSIPERIOD; }
    set { rSIPERIOD = Math.Max(1, value); }
    }

    [Description("RSI SMOOTH")]
    [Category("Parameters")]
    public int RSISMOOTH
    {
    get { return rSISMOOTH; }
    set { rSISMOOTH = Math.Max(1, value); }
    }

    [Description("PROFIT TARGET OFFSET")]
    [Category("Parameters")]
    public int PROFITTARGET
    {
    get { return pROFITTARGET; }
    set { pROFITTARGET = Math.Max(1, value); }
    }

    [Description("STOP LOSS OFFSET")]
    [Category("Parameters")]
    public int STOPLOSS
    {
    get { return sTOPLOSS; }
    set { sTOPLOSS = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Welcome to our forums, NinjaScript is case sensitive, so you would need to take care to name private and public properties appropriately - the code below would compile -

    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>
    /// RSI WITH STOP LOSS AND PROFIT TARGET
    ///</summary>
    [Description("RSI WITH STOP LOSS AND PROFIT TARGET")]
    publicclass TUTORIAL2 : Strategy
    {
    #region Variables
    // Wizard generated variables
    privateint rsiPeriod = 14; // Default setting for RSIPERIOD
    privateint rsiSmooth = 3; // Default setting for RSISMOOTH
    privateint profitTarget = 12; // Default setting for PROFITTARGET
    privateint stopLoss = 6; // Default setting for STOPLOSS
    // 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>
    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose = true;
    //This will ad the RSI indicator to the chart for visualisation
    Add(RSI(RsiPeriod, RsiSmooth));
    //Add stop loss and profit target
    SetStopLoss(CalculationMode.Ticks, StopLoss);
    SetProfitTarget(CalculationMode.Ticks, ProfitTarget);
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    if (CurrentBar < RsiPeriod)
    return;
    if (CrossAbove(RSI(RsiPeriod, RsiSmooth), 20, 1))
    EnterLong();
     
    }
    #region Properties
    [Description("RSI PERIOD")]
    [Category("Parameters")]
    publicint RsiPeriod
    {
    get { return rsiPeriod; }
    set { rsiPeriod = Math.Max(1, value); }
    }
    [Description("RSI SMOOTH")]
    [Category("Parameters")]
    publicint RsiSmooth
    {
    get { return rsiSmooth; }
    set { rsiSmooth = Math.Max(1, value); }
    }
    [Description("PROFIT TARGET OFFSET")]
    [Category("Parameters")]
    publicint ProfitTarget
    {
    get { return profitTarget; }
    set { profitTarget = Math.Max(1, value); }
    }
    [Description("STOP LOSS OFFSET")]
    [Category("Parameters")]
    publicint StopLoss
    {
    get { return stopLoss; }
    set { stopLoss = Math.Max(1, value); }
    }
    #endregion
    }
    }
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thank you for your help

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by AaronKoRn, Today, 09:49 PM
      0 responses
      6 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Today, 08:42 PM
      0 responses
      9 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Today, 07:51 PM
      0 responses
      10 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,977 views
      3 likes
      Last Post jhudas88  
      Started by rbeckmann05, Today, 06:48 PM
      0 responses
      9 views
      0 likes
      Last Post rbeckmann05  
      Working...
      X