///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Entry Condition: When the Low crosses below the lower bollinger band, enter long
if (CrossBelow(Low, Bollinger(2, 14).Lower, 1))
{
// Only allow entries if we have no current positions open
if (Position.MarketPosition == MarketPosition.Flat)
{
/* Enters two long positions.
We submit two orders to allow us to be able to scale out half of the position at a time in the future.
With individual entry names we can differentiate between the first half and the second half of our long position.
This lets us place a Profit Target order only for the first half and Trail Stops for both. */
EnterLong("Long 1a");
EnterLong("Long 1b");
}
}
//Entry Condition: When the High crosses above the higher bollinger band, enter short
if (CrossAbove(High, Bollinger(2, 14).High, 1))
{
// Only allow entries if we have no current positions open
if (Position.MarketPosition == MarketPosition.Flat)
{
/* Enters two short positions.
We submit two orders to allow us to be able to scale out half of the position at a time in the future.
With individual entry names we can differentiate between the first half and the second half of our long position.
This lets us place a Profit Target order only for the first half and Trail Stops for both. */
EnterShort("Short 1a");
EnterShort("Short 1b");
}
}
}

Comment