| Overall Statistics |
|
Total Trades 6 Average Win 2.48% Average Loss -2.01% Compounding Annual Return -55.631% Drawdown 3.900% Expectancy -0.255 Net Profit -1.598% Sharpe Ratio -5.612 Loss Rate 67% Win Rate 33% Profit-Loss Ratio 1.23 Alpha -4.027 Beta 291.851 Annual Standard Deviation 0.09 Annual Variance 0.008 Information Ratio -5.767 Tracking Error 0.089 Treynor Ratio -0.002 Total Fees $0.00 |
// The Goal of this strategy is simply to learn the mechanics of QuantConnect
// price targets, and limit orders.
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;
namespace QuantConnect.Algorithm.CSharp
{
public class LearningLimits : QCAlgorithm
{
decimal limitPct = 0.99999m;
bool OrderSubmitted = false;
bool ExitOrderSubmitted = false;
bool StopOrderSubmitted = false;
string ticker = "BTCUSD";
decimal ProfitPct = .05m;
decimal LossPct = -.02m;
OrderTicket StoplimitOrderTicket; // The debug says these are not being used in the strategy.
OrderTicket limitOrderTicket; // The debug says these are not being used in the strategy.
OrderTicket StoplosslimitOrderTicket; // The debug says these are not being used in the strategy.
public override void Initialize()
{
SetStartDate(2017,12,01); // Set Start Date
SetEndDate(2018,02,15); // Set End Date
SetCash(22000); // Set Strategy Cash
AddCrypto(ticker, Resolution.Minute);
}
public override void OnData(Slice data)
{
if (!Portfolio.Invested && limitOrderTicket == null)
{
decimal LimitPrice = Decimal.Multiply(Securities[ticker].Price, limitPct);
decimal LimitPrice2 = decimal.Round(LimitPrice, 2);
OrderTicket limitOrderTicket = LimitOrder(ticker, 1, LimitPrice2);
Log($"We set our Limit Order at: {LimitPrice2} while the price is: {Securities[ticker].Price}");
}
if (Portfolio.Invested && Portfolio[ticker].UnrealizedProfitPercent > ProfitPct && StoplimitOrderTicket == null)
{
decimal LockedPrice = Portfolio[ticker].Price;
decimal ExitLimitPrice = Decimal.Multiply(LockedPrice,.99999m);
OrderTicket StoplimitOrderTicket = StopLimitOrder(ticker, -1, LockedPrice, ExitLimitPrice);
Log($"Profit - Limit Order Trigger: {LockedPrice} & Limit Order Price at: {ExitLimitPrice}");
}
if (Portfolio.Invested && Portfolio[ticker].UnrealizedProfitPercent < LossPct && StoplosslimitOrderTicket == null)
{
decimal LossLockedPrice = Portfolio[ticker].Price;
decimal LossLockedLimit = Portfolio[ticker].Price + Decimal.Multiply(LossPct, Portfolio[ticker].Price);
OrderTicket StoplosslimitOrderTicket = StopLimitOrder(ticker, -1, LossLockedPrice, LossLockedLimit);
Log($"STOP LOSS trigger at: {LossLockedPrice} with Loss Limit price at: {LossLockedLimit}");
}
}
}
}