Get Excel Data into Ninja Trader - Traders Hideout | futures io social day trading
futures io futures trading


Get Excel Data into Ninja Trader
Updated: Views / Replies:156 / 4
Created: by LionAgainst Attachments:0

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 100,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
 
Thread Tools Search this Thread
 

Get Excel Data into Ninja Trader

  #1 (permalink)
Munich
 
 
Posts: 2 since Feb 2019
Thanks: 1 given, 0 received

Get Excel Data into Ninja Trader

Hi,
i have an oscilator in excel based on cot data that saves a value depending on the date.
My mission is to access from NinjaTrader that excel file, search for todays date and give back the value to NinjaTrader.
I have already worked it out in VisualStudio, but i am now struggling to access the excel file with the same logic. And i wonder what my problem is. I have referenced the Microsoft.Office.Interop.Excel.dll in NinjaTrader but i dont know how to test if it actually works in NinjaTrader. Currently i just try to test it by running a backtest, but unfortunately it wont run the code linked to the excel file but only the strategy based on NinjaTraders indicators.
i will enclose the code from the already working visual studio application. I welcome every help on how to translate that code into Ninja and get it working


 
Code
public class KKK : Strategy
	{
		
		Microsoft.Office.Interop.Excel.Application excelApp;
        Microsoft.Office.Interop.Excel._Workbook excelWorkBook;
        Microsoft.Office.Interop.Excel._Worksheet excelSheet;
        Microsoft.Office.Interop.Excel.Range range;
		private string excelFile = @"C:\\Users\\Felix\\Documents\\C#\\ExcelAnfang\\Mappe6.xlsx";
		private string excelSheetName = "Tabelle";
		private bool excelSheetFound = false;
		private bool excelOpen = false;
		private string fullFileName;///dkasl
        private string simpleFileName;///aklsdf
            
			
	
	
	private void OpenWorkbook(string FileName)
        {
            try
            {
                excelApp = (Microsoft.Office.Interop.Excel.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Excel.Application");
            }
            catch
            {
                excelApp = new Microsoft.Office.Interop.Excel.Application();
            }
            
            try
            {
               excelWorkBook = excelApp.Workbooks.Open(excelFile);
            }
            catch
            {
                excelWorkBook = (Microsoft.Office.Interop.Excel._Workbook) (excelApp.Workbooks.Open(excelFile,
                    false, true, Type.Missing,Type.Missing, Type.Missing, Type.Missing,Type.Missing,
                    Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing,Type.Missing));
            }
        }  
		
		private Microsoft.Office.Interop.Excel.Worksheet FindSheet(Microsoft.Office.Interop.Excel._Workbook excelWorkBook, string excelSheetName)
        {    
            foreach (Microsoft.Office.Interop.Excel.Worksheet excelSheet in excelWorkBook.Sheets)    
            {        
                if (excelSheet.Name == excelSheetName) return excelSheet;   
            }    
            return null;
        }
		
		 private void SetUpSpreadsheet()
        {
            OpenWorkbook(excelFile);
            excelSheet = (Microsoft.Office.Interop.Excel._Worksheet)FindSheet(excelWorkBook, excelSheetName);
			excelOpen = true;
            
                    

            // Set up some column colours
            
        }
		
	


public int searchExcelDate(int i)
    {
        
        
        var PCTime = DateTime.Today;
        string sDate = (excelSheet.Cells[i, 1] as Microsoft.Office.Interop.Excel.Range).Value2.ToString(); //holt Datum als String aus Zelle
        double date = double.Parse(sDate); // Double Datum der Zelle
        var excelTime = DateTime.FromOADate(date); //Excel Zeit -- Vergleich

        //Console.WriteLine(date);
        while (DateTime.Compare(excelTime, PCTime) != 0)
        {
            if ((excelSheet.Cells[i + 1, 1] as Microsoft.Office.Interop.Excel.Range).Value != null)
            {
                i++;
                sDate = (excelSheet.Cells[i, 1] as Microsoft.Office.Interop.Excel.Range).Value2.ToString();
                date = double.Parse(sDate);
                excelTime = DateTime.FromOADate(date);
            }
            else
            {
                return -1;
            }
        }
        Console.WriteLine("Datum gefunden!");
        return i;
    }

    

public double giveValueFromToday()
    {
        int d = searchExcelDate(1);
        
        if(d > 0)
        {
            double wert = double.Parse((excelSheet.Cells[d, 2] as Microsoft.Office.Interop.Excel.Range).Value.ToString());
			Console.WriteLine(wert);
            return wert;
        }
        else
        {
            Console.WriteLine("Datum nicht gefunden!");
            return -1;
        }
     }
		
	
	
           
		protected override void OnBarUpdate()
		{
			
			
			if (BarsInProgress != 0) 
				return;

			if (CurrentBars[0] < 1)
				return;
			if (CurrentBar < BarsRequiredToTrade)
				return;
			
			KKK hallo = new KKK();
	
                         if(excelOpen == false)
			{
				hallo.SetUpSpreadsheet();
			}
			cotData = hallo.gibWertVonAktuellemDatum();
			Console.WriteLine("Sieht man das?");
			System.Windows.Forms.MessageBox.Show("sieht man das?");
			
			excelApp.Visible = false;


	}
		
	
		#region Properties
       
        
        [Description("Excel File Name with full path. Information will be displayed in an Excel Spreadsheet which is included with this indicator")]
        public string ExcelFile
        {
            get { return excelFile; }
            set { excelFile = value; }
        }
        
        [Description("Excel Sheet name e.g. Sheet1, Sheet2, Sheet3. Case Sensitive")]
        public string ExcelSheetName
        {
            get { return excelSheetName; }
            set { excelSheetName = value; }
        }
        #endregion
	
	}
	}

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)
Market Wizard
Gits (Hooglede) Belgium
 
Trading Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,962 since Sep 2013
Thanks: 2,413 given, 5,545 received


you will have to add that library as an external reference
so that Ninja know how to resolve and link it

Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #4 (permalink)
Munich
 
 
Posts: 2 since Feb 2019
Thanks: 1 given, 0 received


rleplae View Post
you will have to add that library as an external reference
so that Ninja know how to resolve and link it

Ok thank you! But i dont really understand what you mean. I have referenced the Microsoft.Office.Interop.Excel.dll in NinjaTrader and moved that file in ninjatrader>bin>custom. If its what you mean? or what should i do
thank you

Reply With Quote
 
  #5 (permalink)
Bay Area California
 
Trading Experience: None
Platform: TT T4
Broker/Data: Phillip Capital
Favorite Futures: Futures
 
Posts: 753 since Nov 2011
Thanks: 696 given, 791 received

If you already successfully demonstrated the logic in visual studio, it should be pretty trivial to test it in ninjatrader. You can attach the visual studio debugger to a ninjascript strategy and hit any breakpoints you set to check that the excel workbook is being correctly bound to and retrieving your desired values.


Sent using the futures.io mobile app

.
Reply With Quote

Reply



futures io > > > Get Excel Data into Ninja Trader

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now
 

Webinar: The Seven Most Effective Trading Setups w/Peter Davies @ Jigsaw

Oct 17
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Data From ToS into Excel JTurner77 ThinkOrSwim 5 October 23rd, 2018 06:35 PM
OEC excel Add-in Update Quotes together with the Positions in Excel sinpeople Options on Futures 1 October 5th, 2017 07:55 AM
Advanced GET + Ninja Trader.Data feed gatiep Traders Hideout 3 March 8th, 2017 10:23 AM
Embed ninjatrader chart to excel - NinjaTrader to Excel Minds NinjaTrader 2 April 13th, 2016 06:01 PM
What is the best way to get Ninja Trader and Kinetick data feed (which broker)? shots fired Reviews of Brokers and Data Feeds 1 May 12th, 2015 07:10 AM


All times are GMT -4. The time now is 05:06 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 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