| Overall Statistics |
|
Total Trades 82 Average Win 0.66% Average Loss -0.60% Compounding Annual Return 0.562% Drawdown 5.200% Expectancy 0.005 Net Profit 0.563% Sharpe Ratio 0.099 Probabilistic Sharpe Ratio 15.762% Loss Rate 52% Win Rate 48% Profit-Loss Ratio 1.10 Alpha 0.012 Beta -0.02 Annual Standard Deviation 0.071 Annual Variance 0.005 Information Ratio -2 Tracking Error 0.125 Treynor Ratio -0.347 Total Fees $0.00 Estimated Strategy Capacity $660000.00 |
using System;
using System.Linq;
using QuantConnect;
using QuantConnect.Algorithm;
using QuantConnect.Brokerages;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
using QuantConnect.Indicators.CandlestickPatterns;
using QuantConnect.Orders;
using QuantConnect.Parameters;
namespace cristian
{
/// <summary>
/// Basic template algorithm simply initializes the date range and cash
/// </summary>
public class TestCandlestickAlgorithm : QCAlgorithm
{
private RollingWindow<QuoteBar> _window;
private string _symbol = "EURUSD";
/// <summary>
/// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
/// </summary>
public override void Initialize()
{
SetStartDate(2013, 1, 1); //Set Start Date
SetEndDate(2013, 12, 31); //Set End Date
SetCash(100000); //Set Strategy Cash
// Find more symbols here: http://quantconnect.com/data
AddForex(_symbol, Resolution.Daily);
_window = new RollingWindow<QuoteBar>(2);
}
/// <summary>
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// </summary>
/// <param name="data">Slice object keyed by symbol containing the stock data</param>
public override void OnData(Slice data)
{
if(data.ContainsKey(_symbol))
{
_window.Add(data[_symbol]);
}
if (!_window.IsReady)
{
return;
}
var currBar = _window[0];
var pastBar = _window[1];
int _pattern;
if ((pastBar.Open > pastBar.Close && currBar.Close > currBar.Open)
&& (pastBar.Open - pastBar.Close < currBar.Close - currBar.Open)
&& (pastBar.Open <= currBar.Close && pastBar.Close >= currBar.Open))
{
// Bullish Engulfing, go long
_pattern = 1;
SetHoldings(_symbol, 1);
Log(_pattern);
}
if ((pastBar.Open < pastBar.Close && currBar.Close < currBar.Open)
&& (pastBar.Close - pastBar.Open < currBar.Open - currBar.Close)
&& (pastBar.Open >= currBar.Close && pastBar.Close <= currBar.Open))
{
// Bearish Engulfing, go short
_pattern = -1;
SetHoldings(_symbol, -1);
Log(_pattern);
}
}
}
}