Cranford, New Jersey, USA
Experience: Advanced
Platform: Tradestation, Ninja Trader
Broker: TS and MB Trading
Trading: ES, EC
Posts: 10 since Dec 2010
Thanks Given: 8
Thanks Received: 2
|
I typed the following into my ninja trader. Trying to follow exactly what Big Mike did in his video and it didn't compile.
Does anyone see the obvious error?
I took out a few lines of code to meet the size limits for this post.
I am getting CS1501 and 1502 errors as well as a CS1519 error on invalid token 'void' .
// 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("Make Millions 1/16/2012")]
publicclass DLTestBigMv0 : Strategy
{
// private int smalength = 200 ; // I took these out when it didn't compile
// private int emalength = 100 ; // don't know whether he did also or not.
// private int hmalength = 34 ; // but was getting a compile error with them in.
// private int Target1 = 12 ; // Question 1: Is it OK to leave these in when
// private int Target2 = 10 ; // these are redefined? later ???
// private int Target3 = 24 ;
// private int Stop = 12 ;
// private bool be2 = False ;
// private bool be3 = False ;
///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverride void Initialize()
{
CalculateOnBarClose = true;
EntryHandling = EntryHandling.UniqueEntries ;
}
/// do this for each target so you know it will do all 3 and not stop after 1st one //
/// these are OCO ordrs placed right after position is entered.
private void GoLong()
{
SetStopLoss(Target1, CalculationMode.Price, Close[0] - (Stop*TickSize), false);
SetStopLoss(Target2, CalculationMode.Price, Close[0] - (Stop*TickSize), false);
SetStopLoss(Target3, CalculationMode.Price, Close[0] - (Stop*TickSize), false);
SetProfitTarget(Target1, CalculationMode.Price, Close[0] + (Target1*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[0] + ((Target1 + Target2)*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[0] + ((Target1 + Target2 + Target3)*TickSize));
EnterLong("Target1") ;
EnterLong("Target2") ;
EnterLong("Target3") ;
}
private void GoShort()
{
SetStopLoss(Target1, CalculationMode.Price, Close[0] + (Stop*TickSize), false);
SetStopLoss(Target2, CalculationMode.Price, Close[0] + (Stop*TickSize), false);
SetStopLoss(Target3, CalculationMode.Price, Close[0] + (Stop*TickSize), false);
SetProfitTarget(Target1, CalculationMode.Price, Close[0] - (Target1*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[0] - ((Target1 + Target2)*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[0] - ((Target1 + Target2 + Target3)*TickSize));
EnterShort("Target1") ;
EnterShort("Target2") ;
EnterShort("Target3") ;
}
private void ManageOrders() // ??? problem w/ 'void' in this statement ???
// These are only 'on close' not 'intrabar'
{
if (Position.MarketPosition == MarketPosition.Long)
{ if (BE2 && High[0] > Position.AvgPrice + (Target1*TickSize))
SetStopLoss("Target2", CalculationMode.Price, Position.AvgPrice, false) ;
if (BE3 && High[0] > Position.AvgPrice + ((Target1 + Target2)*TickSize))
SetStopLoss("Target3", CalculationMode.Price, Position.AvgPrice, false) ;
}
if (Position.MarketPosition == MarketPosition.Short)
{ if (BE2 && Low[0] < Position.AvgPrice - (Target1*TickSize))
SetStopLoss("Target2", CalculationMode.Price, Position.AvgPrice, false) ;
if (BE3 && Low[0] > Position.AvgPrice - ((Target1 + Target2)*TickSize))
SetStopLoss("Target3", CalculationMode.Price, Position.AvgPrice, false) ;
}
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverride void OnBarUpdate() // This section is called at close of every bar
{
EntryHandling = EntryHandling.UniqueEntries ;
SMA SMAV = SMA(SMAlength);
EMA EMAV = EMA(EMAlength);
HMA HMAV = HMA(HMAlength);
ManageOrders() ; // This section manages Positions and determines if new position indicated.
if (Position.MarketPosition != MarketPosition.Flat) return ; // make sure we are flat.
if (Rising(smav) && Rising(emav) && Rising(hmav))
GoLong() ;
else if (Falling(smav) && Falling(emav) && Falling(hmav))
GoShort() ;
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int smalength
{
get { return smalength; }
set { smalength = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int emalength
{
get { return emalength; }
set { emalength = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
publicint hmalength
{
get { return hmalength; }
set { hmalength = Math.Max(1, value); }
}
// deleted from here to end to save space. errors occurred above.//
#endregion
}
}
|