I have a large external body of C# code with many complex indicators
and want to periodically write quotes and lasts from Ninja into a file
which can be referenced by those external indicators.
My search of the forum topics did not turn up any related code examples.
The code included below illustrates a general outline of what I'm trying to accomplish.
The problem for me is that I'm not really sure where to put that baseline code within the Ninja Framework.
Should I try to implement this as a ninja indicator, or should I make it as a stand alone thread, or some other handler?
Are there any existing examples available which do similar things involving timers and files?
What is the object name which contains the list of ticker symbols subscribed to level 1 quotes and lasts?
What is the object name which contains the quote and last prices of those symbols?
Can you provide any suggestions how to get started?
Thanks,
John Devron
#region this is declared global at the top of the file which will write the quotes
//declare new instance of a timer
System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
#endregion
#region this goes inside a form load routine
// Initialize the timer
timer1.Interval = 500; //timer fires every 500 milliseconds
timer1.Tick += new System.EventHandler(this.write_quote_data);
timer1.Enabled = true; //activate the timer to begin
#endregion
#region this goes inside some code file
public static void write_quote_data()
{
int sym_num = new int();
string line_data = null;
string quotes_file = @"C:\live_quote_data\realtime_quotes.txt";
int SFM = DateTime.Now.Second
+ (60 * DateTime.Now.Minute)
+ (3600 * DateTime.Now.Hour); //get the time in Seconds From Midnight
using (StreamWriter filestream1 = File.CreateText(quotes_file)) //Open the file to create a new file
{
for (sym_num = 0; sym_num < GlobalVars.num_Intraday_ticker_symbols; sym_num++)
{
line_data = SFM
+ "," + GlobalVars.Intraday_watchlist[sym_num]
+ "," + GlobalVars.last_price[sym_num] + "," + GlobalVars.last_size_up[sym_num] + "," + GlobalVars.last_size_down[sym_num]
+ "," + GlobalVars.best_ask[sym_num] + "," + GlobalVars.ask_size[sym_num]
+ "," + GlobalVars.best_bid[sym_num] + "," + GlobalVars.bid_size[sym_num];
filestream1.WriteLine(line_data);
}
filestream1.Close(); //Close the file
}//using (StreamWriter
}//write_quote_data()
#endregion
Comment