Cointegration Indicator - Matlab, R project and Python | futures io social day trading
futures io futures trading


Cointegration Indicator
Updated: Views / Replies:6,835 / 14
Created: by kevind Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Cointegration Indicator

  #1 (permalink)
Elite Member
Seattle, WA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Interactive Brokers/IQFeed
Favorite Futures: Stocks
 
Posts: 27 since Nov 2009
Thanks: 10 given, 66 received

Cointegration Indicator

I posted a cointegration indicator ("CADF") in the Elite Downloads area. It plots the output statistic of an Augmented Dickey Fuller cointegrating regression of 2 instruments. It's a C# translation of MATLAB code developed by James P. LeSage and posted at Econometrics Toolbox for MATLAB. I used some mathematical routines from ALGLIB (ALGLIB) which are included, and wrote a lot of helper routines to accomplish the MATLAB functions. Even if you're not interested in cointegration, you might find it useful as an example programming with quantitative methods for NinjaTrader.

I haven't seen a cointegration indicator for a trading platform posted publicly before, only MATLAB or R code. So I thought I would be the first. I posted it for futures.io (formerly BMT) Elite members only, please don't share or distribute.

This version is made using primarily static routines, which call "new" frequently. This works fine for indicators or normal strategies, but it can fall apart by filling up memory if you try to run an extensive optimization on it. The alternative is to implement the internal routines as classes which can be instantiated once and pre-allocate their storage once at the start. I've done that for strategies, and it helps optimizer performance quite a bit, but ALGLIB uses "new" in some places so I haven't been able to get rid of all uses of "new".

I also posted the latest ALGLIB 3.5.0 library, packaged as a NinjaTrader "indicator", in the MATLAB downloads area. But it's not needed for CADF, the required ALGLIB routines are included.

Reply With Quote
The following 11 users say Thank You to kevind for this post:
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Wrocław, Poland
 
Futures Experience: Intermediate
Platform: NinjaTrader, Racket
Favorite Futures: Ockham's razor
 
gregid's Avatar
 
Posts: 651 since Aug 2009
Thanks: 321 given, 605 received


For a brief introduction of cointegration:
Quantitative Trading: Cointegration is not the same as correlation

Thanks kevin for the contribution!

Reply With Quote
The following 2 users say Thank You to gregid for this post:
 
  #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,354 given, 83,237 received


gregid View Post
For a brief introduction of cointegration:
Quantitative Trading: Cointegration is not the same as correlation

Thanks kevin for the contribution!

Thanks, as a math-stupid person, I was wondering about this.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #5 (permalink)
Elite Member
SE-Asia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Amp
Favorite Futures: ES
 
Posts: 141 since Jun 2009
Thanks: 57 given, 114 received


kevind View Post
I posted a cointegration indicator ("CADF") in the Elite Downloads area. It plots the output statistic of an Augmented Dickey Fuller cointegrating regression of 2 instruments. It's a C# translation of MATLAB code developed by James P. LeSage and posted at Econometrics Toolbox for MATLAB. I used some mathematical routines from ALGLIB (ALGLIB) which are included, and wrote a lot of helper routines to accomplish the MATLAB functions. Even if you're not interested in cointegration, you might find it useful as an example programming with quantitative methods for NinjaTrader.

I haven't seen a cointegration indicator for a trading platform posted publicly before, only MATLAB or R code. So I thought I would be the first. I posted it for futures.io (formerly BMT) Elite members only, please don't share or distribute.

This version is made using primarily static routines, which call "new" frequently. This works fine for indicators or normal strategies, but it can fall apart by filling up memory if you try to run an extensive optimization on it. The alternative is to implement the internal routines as classes which can be instantiated once and pre-allocate their storage once at the start. I've done that for strategies, and it helps optimizer performance quite a bit, but ALGLIB uses "new" in some places so I haven't been able to get rid of all uses of "new".

I also posted the latest ALGLIB 3.5.0 library, packaged as a NinjaTrader "indicator", in the MATLAB downloads area. But it's not needed for CADF, the required ALGLIB routines are included.

Thanks for your contribution, I never been exposed to this trade style and i am a completely ignorant about this, but for sure its an interest theme and style. It will be good if you post some example on how to use this approach.

Reply With Quote
 
  #6 (permalink)
Elite Member
Germany
 
Futures Experience: Beginner
Platform: NinjaTrader
Favorite Futures: DAX, EUR/USD
 
Posts: 18 since Aug 2010
Thanks: 16 given, 2 received

kevind, about some examples I would be pleased too.
I experimented with this approach in Matlab before a while and tried to translate this to C# but failed.
The same problem with R.
Thank you for your code I will take a look.

Reply With Quote
The following user says Thank You to bascher for this post:
 
  #7 (permalink)
Elite Member
Reno, Nevada
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: ZN, ZB, FDAX
 
phantomtrader's Avatar
 
Posts: 158 since May 2011
Thanks: 13 given, 226 received

Hi - I'm not getting a plot on Ninja. I've tested a couple of pairs ES/TF, ES,6E daily charts, max data. Are there any specific parameters which need to be entered? Thanks.

Reply With Quote
 
  #8 (permalink)
Elite Member
Reno, Nevada
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: ZN, ZB, FDAX
 
phantomtrader's Avatar
 
Posts: 158 since May 2011
Thanks: 13 given, 226 received

I think I may have found the answer - the pair has to have the same underlying price structure i.e. dollars for stocks. If that's the case, is there any way to use it for futures? thanks.

Reply With Quote
 
  #9 (permalink)
Elite Member
Seattle, WA
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Interactive Brokers/IQFeed
Favorite Futures: Stocks
 
Posts: 27 since Nov 2009
Thanks: 10 given, 66 received

It should work fine with futures, or futures paired with stocks. You need to enter a symbol in the proper form, the symbol must exist in the instrument manager, and the data has to exist for the period specified. Cointegration is typically tested on daily data over longer periods, so continuous futures data is probably your best bet.

Proper symbol form is i.e. "ES ##-##" for continuous futures, or "ES 06-12" for a specific contract.

Reply With Quote
 
  #10 (permalink)
Elite Member
Reno, Nevada
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: ZN, ZB, FDAX
 
phantomtrader's Avatar
 
Posts: 158 since May 2011
Thanks: 13 given, 226 received



kevind View Post
It should work fine with futures, or futures paired with stocks. You need to enter a symbol in the proper form, the symbol must exist in the instrument manager, and the data has to exist for the period specified. Cointegration is typically tested on daily data over longer periods, so continuous futures data is probably your best bet.

Proper symbol form is i.e. "ES ##-##" for continuous futures, or "ES 06-12" for a specific contract.

Thanks for the reply. I have the ES and 6E loaded on a Ninja chart for max days daily chart. Also tried 1440 minute chart because I know some indicators only report on 1440 minute charts on Ninja. Still nothing with the CADF. The parameters list "Symbol 2", which I assume is the second symbol, Nlag ste to 1, P set to 0, and Period set to 250. Should any of these be adjusted? Thanks.

Reply With Quote

Reply



futures io > > > > Cointegration Indicator

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Constant Line Indicator to Another Indicator ceramictilepro NinjaTrader Programming 9 September 22nd, 2011 11:43 PM


All times are GMT -4. The time now is 03:04 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-16 in 0.12 seconds with 19 queries on phoenix via your IP 54.163.209.109