Overall Statistics Total Trades26Average Win479.29%Average Loss-13.64%Compounding Annual Return10.373%Drawdown84.100%Expectancy5.774Net Profit161.806%Sharpe Ratio0.437Loss Rate81%Win Rate19%Profit-Loss Ratio35.13Alpha0.206Beta0.046Annual Standard Deviation0.48Annual Variance0.23Information Ratio0.229Tracking Error0.516Treynor Ratio4.607Total Fees\$242.07
```using MathNet.Numerics;

namespace QuantConnect
{
public class AnnualizedExponentialSlope : WindowIndicator<IndicatorDataPoint>
{
public AnnualizedExponentialSlope(int period)
{
}

public AnnualizedExponentialSlope(string name, int period)
: base(name, period)
{
}

protected override decimal ComputeNextValue(IReadOnlyWindow<IndicatorDataPoint> window, IndicatorDataPoint input)
{
if (window.Count < 3) return 0m;

var xVals = new double[window.Count];
var yVals = new double[window.Count];

// load input data for regression
for (int i = 0; i < window.Count; i++)
{
xVals[i] = i;
// we want the log of our y values
yVals[i] = Math.Log((double)window[window.Count - i - 1].Value);
}

//http://numerics.mathdotnet.com/Regression.html

// solves y=a + b*x via linear regression
var fit = Fit.Line(xVals, yVals);
var intercept = fit.Item1;
var slope = fit.Item2;

// compute rsquared
var rsquared = GoodnessOfFit.RSquared(xVals.Select(x => intercept + slope*x), yVals);

// anything this small can be viewed as flat
if (double.IsNaN(slope) || Math.Abs(slope) < 1e-25) return 0m;

// trading days per year for us equities
const int dayCount = 252;

// annualize dy/dt
var annualSlope = ((Math.Pow(Math.Exp(slope), dayCount)) - 1) * 100;

// scale with rsquared
annualSlope = annualSlope * rsquared;

return (decimal) annualSlope;
}
}
}```
```namespace QuantConnect
{
public class BasicTemplateAlgorithm : QCAlgorithm
{
private RateOfChangePercent ROCPyear;
private RateOfChange ROCPROCPyear;
//private ROCPRateOfChangePercent ROCPROCPyear;
private string symbol;

public override void Initialize()
{
SetStartDate(2006, 1, 1);
SetEndDate(DateTime.Now);
SetCash(25000);
symbol = "LNG";

ROCPyear = new RateOfChangePercent(252); // 252 trading days in a US year
RegisterIndicator(symbol, ROCPyear, Resolution.Daily, Field.Close);
PlotIndicator("ROCP", true, ROCPyear);

ROCPROCPyear = new RateOfChange(252).Of(ROCPyear);
//ROCPROCPyear = new ROCPRateOfChangePercent(252);
//RegisterIndicator(symbol, ROCPROCPyear, Resolution.Daily, Field.Close);
PlotIndicator("ROCP", true, ROCPROCPyear);
}

//Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
{

var quantity = Portfolio[symbol].Quantity;
if (quantity == 0 && ROCPyear > 20)
{
SetHoldings(symbol, .75);
}
if (quantity > 0) {
if (ROCPyear < 0) {
SetHoldings(symbol, 0);
}
}
if (quantity < 0) {
if (ROCPyear > 0) {
SetHoldings(symbol, 0);
}
}
if (quantity == 0 && ROCPyear < -20)
{
SetHoldings(symbol, -.75);
}
}
}
}```