Take this example:
protected override void Initialize()
{
EntriesPerDirection = 5;
EntryHandling = EntryHandling.AllEntries;
}
protected override void OnBarUpdate()
{
if (XYZ()[0] == 1)
// should do ONE of the following tasks this bar (i.e. don't reverse in one step):
// if currently long < 5 contracts, should long another one
// if currently hold short position(s), should close one short position now
EnterLongLimit(GetCurrentBid())
if (XYZ()[0] == 0)
// if hold any contracts (short or long), close 1 position now
ExitLongLimit(GetCurrentBid());
ExitShortLimit(GetCurrentAsk());
if (XYZ()[0] == -1)
// should do ONE of the following tasks this bar (i.e. don't reverse in one step):
// if currently short < 5, should short another one
// if currently hold a long position, should close one long position now
EnterShortLimit(GetCurrentAsk())
}

Comment