It is from sample code from NT "Strategy: Monitoring for and trading a breakout "
I especially wonder if how "FirstBarOfSession" and "BarsSinceSession " work here.
Thanks
protectedoverridevoid OnBarUpdate()
{
// Resets the highest high at the start of every new session
if (Bars.FirstBarOfSession)
highestHigh = High[0];
// Stores the highest high from the first 30 bars
if (Bars.BarsSinceSession < 30 && High[0] > highestHigh)
highestHigh = High[0];
// Entry Condition: Submit a buy stop order one tick above the first 30 bar high. Cancel if not filled within 10 bars.
if (Bars.BarsSinceSession > 30 && Bars.BarsSinceSession < 40)
{
// EnterLongStop() can be used to generate buy stop orders.
EnterLongStop(highestHigh + TickSize);
}
// Exit Condition: Close positions after 10 bars have passed
if (BarsSinceEntry() > 10)
ExitLong();
}

Comment