PDA

View Full Version : Delay entry execution following a signal


bkool
05-13-2010, 01:10 PM
My love and appreciations to the NT development team - it a great application.

I wonder how to program a delay entry execution following a signal.
Say in the following examples:

a) The buy signal is generated in bar[0], but I wish to delay the actual buy order after the next x bars.
b) The buy signal is generated in bar[0], and I wish to limit the actual buy order to a certain price (say High[0] + x.

Many thanks.

bkool

NinjaTrader_Tim
05-13-2010, 01:35 PM
Hi bkool,

1. You could use a variable and CurrentBar to record the bar number that the condition is met. Then wait until the CurrentBar reaches the variable plus x.

More info at - http://www.ninjatrader.com/support/helpGuides/HelpGuideV6/helpguide.html?CurrentBar

2. You can use a Stop order for this....
EnterLongStop() - http://www.ninjatrader.com/support/helpGuides/HelpGuideV6/helpguide.html?EnterLongStop
(http://www.ninjatrader.com/support/helpGuides/HelpGuideV6/helpguide.html?EnterLongStop)
EnterLongStopLimit() - http://www.ninjatrader.com/support/helpGuides/HelpGuideV6/helpguide.html?EnterLongStopLimt

bkool
05-23-2010, 11:43 AM
Thanks Tim,

This was helpful.

I saw a nice exmple in the NT7 guide explaining about CancelOrder(IOrder order) :

Examples
private IOrder myEntryOrder = null;
private int barNumberOfOrder = 0;

protected override void OnBarUpdate()
{
// Submit an entry order at the low of a bar
if (myEntryOrder == null)
{
myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry");
barNumberOfOrder = CurrentBar;
}

// If more than 5 bars has elapsed, cancel the entry order
if (CurrentBar > barNumberOfOrder + 5)
CancelOrder(myEntryOrder);
}


http://www.ninjatrader.com/support/helpGuides/nt7/index.html

best,

bkool.