SmartQuant Discussion
http://www.smartquant.com/forums/

BarFactory - How to make bars from middle?
http://www.smartquant.com/forums/viewtopic.php?f=60&t=14884
Page 1 of 1

Author:  abasqd [ Wed Jan 23, 2019 4:49 am ]
Post subject:  BarFactory - How to make bars from middle?

I have taken the Bollinger band example strategy and edited it to make bars from BarInput.Middle. However, no bars are being produced by BarFactory. I've also tried using BarInput.Bid, BarInput.Ask and ClockType.Local but no bars produced. Here is my code. Any help?

namespace OpenQuant
{
public class Backtest : Scenario
{
private long barSize = 300;

public Backtest(Framework framework)
: base(framework)
{
}

public override void Run()
{
Instrument instrument1 = InstrumentManager.Instruments["AAPL"];
Instrument instrument2 = InstrumentManager.Instruments["MSFT"];

strategy = new MyStrategy(framework, "BollingerBands");

strategy.AddInstrument(instrument1);
//strategy.AddInstrument(instrument2);

DataSimulator.SubscribeBar = false;
DataSimulator.DateTime1 = new DateTime(2013, 01, 01);
DataSimulator.DateTime2 = new DateTime(2013, 12, 31);

BarFactory.Clear();
BarFactory.Add(instrument1, BarType.Time, barSize, BarInput.Middle, ClockType.Exchange, DataSimulator.Id);
//BarFactory.Add(instrument1, BarType.Time, barSize);
//BarFactory.Add(instrument2, BarType.Time, barSize);

StartStrategy();
}
}
}

Author:  skuvv [ Wed Jan 23, 2019 9:56 am ]
Post subject:  Re: BarFactory - How to make bars from middle?

Hello,
Try this line:
Code:
BarFactory.Add(instrument1, BarType.Time, barSize, BarInput.Middle);

instead of:
Code:
BarFactory.Add(instrument1, BarType.Time, barSize, BarInput.Middle, ClockType.Exchange, DataSimulator.Id);

Author:  abasqd [ Fri Feb 01, 2019 5:29 am ]
Post subject:  Re: BarFactory - How to make bars from middle?

hmmm, this works but I can't seem to find this particular method signature in the class reference.

Author:  skuvv [ Fri Feb 01, 2019 9:36 am ]
Post subject:  Re: BarFactory - How to make bars from middle?

abasqd wrote:
hmmm, this works but I can't seem to find this particular method signature in the class reference.

It is same method.
ClockType.Exchange and DataSimulator.Id are optional parameters.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/