Profile Picture

No bid data in backtest

Posted By steven 7 Years Ago
Posted Tuesday April 19 2011

When I run my trading system in simulation, I find all bid & ask price always equals 0, it causes my order never get filled. Maybe I can use other price for backtest, but I don't wanna change my code for simulation and live separately.

Here's my code snippet:

    PositionSettings settings = new PositionSettings();  
    settings.PositionType = signal == TradeSignal.Long ? PositionType.Long :
    settings.LimitPrice = signal == TradeSignal.Long ? Ask.Current : Bid.Current;
    settings.OrderType = OrderType.Limit;
    settings.Size = 1;
    settings.BarsValid = -1;
    settings.BarCountExit = -1;
    settings.StopLossType = TargetPriceType.AbsolutePrice;
    settings.StopLoss = signal == TradeSignal.Long ? BarUtils.LowestLow(Bars, 2) :
      BarUtils.HighestHigh(Bars, 2);

So could you please tell me there is a way to figure this out?

Thanks in advance

Posted Tuesday April 19 2011
This is because in your historical bar data, the bid and ask for each bar is zero. You can change it so that the bid and ask are equal to the close. There's several ways to do this.

You could modify the data store plugin (source code is included in the samples) to fix the bars while they are being retrieved from the data store. I think this is the simplest option.

You could modify the historical data retrieval plugin to fix the bars as they are downloaded.

You could write a program that would load the data from the data store, fix it, and then re-save it.

Posted Tuesday April 19 2011
Thanks. I'll try it

Similar Topics

Reading This Topic

2005-2018 © RightEdge Systems