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
using QuantConnect.Indicators;
using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data.Market;
using QuantConnect.Util;

namespace QuantConnect.Algorithm.CSharp
{
    public class ForexAlgorithm : QCAlgorithm
    {
        public enum Decision { Long, Short, Neutral };
        public const int length = 100;
        // keep 5 of the last data points, max index of 4
        public RollingWindow<TradeBar> History =  new RollingWindow<TradeBar>(5);

        // we want 3 decisions in a row to be the same
        public RollingWindow<Decision> RecentDecisions = new RollingWindow<Decision>(2);

        // define some indicators
        public ExponentialMovingAverage EUREMA,GBPEMA,AUDEMA;

        // these will hold the history of our indicators
        public RollingWindow<decimal> EURHistory = new RollingWindow<decimal>(10);
        public RollingWindow<decimal> AUDHistory = new RollingWindow<decimal>(10);
        public RollingWindow<decimal> GBPHistory = new RollingWindow<decimal>(10);

        //Initialize the data and resolution you require for your strategy:
        public override void Initialize()
        {
            //Start and End Date range for the backtest:
            SetStartDate(2013, 1, 1);
            SetEndDate(DateTime.Now.Date.AddDays(-1));

            //Cash allocation
            SetCash(25000);
            AddSecurity(SecurityType.Forex, "EURUSD", Resolution.Daily);
            AddSecurity(SecurityType.Forex, "GBPUSD", Resolution.Daily);
            AddSecurity(SecurityType.Forex, "AUDUSD", Resolution.Daily);

            EUREMA = EMA("EURUSD", length,Resolution.Daily);
            GBPEMA = EMA("GBPUSD", length, Resolution.Daily);
            AUDEMA = EMA("AUDUSD", length, Resolution.Daily);
        }
        //Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
        public void OnData(TradeBars data)
        {
            // Add the data from this time step to our rolling windows
            if(data.ContainsKey("EURUSD"))
                EURHistory.Add(data["EURUSD"].Close - EUREMA.Current.Price);
            if (data.ContainsKey("AUDUSD"))
                AUDHistory.Add(data["AUDUSD"].Close - AUDEMA.Current.Price);
            if (data.ContainsKey("GBPUSD"))
                GBPHistory.Add(data["GBPUSD"].Close - GBPEMA.Current.Price);

            // wait for our history to be ready
            if (!History.IsReady) return;
            // start our analysis

			Debug("GBP is %d" + GBPHistory[1]);
        }
    }
}