LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
I am trying to determine the length of the candle and its shadows and also the shadow as percentage of entire length. I am aware of CandleSettingType and CandleRangeType Enumerations, but 1st - not sure how to code them; and 2nd - I want to be able to find out certain info, such as: Upper shadow - no more than 15% of entire length and others like this.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Jared Broad
,
Please attach a post / contribution of what you have attempted Boris. Discussions must meet minimum quality standards which show you've made an effort to achieve your goals. Communities work best when the members contribute - posts just asking for others to code your algorithm for you will be removed.
0
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Boris Sachakov
1.8k
,
My appologies.
Here's my work so far. It looks very simplistic and I will continue practicing to learn to be able to use the methods I mentioned above.
I think Bactesting is down. So I am not able to attach it.
0
Boris Sachakov
1.8k
,
Here is my project. Since Backtest is still queuing, not able to attach it the proper way. Please critique my work.
using System;
using System.Globalization;
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Indicators.CandlestickPatterns;
namespace QuantConnect.Algorithm.CSharp
{
   public class CandlestickCloseMarUppShad5minESData : QCAlgorithm
   {
       private string _symbol = "ES";
       private ClosingMarubozu _pattern5 = new ClosingMarubozu();     Â
       /// <summary>
       /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must be initialized.
       /// </summary>
       public override void Initialize()
       {
           SetStartDate(2016, 01, 04); //Set Start Date
           SetEndDate(2016, 01, 04);   //Set End Date
           SetCash(100000);            //Set Strategy Cash
           AddData<CloseMaribos>(_symbol);
           _pattern5 = CandlestickPatterns.ClosingMarubozu(_symbol);         Â
       }
       /// <summary>
       /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
       /// </summary>      Â
       public void OnData(CloseMaribos data)
       {
           if (data.Time.TimeOfDay < new TimeSpan(9, 35, 00) ||
                data.Time.TimeOfDay > new TimeSpan(12, 00, 00))
           {
               return;
           }
           else
           {
               if (_pattern5 == 1)// Bullish ClosingMarubozu
               {                  Â
                   Debug(Time + " -> found Bullish ClosingMarubozu\n" +
                       "Upper Shadow = " + (data.UpperShadow/data.HighLow * 100) + "%");            Â
               }              Â
           }
       }
   }
   public class CloseMaribos : TradeBar
   {
       public decimal UpperShadow { get; set; }
       public decimal LowerShadow { get; set; }
       public decimal HighLow { get; set; }
       public decimal RealBody { get; set; }
       /// <summary>
       /// Return the URL external source for the data: QuantConnect will download it an read it line by line automatically:
       /// </summary>
       public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
       {
           return new SubscriptionDataSource("https://www.dropbox.com/s/nybrjl87y877flp/ES%202016-01-04%20-%202016-12-19%20-%20EST.csv?dl=1", SubscriptionTransportMedium.RemoteFile);
       }
       /// <summary>
       /// Convert each line of the file above into an object.
       /// </summary>
       public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
       {
           CloseMaribos cmBar = new CloseMaribos();
           try
           {
               var data = line.Split(',');
               //Required.
               cmBar.Symbol = "ES";
               cmBar.Time = DateTime.ParseExact(data[0] + data[1], "yyyyMMddhhmmss", CultureInfo.InvariantCulture);
               //User configured / optional data on each bar:
               cmBar.Open = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
               cmBar.High = Convert.ToDecimal(data[3], CultureInfo.InvariantCulture);
               cmBar.Low = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
               cmBar.Close = Convert.ToDecimal(data[5], CultureInfo.InvariantCulture);
               cmBar.Volume = Convert.ToInt32(data[6], CultureInfo.InvariantCulture);
               //This is the value the engine uses for portfolio calculations
               cmBar.Value = cmBar.Close;
               if (cmBar.Close > cmBar.Open)
               {
                   cmBar.UpperShadow = (cmBar.High - cmBar.Close);
                   cmBar.LowerShadow = (cmBar.Open - cmBar.Low);
                   cmBar.RealBody = (cmBar.Close - cmBar.Open);
               }
               else
               {
                   cmBar.UpperShadow = (cmBar.High - cmBar.Open);
                   cmBar.LowerShadow = (cmBar.Close - cmBar.Low);
                   cmBar.RealBody = (cmBar.Open - cmBar.Close);
               }
               cmBar.HighLow = (cmBar.High - cmBar.Low);              Â
           }
           catch (Exception exception)
           {
               Console.WriteLine(exception.Message);
           }
           return cmBar;
       }
   }
}
0
Boris Sachakov
1.8k
,
Backtesting is back on. So here's my complete work so far.
At the current stage of your strategy development, you should keep your algorithm as simple as possible.
Its simpler to write 10 lines of code to compute the shadow relative length than writing a custom indicator. That is what you did. Your current solution looks very good!
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Loading...
To unlock posting to the community forums please complete at least 30% of Boot Camp. You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!