Once I pop it on the chart, it shows previous trades, trailing, exits and the output shows print messages accordingly, but once the chart starts to move it just doesn't take a single trade and it's like no signals at all are working.
It's based on an indicator that shows the large B in the picture and the indicator works in Market replay. I even tried using the indicator code inside the strategy but I get the same results. Working in analyzer but not in playback. The SampleMAcrossover works (that thing always does..).
I've narrowed the problem down to bullSig / bearSig never becoming TRUE even though the indicator works in market replay. But when I enabled the strategy, previous Prints in the output shows that the signals work like intended.
I use this code in OnBarUpdate:
if (Position.MarketPosition == MarketPosition.Flat )
{
if (bullSig[0] )
{
EnterLong(_posSize, LongName);
}
else if (bearSig[0])
{
EnterShort(_posSize, ShortName);
}
}
else if (Position.MarketPosition != MarketPosition.Flat)
{
//trailing stops
if (BarsSinceEntryExecution() > 0)
{
MoveTrailingStop();
}
}
//this gets called when an order gets filled on the exchange
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
//If order is opened and filled, set stops
if (IsEntryOrderFilled(execution))
{
//Set stop and profit
SetInitialStops(execution);
}
}
private bool IsEntryOrderFilled(Execution execution)
{
return execution.Order.OrderState == OrderState.Filled;
}

Comment