Overall Statistics
Total Trades
6001
Average Win
0%
Average Loss
0.00%
Compounding Annual Return
-99.863%
Drawdown
12.000%
Expectancy
-1
Net Profit
-12.002%
Sharpe Ratio
-21.272
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-3.415
Beta
-0.494
Annual Standard Deviation
0.187
Annual Variance
0.035
Information Ratio
-19.374
Tracking Error
0.264
Treynor Ratio
8.057
Total Fees
$12002.00
namespace QuantConnect 
{   
    
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	//parameters go here
    	const decimal StopLossPercent = 0.02m;
    	const decimal TakeProfitPercent = 0.04m;
    	Decimal StopLoss = 0.04m;
    	Decimal TakeProfit = 0.065m;
    	private OrderTicket CurrentOrder;
        int quantity = 10000;
        decimal price = 0;
        decimal tolerance = 0m; //0.1% safety margin in prices to avoid bouncing.
        DateTime sampledToday = DateTime.Now;
        SimpleMovingAverage smaShort;
        SimpleMovingAverage smaLong;
        String symbol = "USDCAD" ;
        private Identity yesterdayClose;
        int holdings = 0;
       
        //int leverage = 50; Enable for borrowing abilities (max is 50x for fx, 2x? for equities)
        
        public override void Initialize() 
        {
			//AddSecurity(SecurityType.Equity, Symbol, Resolution.Minute); Uncomment this for stocks
			AddSecurity(SecurityType.Forex, symbol , Resolution.Minute);
		
			//Set backtest dates here
            SetStartDate(2016, 3 , 1);         
            SetEndDate(2016, 3, 18);
            
            //Set Backtest cash amount here
            SetCash(100000);
            
            //MA's go here
            smaShort = SMA(symbol, 5, Resolution.Minute);
            smaLong = SMA(symbol, 25, Resolution.Minute);
           
            // this will get us an indicator that represents our symbol's closing price
            yesterdayClose = Identity(symbol, Resolution.Minute, Field.Close);
        }
        public void OnData(TradeBars data) 
        {   
             // set price based on previous minute bar
            price = data[symbol].Close;
            
            //Algo buying logic below
            if (holdings <= 0 && smaShort > smaLong && price > smaShort) 
            {
               CurrentOrder = Order(symbol,  quantity);
               StopLoss = StopMarketOrder(symbol, quantity, price * (1m - StopLossPercent));
               TakeProfit = LimitOrder(symbol, quantity, price * (1m + TakeProfitPercent)) ;
               SetHoldings(symbol, 1.0);
           	  }
           	  
            if (holdings > 0 && price <= StopLoss || price >= TakeProfit);
            {
             	Log("Dumped >> " + Securities[symbol].Price);
             	Liquidate(symbol) ;
             	SetHoldings(symbol, 0.0);
            }  
                //Debug sends messages to the user console: "Time" is the algorithm time keeper object 
                Debug("Purchased USDCAD on " + Time.ToShortDateString());
                //Log("This is a longer message send to log.");
            } 
        }
    }