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

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python

How to connect NinjaTrader7 --> MySQL --> R(2.12)
Started:January 24th, 2011 (12:43 AM) by Justin300 Views / Replies:4,768 / 5
Last Reply:December 10th, 2011 (10:52 AM) Attachments:1

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

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

Old January 24th, 2011, 12:43 AM   #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, 229 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:

Old January 24th, 2011, 12:43 AM   #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.


Old January 26th, 2011, 03:50 PM   #3 (permalink)
Elite Member
Neubrandenburg, Germany
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
wh's Avatar
Posts: 539 since Jun 2009
Thanks: 297 given, 474 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:

Old February 10th, 2011, 07:46 AM   #4 (permalink)
Elite Member
Futures Experience: Beginner
Platform: MultiCharts
Posts: 213 since Nov 2010
Thanks: 8 given, 18 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

Old December 9th, 2011, 12:50 PM   #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

Futures Edge on FIO

What happens to the S&P 500 when a new President takes office?

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

Reply With Quote

Old December 10th, 2011, 10:52 AM   #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: 45,432 since Jun 2009
Thanks: 28,836 given, 79,558 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:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python > 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)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

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 02:23 AM.

Copyright © 2016 by 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 2016-10-23 in 0.10 seconds with 21 queries on phoenix via your IP