Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

building links between mysql and ninjatrader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    building links between mysql and ninjatrader

    Hello
    I am facing issue in exporting data from ninja trader using text files.
    I have then decided to implement a direct link ninja to Mysql

    I am using a script I have found in bigmike's forum but i am facing issue probably related to system.data or MySql.Data.MySqlClient. class installation.

    I am adding them as references (right clic on the script to open the Reference form)
    System.data, i found it on my computer in Windows/NT framework/ version ...

    MysqlClient, i downloaded it from oracle and place it in Ninja/bin/custom

    I have the following error message
    Error on calling 'OnTermination' method for strategy 'LNMysql/97c3d2ee041e42f9aea17ed6d9046c19': Les gestionnaires AssemblyResolveEvent ne peuvent pas retourner des assemblys chargés pour la réflexion seulement.

    I must admit it is not totally clear for me !!!

    If someone can help, I would appreciate.

    Lionel

    XXXXXXXXXXX Script

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;

    // Ajout Lionel
    using System.Collections;
    using System.Linq;

    using MySql.Data.MySqlClient;
    using System.Data;
    // Add this to the declarations. It allows for the use of ArrayLists.

    using System.Collections.Generic;
    using System.Reflection;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// mise à jours base my SQL
    /// </summary>
    [Description("mise à jours base my SQL")]
    public class LNMysql : Strategy
    {
    #region Variables
    public ArrayList PositionVector = new ArrayList();

    private int fast = 10;
    private int slow = 25;


    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    SMA(Fast).Plots[0].Pen.Color = Color.Orange;
    SMA(Slow).Plots[0].Pen.Color = Color.Green;

    Add(SMA(Fast));
    Add(SMA(Slow));

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    if (CrossAbove(SMA(Fast), SMA(Slow), 1))
    EnterLong();
    else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
    EnterShort();

    PositionVector.Add(Close[0].ToString());
    }
    protected override void OnTermination()
    {



    string[] Array2 = (string[])PositionVector.ToArray(typeof(string));

    string delimited = string.Join(",", Array2);

    //Debug
    //Print(delimited.ToString());


    MySql.Data.MySqlClient.MySqlConnection conn;
    MySql.Data.MySqlClient.MySqlCommand cmd;
    cmd = new MySql.Data.MySqlClient.MySqlCommand();
    string myConnectionString;
    myConnectionString = "server=localhost;uid=root;" +
    "pwd=xxxx;database=bourse";
    string SQL;


    conn = new MySql.Data.MySqlClient.MySqlConnection();
    conn.ConnectionString = myConnectionString;
    conn.Open();


    SQL = "INSERT INTO closes (close) VALUES (@delimited)";
    cmd.Connection = conn;
    cmd.CommandText = SQL;
    cmd.Parameters.AddWithValue("@delimited", delimited);
    cmd.ExecuteNonQuery();


    conn.Close();
    Last edited by Lionel92; 06-18-2013, 05:14 AM.

    #2
    Lionel, which version of the referenced assemblies are you using here? Please ensure those would be taken at max from the 3.5 version of the framework - http://www.ninjatrader.com/support/f...ad.php?t=47205
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hello

      Many thanks for this prompt reply.

      This issue is that in windows/Microsoft.det/assembly although they are folders for version 3.5 I can't find system.data in version 3.5 (only 4.0)

      I try to download dot.net and install it but nothing happened even in admin mode.
      i have been into the windows set up panel were i found DOT.NET 3.5 and activate evrything again no change

      I am on windows 8. I don't know if it is the reason.

      Lionel

      Comment


        #4
        Now that you've enabled .NET 3.5, are you able to locate the System.Data that was targeted for that version? This would be in the Windows/NT framework/ version you originally pointed to. It's likely you're referring the .NET 4.0 version which would not be supported in NT7
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hello

          Many thanks for your help as always (fast, efficient and cristal clear).

          Although i have activated Dotnet framework 3.5 in windows setup panel i could'nt find the system.data.Dll in version 3.5.

          I have referenced in the script the version 2.0 and It's working, so that's fair enough

          Many thanks again

          Lionel

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Tim-c, Today, 02:34 PM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by idangre, 12-08-2016, 11:37 AM
          11 responses
          1,282 views
          0 likes
          Last Post gkadokg
          by gkadokg
           
          Started by Uregon, Today, 01:59 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by SoCalFuturesFX, 11-06-2023, 11:08 AM
          2 responses
          201 views
          0 likes
          Last Post Lavallmc  
          Started by cre8able, Today, 01:35 PM
          2 responses
          6 views
          0 likes
          Last Post cre8able  
          Working...
          X