MySQL & Ninja - NinjaTrader Programming | futures io social day trading
futures io futures trading


MySQL & Ninja
Updated: Views / Replies:4,314 / 18
Created: by dsraider 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

Reply
 1  
 
Thread Tools Search this Thread
 

MySQL & Ninja

  #1 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

MySQL & Ninja

Hey All,

I've written code so that one of my indicators can write directly to MySQL. The following works fine with a simple Windows Form I created but prints

"Error on calling 'OnBarUpdate' method for indicator '[indicator]' on bar 0: AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only."

in my output window when attempting to use with Ninja. I've been through this, and other, forums and can't find the answer.

 
Code
                            
//create a MySQL connection with a query string 
                    
MySqlConnection connection = new MySqlConnection("Server=server;Database=database;Port=port;Uid=userid;Password=password"); 

                    
//create a MySQL insert command with a query string 
                    
string myInsertQuery String.Format ("INSERT INTO table (column1, column2) values ('value1', 'value2')"); 
                    
MySqlCommand command = new MySqlCommand(myInsertQuery); 

                    
command.Connection connection
                    
connection.Open(); 

                    
//insert info 
                    
command.ExecuteNonQuery(); 
                 
                    
//close the connection 
                    
connection.Close(); 
Thanks,
DS

Reply With Quote
 
  #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)
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,238 since Jun 2009
Thanks: 29,350 given, 83,220 received


Sorry I don't have specific advise on the error. But I played with mysql db collection from Ninja a few years ago, here are some tips based on what I remember:

1) Don't create/destroy the connection OnBarUpdate. Instead just open it once, and close it once.

2) Don't write (INSERT) on every OnBarUpdate or OnMarketData. Instead use some sort of array or collection and write every 'x' ticks or every 'x' seconds. If you are timestamping, you can generate the timestamp within the collection or array so that when written it will retain the original timestamp.

I was able to record a dozen or more instruments at the tick level doing this, using a remote mysql server on my local network.

I have since deleted the code (by accident) so can't post, sorry.

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
The following user says Thank You to Big Mike for this post:
 
  #4 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

Interesting, Mike. Will give these tips a whirl.

Thanks.

Reply With Quote
 
  #5 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

Afraid moving things around resulted in:

Error on calling 'OnStartUp' method for indicator '[indicator]': AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only. and

Error on calling 'OnTermination' method for indicator '[indicator]': AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only.

Oh Ninja. Why must you be so cruel...?

Reply With Quote
 
  #6 (permalink)
Elite Member
Portland, OR
 
Futures Experience: Intermediate
Platform: Sierra Chart
Favorite Futures: ES
 
Posts: 269 since Jan 2011
Thanks: 326 given, 179 received

This thread should help in this space.

https://futures.io/matlab-r-type/7880-how-connect-ninjatrader7-mysql-r-2-12-a.html#post91701

I am also looking for very similar but trying to use sqlserver ( or sql CE) with an intention of using certain other plug-ins in the future. Have to see how it goes.

dsraider - if you can find a solution using mySQL - can you post the result as well?

Thanks.

Reply With Quote
The following 3 users say Thank You to ejtrader for this post:
 
  #7 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received

FIXED!!

I have absolutely no idea whatsoever why this worked but all I had to do was remove the System.Data.dll reference to .NET 4.0 and replace with with the same one from 2.0.

I am now happily writing to MySQL. Hope this helps anyone who's going through the same thing.

Mike, will still gladly take your advice on where to put what. I hadn't even thought of that so thanks again.

DS

Reply With Quote
The following 2 users say Thank You to dsraider for this post:
 
  #8 (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,238 since Jun 2009
Thanks: 29,350 given, 83,220 received

Glad to hear it. I was using NT 6.5 and it was about 3 years ago, using 5 year old hardware, so I am sure you can record a 100+ tick level instruments using an efficient method.

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
 
  #9 (permalink)
Elite Member
Portland, OR
 
Futures Experience: Intermediate
Platform: Sierra Chart
Favorite Futures: ES
 
Posts: 269 since Jan 2011
Thanks: 326 given, 179 received

dsraider - Very Nice. Would you please post the full sample code if possible?

I tried the other thread but some reason the data is not getting populated in mySQL database - don't see any errors but no data gets populated.

Wanted to replicate and see what you did.

thanks.

Reply With Quote
 
  #10 (permalink)
Trading for Fun
New York, NY
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Amp Futures/Zen-Fire
Favorite Futures: ES
 
Posts: 142 since Dec 2009
Thanks: 41 given, 83 received


Hey EJ,

As you've probably read, I'm going to be moving things around but this got me writing to MySQL through OnBarUpdate():

 
Code
                            
//create a MySQL connection with a query string

            
MySqlConnection connection = new MySqlConnection("Server=server;Database=database;Port=port;Uid=userid;Password=password");

            
//create a MySQL insert command with a query string
            
string myInsertQuery String.Format ("INSERT INTO tablename (column1, column2) values ({0}, {1})"value1value2);
            
MySqlCommand command = new MySqlCommand(myInsertQuery);

            
command.Connection connection;
            
connection.Open();

            
//insert info
            
command.ExecuteNonQuery();
           
            
//close the connection
            
connection.Close(); 
One thing worth noting is that my table has an auto-increment column, column 1, but I did NOT use that in this code. "column1" up above is the first variable I'm looking to save. I ignored AI completely and it worked perfectly.

I'm shutting down for the night but if you have any issues, please note any error messages or output window statements. I came across many during this journey and they might ring a bell for me.

Good luck!
DS

Reply With Quote
The following 5 users say Thank You to dsraider for this post:

Reply



futures io > > > > > MySQL & Ninja

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
ninja & AutoHotKey for order entrys bobarian NinjaTrader 55 April 6th, 2016 03:59 PM
GomRecorder with MySQL backend Big Mike The Elite Circle 25 October 14th, 2012 05:46 PM
Ninja T&S Trades Above and Below the Market Trafford Traders Hideout 3 January 6th, 2011 05:58 PM
My 2 cents in mysql database iwannatoscript NinjaTrader Programming 5 March 7th, 2010 09:56 AM
mysql db writer tortexal NinjaTrader Programming 2 November 27th, 2009 11:59 AM


All times are GMT -4. The time now is 06:06 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-12 in 0.12 seconds with 20 queries on phoenix via your IP 54.167.44.32