How to connect NinjaTrader7 --> MySQL --> R(2.12) - Matlab, R project and Python | futures io social day trading
futures io futures trading

How to connect NinjaTrader7 --> MySQL --> R(2.12)
Updated: Views / Replies:5,555 / 5
Created: by Justin300 Attachments:1

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

Thread Tools Search this Thread

How to connect NinjaTrader7 --> MySQL --> R(2.12)

  #1 (permalink)
Just starting out...
Futures Experience: Intermediate
Platform: NinjaTrader
Posts: 1 since Jul 2010
Thanks: 1 given, 1 received

How to connect NinjaTrader7 --> MySQL --> R(2.12)

Just wanted to share a short example demonstrating how to connect NinjaTrader7 --> MySQL --> R(2.12). The example is just trivial, pulling a vector of closing values from NT7 into R, but it demonstrates the power.

Assumes NT7, MySQL, MySQL Connector/Net, .Net Framework and R are installed.
I used a Windows 7 (64) base. I used NT7(32) and R(32).
Assumes “Complete” install option for MySQL (this includes the client header and library files).
I had to uninstall and then reinstall .Net Framework, MySQL Connector and NT7 for this to work.
NT7 was very fussy about referencing the assemblies to get the MySQL connection.
I used the following reference paths:
This tutorial is a huge help for setting up RMySQL:

RMySQL needs Rtools212.exe .
Download and Install (for your version of R):

Create the MySQL database:

shell> mysql -u root -p
>use testBlob;
>CREATE TABLE closes (
>DESCRIBE closes;

Configure R:
Navigate to:
C:\Program Files\R\R-2.12.0\etc
In type:

I had a hard time finding the short name for the path.
Eventually I used the small vb script found here:

Restart R.
Check that the MYSQL_HOME environment variable is set, at the R prompt type:
This returns:
Then in R:

R Script for connecting to MySQL db:

dd <- dbDriver("MySQL")

con <-dbConnect(MySQL(),user="root",password="12345",dbname="testBlob",host="localhost")


closes <- dbSendQuery(con,"SELECT close FROM `closes`")


vecTest <- as.numeric(unlist(strsplit(closes[1,],split=",")))

I hope this helps you.
Good Luck,


NinjaScript example is attached.

Attached Files
Register to download File Type: txt MACrossOverSQL.txt (3.4 KB, 258 views)

Last edited by sam028; January 26th, 2011 at 05:29 PM. Reason: spaces for http addresses removed
Reply With Quote
The following 9 users say Thank You to Justin300 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
Neubrandenburg, Germany
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
wh's Avatar
Posts: 538 since Jun 2009
Thanks: 297 given, 482 received

you can also access R from mysql (from your c# code) to send signals to analysis in r.
you do not need com/pinvoke/interop

here the simple steps:

RMySQL Package

then create some sql function where you call R and make your analysis
so you can include what you want (ann, wavelet and other signal processing stuff)

a better and solution will be postgresql (with some pl/r examples)

with R/Perl you can pull to html or back to ninja

(imo it is a better solution as encog or similar)

Causality is the relationship between an event (the cause) and a second event (the effect), where the second event is a consequence of the first.
Reply With Quote
The following 4 users say Thank You to wh for this post:
  #4 (permalink)
Elite Member
Futures Experience: Beginner
Platform: MultiCharts
Posts: 232 since Nov 2010
Thanks: 10 given, 20 received

So I just want try to do the same, what is the easy way to follow.
Please You make the easiest way.

Reply With Quote
  #5 (permalink)
Trading Apprentice
Futures Experience: Intermediate
Platform: Ninjatrader, Metatrader
Favorite Futures: EUR/USD, Currency futures
Posts: 1 since Jun 2011
Thanks: 0 given, 0 received

could somebody make an videotutorial please or better describe any steps ? bcs I get lost after few steps... thx

Reply With Quote
  #6 (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,336 since Jun 2009
Thanks: 29,450 given, 83,942 received

To accomplish this you need a good technical background. This is an advanced topic.


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.
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
The following user says Thank You to Big Mike for this post:


futures io > > > > How to connect NinjaTrader7 --> MySQL --> R(2.12)

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Wyckoff Hunting for Great Risk/Reward Ratio w/Gary Fullett

Elite only

Digging into the Details of iSystems w/Stage 5 & iSystems

Jun 5

Similar Threads
Thread Thread Starter Forum Replies Last Post
BLUELINE DELIGHT >>>Intraday Trading Strategy Guide<<< Gabriyele The Elite Circle 407 May 30th, 2013 07:29 AM
First Indicator programing, Text on graph >> Easy language / Multicharts arjfca The Elite Circle 2 September 22nd, 2010 09:05 PM
TIP : Search for free NinjaTrader Indicator on BMT ? >> How to use our searchtools ! max-td Beginners and Introductions 2 July 19th, 2010 06:16 AM
Strategy Condition Logic >> my wetware Trader.Jon NinjaTrader Programming 2 May 24th, 2010 04:17 PM
Jobs for musicians, DJs, coder, salesman >> Native Instruments Berlin + L.A. max-td Off-Topic 1 March 18th, 2010 09:43 AM

All times are GMT -4. The time now is 07:38 PM.

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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 2018-05-24 in 0.09 seconds with 20 queries on phoenix via your IP