NexusFi: Find Your Edge


Home Menu

 





Import quotes from Metatrader to NinjaTrader


Discussion in NinjaTrader

Updated
    1. trending_up 3,387 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Import quotes from Metatrader to NinjaTrader

  #1 (permalink)
ntr123
San Francisco, CA
 
Posts: 4 since Dec 2010
Thanks Given: 2
Thanks Received: 1

There is a performance problem, then converting large intraday MetaTrader CSV file to NinjaTrader txt file format.
So, I wrote a small console program, that solve it.
May be it will be useful.

In Attachment
EXE_Mt4ToNt7QuotesConverter.zip - Compiled program
SOURCE_Mt4ToNt7QuotesConverter.zip - Solution for Visual Studio 2010

Usage: 1st argument - path to csv file from MetaTrader
2nd argument - path to txt file for NinjaTrader
Example: Mt4ToNt7QuotesConverter.exe EURUSD1.csv $EURUSD_MT.txt


Sorry for my English

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
Futures True Range Report
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Build trailing stop for micro index(s)
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #3 (permalink)
 
LukeGeniol's Avatar
 LukeGeniol 
Italy (IT) Italy
 
Experience: Advanced
Platform: ATAS, R|Trader, NT8
Broker: Rithmic
Trading: CL, Brent, GC, TF
Frequency: Daily
Duration: Minutes
Posts: 1,499 since Apr 2010
Thanks Given: 408
Thanks Received: 985


I'm sorry, but your zip folders contain a lot of exe files, this could be malicious, so I removed them.

Take your Pips, go out and Live.
Luke.
Reply With Quote
  #4 (permalink)
ntr123
San Francisco, CA
 
Posts: 4 since Dec 2010
Thanks Given: 2
Thanks Received: 1

Ok, there is a code:


 
Code
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Mt4ToNt7QuotesConverter
{
    class Mt4ToNt7QuotesConverter
    {
        static void Main(string[] args)
        {
            string PathMT;
            string PathNT;
            string LineMT;
            string LineNt;
            int ProcessedLines = 0;

            // Test if input arguments
            if (args.Length != 2)
            {
                Console.WriteLine("Please enter arguments");
                Console.WriteLine("Usage: 1st argument - path to csv file from MetaTrader");
                Console.WriteLine("       2nd argument - path to txt file for NinjaTrader");
                Console.WriteLine(@"Example: Mt4ToNt7QuotesConverter.exe c:\temp\EURUSD1.csv c:\temp\$EURUSD_MT.txt");
                Console.ReadLine();
                return;
            }

            PathMT = args[0];
            PathNT = args[1];
            
            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader(PathMT)) 
                {
                    // Create an instance of StreamWriter to write a file.
                    // The using statement also closes the StreamWriter.
                    using (StreamWriter sw = new StreamWriter(PathNT))
                    {
                        // Read lines from the file until the end of the file is reached.
                        while ((LineMT = sr.ReadLine()) != null)
                        {
                            ProcessedLines += 1;
                            LineNt = LineMT.Substring(0, 4) + LineMT.Substring(5, 2) + LineMT.Substring(8, 2)
                                        + " " + LineMT.Substring(11, 2) + LineMT.Substring(14, 2) + "00" + ";"
                                        + LineMT.Substring(17);
                            //Write to file
                            sw.WriteLine(LineNt);
                            if (ProcessedLines % 1000 == 0)
                            {
                                Console.WriteLine("Processed: " + ProcessedLines.ToString() + " lines");
                            }
                        }
                    }
                }
            }
            catch (Exception e) 
            {
                // Let the user know what went wrong.
                Console.WriteLine("Error:");
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("Written: " + ProcessedLines.ToString() + " lines");
            Console.WriteLine("Finished!");
            Console.ReadLine();
        }
    }
}

Reply With Quote
Thanked by:




Last Updated on December 15, 2010


© 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