| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
namespace QuantConnect
{
class SimpleExample : QCAlgorithm
{
Symbol _symbol;
SimpleMovingAverage _sma;
RollingWindow<IndicatorDataPoint> _window;
public override void Initialize()
{
SetStartDate(2015, 11, 01);
SetEndDate(2015, 11, 2);
SetCash(10000);
_symbol = AddForex("EURUSD").Symbol;
_sma = new SimpleMovingAverage(10);
_window = new RollingWindow<IndicatorDataPoint>(2);
// Here is where the RollingWindow is updated with the latest SMA observation.
_sma.Updated += (object sender, IndicatorDataPoint updated) =>
{
_window.Add(updated);
};
var fiveMinuteConsolidator = new QuoteBarConsolidator(TimeSpan.FromMinutes(5));
SubscriptionManager.AddConsolidator(_symbol, fiveMinuteConsolidator);
RegisterIndicator(_symbol, _sma, fiveMinuteConsolidator);
}
public override void OnData(Slice slice)
{
if (!_window.IsReady) return;
Log("SMA value :" + _sma);
Log("Previous SMA value: " + _window[1]);
// Here you can implement your logic.
if (_window[1] > _window[0])
{
//Do stuff
}
}
}
}