| 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 Probabilistic 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 6.363 Tracking Error 0.113 Treynor Ratio 0 Total Fees $0.00 |
using System;
using System.Linq;
using QuantConnect.Indicators;
using QuantConnect.Models;
namespace QuantConnect.Algorithm.Examples
{
public class QCUMovingAverageCross : QCAlgorithm
{
private const string Symbol = "USDJPY";
private ExponentialMovingAverage fast;
private ExponentialMovingAverage slow1;
private ExponentialMovingAverage slow2;
private SimpleMovingAverage[] ribbon;
private MovingAverageConvergenceDivergence macd;
private DateTime current;
public override void Initialize()
{
// set up our analysis span
current = new DateTime(2020,05,18);
current = current.AddHours(+11);
SetStartDate(2020,05, 18);
SetEndDate(2020,5, 19);
//SetEndDate(DateTime.Now.Date.AddDays(-1));
SetCash(1000);
// request SPY data with minute resolution
AddForex(Symbol, Resolution.Hour, Market.Oanda);
SetBrokerageModel(BrokerageName.OandaBrokerage);
// create a 15 day exponential moving average
//fast = EMA(Symbol, 9, Resolution.Minute);
// create a 30 day exponential moving average
//slow1 = EMA(Symbol, 50, Resolution.Minute);
//slow2 = EMA(Symbol, 100, Resolution.Minute);
macd = MACD(Symbol, 12, 26, 9, MovingAverageType.Simple, Resolution.Hour);
}
public void OnData(TradeBars data) {
Decimal price = data[Symbol].Close;
price = Math.Round(price, 2);
Debug(current.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ss")+" "+price);
current =current.AddHours(+1);
Plot(Symbol, "Price", price);
Plot("MACD", macd, macd.Signal);
}
// Access data via grouped time slice method handlers:
public override void OnData(Slice data) {
//Debug(data.Bars[Symbol].Close);
}
//Plot(Symbol, "Price", data[Symbol].Price);
//Plot("Ribbon", "Price", data[Symbol].Price);
//Plot("MACD", macd.Fast, macd.Slow);
}
}