namespace QuantConnect
{
/*
* OANDA/QuantConnect Basic Template:
* Fundamentals to using a QuantConnect algorithm.
*
* You can view the QCAlgorithm base class on Github:
* https://github.com/QuantConnect/Lean/tree/master/Algorithm
*/
public class BasicTemplateAlgorithm : QCAlgorithm
{
private RollingWindow<IndicatorDataPoint> BBWIN;
BollingerBands Bol;
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
// Date range for your backtest
// In live trading these are ignored.
SetStartDate(2016, 1, 1);
SetEndDate(2016, 6, 1);
// Set cash allocation for backtest
// In live trading this is ignored and your real account is used.
SetCash(5000);
// Specify the OANDA Brokerage: This gives lets us know the fee models & data.
SetBrokerageModel(BrokerageName.OandaBrokerage);
//Add as many securities as you like. All the data will be passed into the event handler:
AddForex("GBPUSD", Resolution.Minute, Market.Oanda);
Bol = BB("GBPUSD", 20, 20, MovingAverageType.Simple);
BB("GBPUSD", 20, 20).Updated += (sender, updated) => BBWIN.Add(updated);
BBWIN = new RollingWindow<IndicatorDataPoint>(5);
}
// Event handler for the price events
public override void OnData(Slice data)
{ if (!BBWIN.IsReady) return;
var bbpast1 = BBWIN[1];
if (!Portfolio.HoldStock)
{
}
Plot("PAST", "Bollinger", Bol.MiddleBand);
Plot("PAST", "BB Past", bbpast1);
}
}
}