I´m having trouble using Order objects set to ExitShortLimit for my target and stoploss in an "Advanced Managed Approach" since I don´t want to use SetProfitTarget and SetStopLoss methods. My aim is to have these orders cancel each other once either is filled but cannot figure out why they are not being placed.
Here is my code:
namespace NinjaTrader.NinjaScript.Strategies
{
public class AddSeriesTest : Strategy
{
#region Variables
private Order EntryOrder = null;
private Order TargetOrder = null;
private Order StopLossOrder = null;
#endregion
protected override void OnStateChange(){
if (State == State.SetDefaults)
{
Description = @"";
Name = "AddSeriesTest";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 0;
IsInstantiatedOnEachOptimizationIteration = true;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
}
}
protected override void OnBarUpdate()
{
if(BarsInProgress == 0 && ToDay(Time[0]) == 20131212 && ToTime(Time[0]) == ToTime(9,32,00) )
{
EntryOrder = EnterShortLimit(BarsInProgress,true, 1, Close[0],"Entry");
TargetOrder = ExitShortLimit(BarsInProgress, true, 1, Close[0] - 1.5 , "ProfitTarget", "Entry");
StopLossOrder = ExitShortLimit(BarsInProgress, true, 1, Close[0] + 2.5 , "StopLoss", "Entry");
}
}
}
}
Comment