Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -2.19 Tracking Error 0.137 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
using System; using System.Drawing; namespace QuantConnect.Algorithm.CSharp { public class CasualYellowGreenLemur : QCAlgorithm { //Initializers: double dayCount = 0; bool tradedToday = false; int quantity = 0; decimal price = 0; decimal tolerance = 0m; //0.1% safety margin in prices to avoid bouncing. private string _symbol = Futures.Indices.NASDAQ100EMini; private DateTime _previous; decimal ema = 0; //Set up the EMA Class: private SimpleMovingAverage _fast; private SimpleMovingAverage _slow; //Initialize the data aND resolution you require for your strategy: public override void Initialize() { SetStartDate(2021, 3, 1); SetEndDate(2021, 3, 16); SetCash(10000); AddFuture(Futures.Indices.NASDAQ100EMini); // request ND data with minute resolution AddSecurity(SecurityType.Equity, Futures.Indices.NASDAQ100EMini, Resolution.Minute); // create a 50 day exponential moving average _fast = SMA(Futures.Indices.NASDAQ100EMini, 72, Resolution.Minute); // create a 200 day exponential moving average _slow = SMA(Futures.Indices.NASDAQ100EMini, 89, Resolution.Minute); // AddSecurity(SecurityType.Equity, "ND", resolution: Resolution.Minute); AddSecurity(SecurityType.Equity, "SPY", Resolution.Daily); } //HaNDle TradeBar Events: a TradeBar occurs on every time-interval public void OnData(TradeBars data) { if (!_slow.IsReady) return; if (_previous.Date == Time.Date) return; var holdings = Portfolio[_symbol].Quantity; var profitloss = Portfolio[_symbol].UnrealizedProfit; // we only want to go long if we're currently short or flat // if the fast is greater than the slow, we'll go long if (Portfolio.TotalPortfolioValue > _fast ) { Log("BUY >> " + Securities[_symbol].Price); SetHoldings(_symbol, 1.0); //stoploss var close = Securities[_symbol].Close; var stopMarketTicket = StopMarketOrder(_symbol, 10, close * 0.99m); } Plot(_symbol, "Price", data[_symbol].Price); // easily plot iNDicators, the series name will be the name of the iNDicator Plot(_symbol, _fast, _slow); //Plot("Ribbon", _ribbon); if (profitloss <= -2000) { //Log("SELL >> " + Securities[_symbol].Price); //SetHoldings(_symbol, -1.0); Liquidate(_symbol); } _previous = Time; } } }