Overall Statistics
Total Trades
2
Average Win
0%
Average Loss
-0.01%
Compounding Annual Return
-0.091%
Drawdown
0.000%
Expectancy
-1
Net Profit
-0.008%
Sharpe Ratio
-2.948
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.001
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-5.047
Tracking Error
0.043
Treynor Ratio
-2.084
Total Fees
$2.00
using System.Threading;
using System.Threading.Tasks;

namespace QuantConnect 
{ 
    public partial class QCUMartingalePositionSizing : QCAlgorithm 
    {
        public override void Initialize()
        {
        	SetCash(25000);
            SetStartDate(2017, 10, 1);
            SetEndDate(2017, 11, 1); 
            SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage);
            AddSecurity(SecurityType.Equity, "MSFT", Resolution.Hour, true, 4m, false);
        }
        
        public void OnData(TradeBars data) 
        {
        	if (Transactions.OrdersCount == 0)
        	{
        		var price = Securities["MSFT"].Price;
        		
        		MarketOrder("MSFT", 1);				// Buy 1 share of MS
        		StopMarketOrder("MSFT", -1, 1000m); // Sell 1 share only when price hits $1000
        		
        		// In some reason both orders execute at the same time
        	}
        }
    }
}