Overall Statistics
Total Trades
3
Average Win
37.46%
Average Loss
-3.10%
Annual Return
44.338%
Drawdown
14.300%
Expectancy
7.735
Net Profit
70.657%
Sharpe Ratio
1.595
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
12.10
Alpha
0.18
Beta
0.853
Annual Standard Deviation
0.226
Annual Variance
0.051
Information Ratio
0.722
Tracking Error
0.207
Treynor Ratio
0.423
using System;
using System.Collections;
using System.Collections.Generic; 
using QuantConnect.Securities;  
using QuantConnect.Models;   

namespace QuantConnect { 
    /*************************************************************************** 
        ORDERS
        Orders are placed through the Order() Method. Here you simply enter 
        the string symbol and int quantity of the asset you'd like to buy or sell
    ***************************************************************************/
    
    public class OrdersExample : QCAlgorithm
    {
        public override void Initialize()
        {
            SetStartDate(2013, 1, 1);         
            SetEndDate(DateTime.Now.Date.AddDays(-1)); 
            SetCash(50000);
            AddSecurity(SecurityType.Equity, "MSFT", Resolution.Minute); 
        }
        
        public void OnData(TradeBars securityData) 
        {   
            try
            {
                //If we don't hold any MSFT stocks, buy all possible with the money aviable
                if (securityData["MSFT"].Open <= 44.45m && !Portfolio.HoldStock) 
                {
                    Order("MSFT", (int)Math.Floor(Portfolio.Cash / securityData["MSFT"].Close));
                }
    		    //If the price of the stock is bigger than $44.5, sell them all (If we have any)
    		    if (securityData["MSFT"].Open >= 45.1m && Portfolio.HoldStock)
    		    {
    		        Order("MSFT", -Portfolio["MSFT"].Quantity);
                }
            }
            catch(Exception err) 
            {
                Error("OnData Err: " + err.Message);
            }
        }
    }
}