PDA

View Full Version : Scale Out Partials


jon_lbs
05-04-2007, 02:39 PM
I would like to send 2 contracts with a target for the 1st and another target for the 2nd.

I'm using ER2 06-07

Here is the code that the wizard produced:




#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.Strategy;

#endregion

// This namespace holds all strategies and is required. Do not change it.

namespace NinjaTrader.Strategy

{

/// <summary>

/// Scale out 1st target and 2nd target

/// </summary>

[Description("Scale out 1st target and 2nd target")]

[Gui.Design.DisplayName("MultCars")]

public class MultContracts : Strategy

{

#region Variables

// Wizard generated variables

// 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()

{

SetProfitTarget("T1", CalculationMode.Ticks, 10);

SetProfitTarget("T2", CalculationMode.Ticks, 15);

CalculateOnBarClose = true;

}

/// <summary>

/// Called on each bar update event (incoming tick)

/// </summary>

protected override void OnBarUpdate()

{

// Condition set 1

if (ToDay(Time[0]) == ToDay(2007, 5, 3)

&& ToTime(Time[0]) > ToTime(7, 15, 0)

&& ToTime(Time[0]) < ToTime(7, 30, 0))

{

EnterLongStop(1, High[0], "T1");

EnterLongStop(1, High[0], "T2");

}

}

#region Properties

#endregion

}

}

The output is attached. As you can see it doesn't work.

Any ideas on how to do scaling of multiple contracts?

NinjaTrader_Ray
05-05-2007, 12:12 PM
This does work, you likely have not set the parameter "Entry handling" to "UniqueEntries" when running a backtest.

PS - Make sure "Entries per direction" remains at a value of 1.

jon_lbs
05-06-2007, 10:44 PM
This does work, you likely have not set the parameter "Entry handling" to "UniqueEntries" when running a backtest.

PS - Make sure "Entries per direction" remains at a value of 1.

>> That was all it needed.. THANKS