Overall Statistics Total Trades1Average Win65.08%Average Loss0%Compounding Annual Return26.757%Drawdown18.00%Expectancy0Net Profit65.081%Sharpe Ratio1.141Loss Rate0%Win Rate100%Profit-Loss Ratio0Alpha0.069Beta0.956Annual Standard Deviation0.227Annual Variance0.052Information Ratio0.304Tracking Error0.2Treynor Ratio0.271
```namespace QuantConnect
{
/*
*   QuantConnect University - Creating and Updating Limit Orders
*
*   This algorithm walks through an example of creating and updating a limit order.
*   The orders are stored in the Transactions Manager inside the algorithm.
*
*   For the demonstration we will place a buy limit order for 1 SD below of microsoft's price,
*   and every day update it until its filled
*/
public class QCULimitOrders : QCAlgorithm
{
//Access for the order we'll place
int _limitOrderId = 0;
LimitOrder _limitOrder;
string _symbol = "MSFT";
decimal _price = 0;
int _rebalancePeriod = 20;
DateTime _updatedDate;

//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
SetStartDate(2013, 1, 1);
SetCash(25000);
}

//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
{
//if (data.Contains("MSFT"))
_price = data["MSFT"].Close;

//Create the first order
if (_limitOrderId == 0)
{
//Set our first order to less than MS's price:
_limitOrderId = LimitOrder(_symbol, (int)(Portfolio.Cash/_price), (_price * 0.95m));
_limitOrder = (LimitOrder)Transactions.GetOrderById(_limitOrderId);
Debug("Created first limit order with " + _symbol + " Price: " + _price.ToString("C") + " id: " + _limitOrderId);
}

//Update the limit price once per week:
if (_updatedDate.Date < Time.Date && !Portfolio.Invested)
{

_limitOrder.LimitPrice = (_price * 0.99m);

Transactions.UpdateOrder(_limitOrder);
}
}

/*
*   For our plotting we can show the limit price and MSFT to check if its hit.
*/
public override void OnEndOfDay()
{
Plot("Limit Plot", "MSFT", _price);
Plot("Limit Plot", "Limit", _limitOrder.LimitPrice);
}
}
}```