Back

Complex Indicators on 15 minute Time frame

I've thrown together an example algorithm that shows how to define indicators on any time frame using a consolidator. I also show how you can combine multiple indicators into more complex things like ratios and even indicators of indicators.

Let me know what you guys think!
Update Backtest






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.



A lot of things to learn from few lines of code - excellent example!
Thanks!
Nik
1

Awesome, thanks for sharing. Time saver!
1

Much obliged,
please make more like these if it's no trouble.
0

@Nicholas, no worries, it's my pleasure! Let me know if there's something specific you're trying to do. This was another user's question and I figured it would help many others.

Don't hesitate to ask questions about the best way to perform some task on the platform, that's what I'm here for!
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.


@MichaelH

I have been unable to find a section of documentation / community conversation that regards using anchor charts: trading on a certain timeframe (for example 15m) while also referencing a larger timeframe (for example daily) to ensure the algorithm is trading in the "right" direction. If you could help me with this, that would be spectacular.
0

Hey @Nicholas!

Have a look at the attached algorithm. I set up some fifteen minute indicators as well as some daily indicators. This guy is pretty simple, no risk management, simple trend follower.

Let me know if you have any questions!
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.


Hello @MichaelH,

I was wondering if you could do a segment on creating custom bar data-input indicators.
For example, I have been trying to find a way to create an ExponentialMovingAverage of period 20 based on bar high's rather than bar closes on the 15m timeframe but to no avail.
0

Try this:
var emaHigh = EMA("SPY", 20, Resolution.Minute, Field.High);
1

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.


Also, try reading through this demo algorithm.
1

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.


Ah, I was plugging in BaseData.High for that method.
Thanks Michael; also appreciate the demo algo, quite useful
0

BaseData doesn't have a High property. Check out github for the BaseData source.

Also, the 'selector' is a function delegate. You can read up on delegates on MSDN. Be sure to read all the sub-articles on the page as well, they contain very useful piece of information regarding anonymous methods using lambda syntax and such.

As always, any questions feel free to ask them here (preferably in a new dedicated thread) :)
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.


@Nicholas - I've modified the algorithm to use the High property for the fast ema and the Low property for the slow ema, I hope this helps!
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.


Is there a way to run an EMA on non-conventional data such as the average of the Open and Close?
I've attempted to use the concept of casting so I could feed ((Field.Open + Field.Close)/2) into the EMA method but I have not succeeded.
0

Also, thank you for the resource on delegates, haven't encountered that term or any of its related concepts yet.
0

@Nicholas, you can specify anything for the selector. Since it is a function you can't simply do math on Field.High and Field.Close, it's like adding together to methods!

But what you can do is define your own selector that computes whatever you need!
// in initialize
RegisterIndicator(Symbol, myIndicator, myConsolidator, AveragePriceSelector);

public static decimal AveragePriceSelector(BaseData data)
{
var bar = (TradeBar)bar;
return (bar.High + bar.Low)/2;
}

Also, check out the Field.SevenBar which performs an averaging scheme on OHLC data.
3

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.


Again, much appreciated Michael
0

Michael...I tried experimenting with the algo you provided above...via trend following...but it has a runtime error: "Forward..." Any suggestions? Thanks man!!
0

Daniel, I just ran the attached algorithm with no errors. Can you post your algorithm. Thanks.
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.


What is "SPY_EMA15" as defined in the constructor that you used? Because as far as I know that first parameter is for the security and as such I was expecting "SPY" for example rather than what you used.
0

There are two ways of constructing an indicator. The primary method involves using the helper functions which will result in an 'auto-updating' indicator, such as:var ema15 = EMA("SPY", 15, Resolution.Minute);The other method involves manually instantiating the class using the constructor. This is not directly tied to any security when you construct it, but instead we can register it to receive data from other indicators or from a consolidator. In the attached project here I'm manually instantiating the indicators because I want to use them on the 15 bars produced by my consolidator object, so I use method 2: var Symbol = "SPY";
var ema = new ExponentialMovingAverage("this is an indicator name", 15);
RegisterIndicator(Symbol, ema, TimeSpan.FromMinutes(15));

So to answer your question, the "SPY_EMA15" is just the name of the indicator object and can be an arbitrary string. The indicator name is used by the helper Plot functions for the series name, so be sure to make it unique! I like to use names that indicator where the data came from ("SPY") and what I did with it ("EMA15"). Here's a link to the constructor in question. You can also navigate up a level to see all the code for all the indicators.
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.


Thank you for your response. It has shed light on the issue while raising other questions. Not wanting to give you work to do but what would be really helpful is another sample algorithm - EMA crossover. One that traded the 'SPY' on a 30 min window. Coded in such a way that the time period is coded in DRY fashion and therefore can be easily adjusted in a single place. Also coded in such a way that the EMA indicators are also operating within time period specified. And within the algo was the usual considerations for bouncing and management of portfolio in the other examples (ie. percentage capital risked per trade). Such an algo would tie all the ideas from the other sample algos on the site together in a cohesive usable fashion and could then be used a solid template for expansion. That would potentially eliminate the need for numerous follow on questions.
0

Have a read through this other forum thread. Also, try reading through the numerous example algorithms in the QCUniversity and in the github.

As always, if you get stuck, post to the forums by attaching a project with a backtest and I can help you out usually within a few hours.
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.


I'm having trouble consolidating Exponential Moving Average crossovers along with 15-minute time frames. The examples provided seem to indicate that EMA can not be used on a 15-minute time frame. Wondering if there was ever a posting as suggested by Jonathan Andre (just above), indicating the following: " Not wanting to give you work to do but what would be really helpful is another sample algorithm - EMA crossover. One that traded the 'SPY' on a 30 min window. Coded in such a way that the time period is coded in DRY fashion and therefore can be easily adjusted in a single place. Also coded in such a way that the EMA indicators are also operating within time period specified. And within the algo was the usual considerations for bouncing and management of portfolio in the other examples (ie. percentage capital risked per trade). Such an algo would tie all the ideas from the other sample algos on the site together in a cohesive usable fashion and could then be used a solid template for expansion. That would potentially eliminate the need for numerous follow on questions."
0

The algorithms I attached previously set up 15 minute indicators using the consolidator system.

Could you attach an algorithm and I can help figure out what's going on.
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.


@MichaelH Hi, I'm a rookie here, how do I modified your code to make a decision whenever the indicator takes place including after hour?  Thx

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