View Full Version : Get Indicator Input from Excel
Richard Von
09-10-2007, 10:21 AM
I have an indicator I use on multiple charts that requires manual inputs regularly. Now I have to make these entries separately for each chart.
What I would like to do is to make th entries once into a simple Excel sheet (one column, two or three entries) and have the indicator read those for all charts (simply by Reloading NinjaScript).
What is the simplest code to make the spreadsheet accessible and then to read the cells I need?
Or is there another way to do this?
NinjaTrader_Ray
09-10-2007, 11:00 AM
Hi,
Unfortunately, this is outside the scope of what we can support. However, since NinjaScript is C#, you could likely accomplish what you want. Just have to google for it. I would likely take a different approach and just read in a text file that contains these values. If you start creating objects that have scope over the lifetime of an indicator, be sure to clean up these resources in the Dispose() method.
http://www.ninjatrader-support.com/HelpGuideV6/Dispose.html
Richard Von
09-10-2007, 01:02 PM
A text file would be fine with me -- I'm looking for the simplest way. How would I do that?
NinjaTrader_Ray
09-10-2007, 01:14 PM
You will need to google for resources and samples on reading/writing to text files in .NET.
Google and search this forum for references to StreamReader and StreamWriter.
Folls
09-10-2007, 04:50 PM
I'm not an experienced program but here is how I read some values from a file:
First, I added a line to the Using declarations (using System.IO;):
#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.Strategy;
//added by me
using System.IO;
#endregion
Then, I added the attached code to OnBarUpdate to read four values from a file and convert to doubles.
You are interested in the try and catch section. The part before that is specific to my code.
Folls
NinjaTrader_Ray
09-10-2007, 04:54 PM
Thanks for the contribution Folls.
We will publish some official reference files for File I/O by the end of next week.
Richard Von
09-11-2007, 06:54 AM
Thank you Folls, I'll work on this.
And I'm looking forward to the new reference files. How will I find them?
NinjaTrader_Ray
09-11-2007, 07:01 AM
They will be posted in this section.
http://www.ninjatrader-support.com/vb/forumdisplay.php?f=29