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
Is there anything built into QuantConnect (Like an indicator or something) where you could create a trendline based off two or more points and be able to see when it has been crossed by incoming data?
I am looking for something that I can use on daily charts to look for patterns like double tops, double bottoms, Three Rising Valleys, etc and be able to trigger an insight when the pattern confirms.
I am familiar with the standard oscillators I see on the indicator documentation page, but I haven't found anything where I can do programmatic trendlines, it seems like something that would be here.
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.
You can find suitable indicators built in QuantConnect and then plot them for finding patterns on daily charts. As for incoming data, if you claim a specific symbol, then the indicator based on it will be automatically updated. If not, we suggest you register the indicator for automatic updates with the RegisterIndicator() method, so that you will get the trend of indicators when new data is included.
Also, if you want to design your own indicators to find valuable patterns (double tops, double bottoms, Three Rising Valleys, etc), you can create custom indicators as stated in here.
For further information, you might find Indicators and Charting references be very helpful.
Here is an example of creating custom indicators using C#. Hope it helps!
namespace QuantConnect.Algorithm.CSharp
{
public class CustomIndicatorAlgorithm : QCAlgorithm
{
CustomSimpleMovingAverage Custom;
SimpleMovingAverage SMA;
public override void Initialize()
{
SetStartDate(2013,10,7);
SetEndDate(2013,10,11);
AddEquity("SPY", Resolution.Second);
SetCash(100000);
SMA = SMA("SPY", 60, Resolution.Minute);
Custom = new CustomSimpleMovingAverage("custom", 60);
RegisterIndicator("SPY", Custom, Resolution.Minute);
}
/// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
/// Slice object keyed by symbol containing the stock data
public override void OnData(Slice data)
{
if (Portfolio.Invested){
SetHoldings("SPY", 1);
}
if (Time.Second == 0){
Log(string.Format(" sma -> IsReady: {0}. Time: {1}. Value: {2}", SMA.IsReady, SMA.Current.Time, SMA.Current.Value));
Log(Custom.Value);
}
// Regression test: test fails with an early quit
var diff = Math.Abs(Custom.Value - SMA.Current.Value);
if (diff > 1e-25m){
Quit(string.Format("Quit: indicators difference is {0}", diff));
}
}
}
public class CustomSimpleMovingAverage : WindowIndicator<IndicatorDataPoint>
{
DateTime Time;
public decimal Value;
public bool IsReady;
public RollingWindow<decimal> RW;
public string Name;
public CustomSimpleMovingAverage(string name, int period): base(name, period){
Name = name;
Time = DateTime.MinValue;
Value = 0;
IsReady = false;
RW = new RollingWindow<decimal>(period);
}
public void Update(TradeBar input){
RW.Add(input.Close);
var count = RW.Count;
Time = input.EndTime;
Value = RW.Sum() / count;
IsReady = (count == RW.Size);
}
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.
Trendlines seem like something generic and useful enough to warrant inclusion in the standard library of indicators, I would imagine. Can be a nice base to build other chart patterns off.
Thanks for the answers so far, I think what I am hearing is that there isn't something currently in the framework that will do a trendline, I was thinking about building an indicator to do it, but I wanted to make sure I wasn't just duplicating something that was already built into the framework.
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!
You do not have enough QC Credit to send this award, get a QC Credit Pack
here.
Award Sent Successfully
Thank you for giving back to the community.
Processing...
Choose a Credit Pack
Payment Confirmation
QuantConnect Credit (QCC) can be applied to your cloud-invoices or
gifted to others in the community with Community Awards in recognition of their contributions.
Community Awards highlight the awesome work your fellow community members are doing and inspires
high quality algorithm contributions to the community. Select an option below to add
QuantConnect Credit to your account:
$5
500 Credit Points
 
$10
1,000 Credit Points
 
$18
2,000 Credit Points
10% bonus
$45
5,000 Credit Points
10% bonus
03/23XXXX XXXX XXXX 0592
We will charge your default organization credit card on file, click
here to update.