I am now trying to use this to automate a trading strategy. I created the strategy over this past weekend and it appeared to be working fine. When I ran it on Sunday and I look at the real-time and historical performance the trades that were executed from 12/05/08 - 01/02/09 match up perfectly. All of the buys and sells show up on the chart and match up exactly with the indicator.
For some reason the strategy did not work Monday or Tuesday in realtime although the indicator triggered multiple times. And furthermore Monday night I stopped the strategy and restarted it and it then shows the trades for Monday just fine. But those trades did not trigger when it was running during the day on Monday. Here is the strategy code:
protected override void Initialize()
{
EntriesPerDirection = 4;
EntryHandling = EntryHandling.AllEntries;
TimeInForce = Cbi.TimeInForce.Day;
TraceOrders = true;
SetProfitTarget("1", CalculationMode.Ticks, 4);
SetProfitTarget("2", CalculationMode.Ticks, 8);
SetStopLoss("1", CalculationMode.Ticks, 6, false);
SetStopLoss("2", CalculationMode.Ticks, 6, false);
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1 ---Long Setup---
if (Close[0] > MySetup().Buy[0])
{
// Only allow entries if we have no current positions open
if (Position.MarketPosition == MarketPosition.Flat)
{
EnterLongLimit(1, MySetup().Buy[0], "1");
EnterLongLimit(1, MySetup().Buy[0], "2");
}
}
// Condition set 2 ---Short Setup---
if (Close[0] < MySetup().Sell[0])
{
// Only allow entries if we have no current positions open
if (Position.MarketPosition == MarketPosition.Flat)
{
EnterShortLimit(1, MySetup().Sell[0], "1");
EnterShortLimit(1, MySetup().Sell[0], "2");
}
}
}
I am running this on the Sim account if that matters.
I start a new chart, add the indicator, add the strategy... Is there something else I need to be doing?

Comment