Overall Statistics Total Trades1Average Win60.38%Average Loss0%Compounding Annual Return27.5%Drawdown12.100%Expectancy0Net Profit60.377%Sharpe Ratio1.257Loss Rate0%Win Rate100%Profit-Loss Ratio0Alpha0.113Beta0.706Annual Standard Deviation0.203Annual Variance0.041Information Ratio0.28Tracking Error0.191Treynor Ratio0.361
```using System;
using System.Collections;
using System.Collections.Generic;
using QuantConnect.Securities;
using QuantConnect.Models;

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
Order _limitOrder;
string _symbol = "MSFT";
decimal _price = 0;
int _rebalancePeriod = 20;
DateTime _updatedDate;
LimitedQueue<decimal> _queue = new LimitedQueue<decimal>(30);

//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 (_limitOrder == null)
{
//Set our first order to half of microsoft's price Jan-2013
_limitOrder = new Order(_symbol, (int)(Portfolio.Cash/_price), OrderType.Limit, Time, (_price * 0.95m), "Our customized limit order");

Debug("Creating first limit order: " + _symbol + " Price: " + _price.ToString("C"));

_limitOrder.Id = id;
}

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

_limitOrder.Price = (_price * 0.95m);

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.Price);
_queue.Enqueue(_price);
}
}
}```