PDA

View Full Version : Compile Error CS0102


Segale
08-26-2010, 06:21 AM
Hi,
I am running through the Ninjascript at link http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?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
}
}

NinjaTrader_Bertrand
08-26-2010, 06:43 AM
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 -


#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
}
}

Segale
08-28-2010, 02:35 AM
Thank you for your help