February 28th, 2010, 10:40 PM
1 ( )
Just starting out...
Futures Experience: Intermediate
Platform: Ninja Trader
Posts: 6 since Nov 2009
Thanks: 4 given,
Prevent strategy from executing trade at the same price level within a session
I have been researching the following topic of saving a variable in NT for use within a strategy to prevent the strategy from executing at the same price more than once within a session and I'm having some trouble trying to get it to compile.
If anyone one has the chance to review the code attached I would appreciate any help you can provide...
Thank you in advance,
// Copyright (C) 2007, NinjaTrader LLC
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
#region Using declarations
// This namespace holds all strategies and is required. Do not change it.
/// Sample strategy
public class MyCustomStrategy : Strategy
double myEntryOrder = Position.AvgPrice;
/// This method is used to configure the strategy and is called once before any strategy method is called.
protected override void Initialize()
SetStopLoss("", CalculationMode.Ticks, 25, false);
SetProfitTarget("", CalculationMode.Ticks, 6);
CalculateOnBarClose = false;
/// Called on each bar update event (incoming tick)
protected override void OnBarUpdate()
// Condition set 1
if (CurrentDayOHL().CurrentLow >= IY().IU
&& Position.MarketPosition == MarketPosition.Flat
&& BarsSinceExit() > 40 && myEntryOrder != IY().IU)
myEntryOrder = EnterLongLimit(DefaultQuantity, IY().IU, "");