Back

Candlestick examples?

Hi everyone, I was wondering if there were any examples I could look that that use candlestick patterns ? I did a search but didn't find the basic example I was looking for.

Update Backtest








@Jared,

Would you please show me the code how to make it happen. Thanks in advance.

0

How should I adjust the following formula for 5-min Period?

public new TimeSpan Period
{
get { return QuantConnect.Time.OneDay; }
}

 

0

QuantConnect.Time Helper has the following "aliases":

QuantConnect.Time.OneDay = TimeSpan.FromDays(1);
QuantConnect.Time.OneHour = TimeSpan.FromHours(1);
QuantConnect.Time.OneMinute = TimeSpan.FromMinutes(1);
QuantConnect.Time.OneSecond = TimeSpan.FromSeconds(1);
QuantConnect.Time.OneMillisecond = TimeSpan.FromMilliseconds(1);

For other periods, we need to rely on TimeSpan.From* functions.

In this particular case, please adjust it with:

public new TimeSpan Period
{
get { return TimeSpan.FromMinutes(5); }
}

 

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.


@Alexandre,

Thanks for your advice. However, the time is still reported by 1-min off: e.g. 11:16 instead of 11:15.

0


public override DateTime EndTime
{
get { return Time + TimeSpan.FromMinutes(5); }
}

The default resolution length is 1 minute which makes it appear 1 minute past the start time (which is infact looking into the future since your bars are 5 minutes long). If you set your bar length to 5 minutes (like above) it'll appear on the 5 minute boundary.

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, you got a different result, because you removed the part we override EndTime. The complete solution would be:

public override DateTime EndTime
{
get { return Time + Period; }
set { Time = value - Period; }
}

public new TimeSpan Period
{
get { return TimeSpam.FromMinutes(5); }
}

Since Jared's solution is 5 lines shorter, we can considered it better. 

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.


Jared and Alexandre,

Thank you both for your suggestions. Both codes brought the time of events to the end of the bar. However, the time that 'Logs' and 'Trades' after Backtest show is 5 minutes later than the actual event. For example, by looking at the chart, 1st Bearish Closing Marubozu ends at 10:55, whereas the Logs record it at 11:00. Also the 'Trades' show that its price was 1988.50 USD at 11:00; but if you look at the actual records (see the link to Dropbox in GetSource), the price 1988.50 corresponds to Close at 10:55.

Basically, the candlestick pattern and the trade in reality occur at 10:55, but the records (Logs & Trades) show 11:00. Similar situation happens with the rest of patterns.

How can we fix this situation? Thanks in advance

0


That is the intended behaviour; the bars close on the end time (i.e. start + period).

20160104 10.55 ...$1988.50 + 5 minute period bar means the bar is available (closing) at 10.59.9999 and appearing in your algorithm at 11am.

If the bar was available at 10.55 you'd see into the future (as the closing price is at 10.59.99999)

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.


Jared,

Thanks for your response. Still, there is some confusion. But I am beginning to understand the problem, possibly. When I downloaded my data, I set the time of candle correspond to Close. So in my data 10:55 is the bar's close. In your case, probably, the time corresponds to the beginning of the candle.

0

Update Backtest





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.


Loading...

This discussion is closed