Overall Statistics Total Trades2Average Win0%Average Loss-0.04%Compounding Annual Return-2.404%Drawdown0.000%Expectancy-1Net Profit-0.040%Sharpe Ratio-4.898Loss Rate100%Win Rate0%Profit-Loss Ratio0Alpha-0.02Beta0.049Annual Standard Deviation0.003Annual Variance0Information Ratio-1.933Tracking Error0.038Treynor Ratio-0.345Total Fees\$2.00
```namespace QuantConnect {

//
//	Make sure to change "BasicTemplateAlgorithm" to your algorithm class name, and that all
//	files use "public partial class" if you want to split up your algorithm namespace into multiple files.
//

//public partial class BasicTemplateAlgorithm : QCAlgorithm, IAlgorithm
//{
//  Extension functions can go here...(ones that need access to QCAlgorithm functions e.g. Debug, Log etc.)
//}

//public class Indicator
//{
//  ...or you can define whole new classes independent of the QuantConnect Context
//}
public class movingaveragealgorithm
{
private decimal period;
private decimal ema;
private int samples;

public decimal EMA
{
get {return ema;}
}
public movingaveragealgorithm(decimal period)
{
this.period=period;
}
{
get {return samples>=period;}
}
{
if(samples==0)
{
ema=price;
}else
{
ema=(1/period)*price+((period-1)/period)*ema;
}
samples++;
return ema;
}
}

}```
```// using System;
// using System.Linq;
// using QuantConnect.Data;
// using QuantConnect.Data.Consolidators;
// using QuantConnect.Data.Market;
// using QuantConnect.Indicators;

// namespace QuantConnect.Algorithm
// {
//     public  class TimeIndicator
//     {
//         bool isMonday;
//         bool isFriday;

//         public bool day(Time date)
//         {
//         	if(date.Date.DayOfWeek==DayOfWeek.Monday)
//         	return true;
//         }

//     } // End Partial Algorithm Template - Indicators.

// } // End QC Namespace```
```

namespace QuantConnect
{

public class BasicTemplateAlgorithm : QCAlgorithm
{

private  string symbol = "UVXY";
private  int quantity=100;
private  int trigger=0;
//movingaveragealgorithm emafast=new movingaveragealgorithm(10);
//movingaveragealgorithm emaslow=new movingaveragealgorithm(50);
//MovingAverageConvergenceDivergence _macd;

public override void Initialize()
{
SetStartDate(2016, 07, 22);
SetEndDate(2016, 07, 27);
SetCash(30000);

Schedule.On(DateRules.Every(DayOfWeek.Friday), TimeRules.AfterMarketOpen("UVXY",0), () =>
{
trigger=-1;
Log(Time.ToString()+"");
});

Schedule.On(DateRules.Every(DayOfWeek.Monday), TimeRules.BeforeMarketClose("UVXY",0), () =>
{
trigger=1;
Log(Time.ToString()+"");
});

}

{
Log(Time.ToString()+"\t"+Securities["UVXY"].Close);
if(trigger==-1&&!Portfolio.HoldStock)
{
Order(symbol, -quantity);
Log(Time.ToString()+"\t"+"short "+quantity);
}
else if(trigger==1&&Portfolio.HoldStock)
{
Order(symbol,quantity);
Log(Portfolio["UVXY"].Quantity+"");
Log(Time.ToString()+"\t"+"close "+quantity);

}

}
}
}```