NexusFi: Find Your Edge


Home Menu

 





MySQL & Ninja


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one dsraider with 8 posts (8 thanks)
    2. looks_two ejtrader with 5 posts (5 thanks)
    3. looks_3 Big Mike with 4 posts (1 thanks)
    4. looks_4 shodson with 1 posts (0 thanks)
    1. trending_up 9,010 views
    2. thumb_up 14 thanks given
    3. group 5 followers
    1. forum 18 posts
    2. attach_file 1 attachments




 
Search this Thread

MySQL & Ninja

  #11 (permalink)
 ejtrader 
Portland, OR
 
Experience: Intermediate
Platform: Sierra Chart
Trading: ES
Posts: 269 since Jan 2011
Thanks Given: 327
Thanks Received: 180

Thanks dsraider. Appreciate it. Checking out.

Mike - FYI:

your code is located in this thread:

NinjaTrader Support Forum - View Single Post - mysql database code sample

full thread:
mysql database code sample - Page 3 - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

nexusfi.com (formerly BMT) link:

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
23 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #12 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,207
Thanks Received: 101,599


ejtrader View Post
Thanks dsraider. Appreciate it. Checking out.

Mike - FYI:

your code is located in this thread:

NinjaTrader Support Forum - View Single Post - mysql database code sample

full thread:
mysql database code sample - Page 3 - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

nexusfi.com (formerly BMT) link:

Thanks for digging. Unfortunately that was my first round of code, not with the enhancements I made later and then lost somehow.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #13 (permalink)
 ejtrader 
Portland, OR
 
Experience: Intermediate
Platform: Sierra Chart
Trading: ES
Posts: 269 since Jan 2011
Thanks Given: 327
Thanks Received: 180


dsraider - Just wanted to let you know - I am able to write the data as well.

In the end it turned out to be the System.Data.dll - reference ( it was pointed to net 4.0 version and later changed to 2.0).

Should be able to experiment further going forward as this was the initial hurdle

PS: I think this should work fine with net 3.5 version of this dll as well - but would have to experiment further.

Thanks.

Attached Thumbnails
Click image for larger version

Name:	NT_References.jpg
Views:	129
Size:	23.6 KB
ID:	60971  
Reply With Quote
  #14 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

EJ - Awesome!

Thanks for letting me know. My 3.5 dll wasn't readily available (read I was tired and frustrated and couldn't find it at first glance) so I went with 2.0, wrote to MySQL and promptly ran away. Would definitely be interested to hear if 3.5 works out better for you.

P.S. Mike, I didn't realize you'd written the my_sql_db code from which I based mine so thanks yet again.

Reply With Quote
  #15 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

EJ, Mike et al,

Wondering if anyone has successfully separated code in the following way:

OnStartUp() - open connection

OnBarUpdate() - execute insert command (though will change later per Mike's suggestion)

OnTermination() close connection

While Print statements are telling me each of these are being called, and everything compiles properly, it's simply not working.

Placing connection.Open() in OnStartUp() gives me: Error on calling 'OnBarUpdate' method for indicator '[indicator]' on bar 0: Connection must be valid and open.

Placing connection.Close() in OnTermination gives me a message about pooling, which I've found out means I've opened too many connections WITHOUT closing any (this occurs when moving connection.Open() back to OnBarUpdate() with insert code).

Reply With Quote
  #16 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,440 since Jun 2009
Thanks Given: 33,207
Thanks Received: 101,599


dsraider View Post
EJ, Mike et al,

Wondering if anyone has successfully separated code in the following way:

NT7 was before my time with this So I can't comment much, except to say just add more debug print statements to see what is going on and track down the bad code.

Also check your MySQL settings, make sure the timeout is sufficiently high to not force close the connection on the server side between inserts if you choose to keep the connection open on the client (which would be my choice).

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #17 (permalink)
 ejtrader 
Portland, OR
 
Experience: Intermediate
Platform: Sierra Chart
Trading: ES
Posts: 269 since Jan 2011
Thanks Given: 327
Thanks Received: 180

There is an excellent thread started by GOMI ( Kudos to him!! ) - which has everything that is needed to get this done correct.

Here is the thread.


Reply With Quote
Thanked by:
  #18 (permalink)
 
shodson's Avatar
 shodson 
OC, California, USA
Quantoholic
 
Experience: Advanced
Platform: IB/TWS, NinjaTrader, ToS
Broker: IB, ToS, Kinetick
Trading: stocks, options, futures, VIX
Posts: 1,976 since Jun 2009
Thanks Given: 533
Thanks Received: 3,709


dsraider View Post
EJ, Mike et al,

Wondering if anyone has successfully separated code in the following way:

OnStartUp() - open connection

OnBarUpdate() - execute insert command (though will change later per Mike's suggestion)

OnTermination() close connection

While Print statements are telling me each of these are being called, and everything compiles properly, it's simply not working.

Placing connection.Open() in OnStartUp() gives me: Error on calling 'OnBarUpdate' method for indicator '[indicator]' on bar 0: Connection must be valid and open.

Placing connection.Close() in OnTermination gives me a message about pooling, which I've found out means I've opened too many connections WITHOUT closing any (this occurs when moving connection.Open() back to OnBarUpdate() with insert code).

Since you haven't included any code I can only offer a couple of thoughts

1) make sure your connection object has class scope, and is not a variable declared within your OnStartUp() method.

2) I would initialize and open the connection in OnBarUpdate() but only if the connection object is null. This helps prevent issues assuming that OnStartUp() will only be called once and only once at the beginning of the strategy's execution.

I have not done this with MySql, but I have done it with MS SQL, which you can download for free, and .NET is much more friendly to SQL Server out of the box. It's possible you need a .NET 4-friendly MySql driver, or use the older driver as some have done.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #19 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

Apologies for the delayed response. They're trying to kill me in the real world...

Thank you to everyone for your suggestions. Unfortunately, nothing I've tried has worked. shodson, I've actually including my current working code early on in this thread. If you have time to check it out, I'd definitely appreciate it. I'm starting to think it might be an NT issue but this is "Unsupported."

DS

Reply With Quote




Last Updated on February 2, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts