I'm using a stoploss order to help shore up some profits from an otherwise great signal. the problem is, the stoploss hits the signal is still showing a "buy" and then I'm back in a position.
My thought was to set a counter variable in OnExecution equal to some number of bars and then prevent OnBarUpdate from calculating until that counter decremented to zero.
The goal here is to allow some time period to expire before reverting back to the signal (the signal usually catches up to the same exit idea a minute or two after the stoploss executes).
protected override void OnExecution(IExecution execution)
{
if(execution.Order.OrderType == OrderType.Stop)
{
timeOut = 10;
}
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if( timeOut>0)
timeOut--;
else
{ else calc signal for trading
This code is causing a lot of errors in optimization and I'm trying to see if there's an order of events I'm missing or maybe OnExecution is called multiple times, resetting the timeOut variable...there's something I'm missing here...
Thank you for your help!
Comment