Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Debugging a BarsType help
Updated November 20, 2014
Top Posters
looks_one
zacharydw00
with 6 posts (3 thanks)
looks_two
MXASJ
with 3 posts (0 thanks)
looks_3
eman
with 2 posts (0 thanks)
looks_4
DavidHP
with 1 posts (1 thanks)
trending_up
7,411 views
thumb_up
7 thanks given
group
2 followers
forum
13 posts
attach_file
2 attachments
Debugging a BarsType help
April 18th, 2011, 09:18 PM
Idaho
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180
I've been unable to get Studio 2008 to debug a BarsType. And, of course Print() does not work in that class. Can someone point me in the right direction? I'm somewhat a novice in C# & VS 2008. Thanks for any help.
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
April 18th, 2011, 09:21 PM
Asia
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800
Could you throw us a few lines of code to show what you are trying to do? You should be able to access that in OnStartUp() if you are looking to Print it.
April 18th, 2011, 09:26 PM
Asia
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800
Code
Print(DateTime.Now + " Instrument and Bars Type " + Instrument.FullName + " " + BarsPeriod.Value + " " + BarsPeriod.Id );
Try that in OnStartUp(). Is that what you are trying to do?
April 18th, 2011, 10:37 PM
Idaho
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180
zacharydw00
... BarsType. And, of course Print() does not work in that class.
And, there is no OnStartUp() in a BarsType class.
Thanks for trying MXASJ.
April 18th, 2011, 11:07 PM
Asia
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800
BarsType has a ToString() method. But again I don't understand what you are trying to do...
April 18th, 2011, 11:19 PM
Isla Mujeres, MX
Legendary Market Wizard
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,625 since Aug 2009
Thanks Given: 11,356
Thanks Received: 2,756
One way is to use StreamWriter to create a file that will write what you want to a text file.
Bar Types don't do PRINT statements. (as far as I know)
Something like this maybe:
Code
// at the beginning
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\BarTextFile.txt");
...
// every time you want to make a note of something
file.WriteLine("Hello World");
file.Flush();
...
// when done
file.Close();
You can download a sample that NT provides if you have issues.
SampleStreamWriter NT7
Indicator: Using StreamWriter to write to a text file - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum
Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind . . .
But Learning to Dance in the Rain ! ! !
April 19th, 2011, 04:20 AM
Idaho
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180
Thanks David. StreamWriter starts to work, but then I get the same kind of error regardless if I use NT's sample, code or yours, or the examples on Microsoft's web site How to: Open and Append to a Log File
Shortly after the file is created and written to I get this error in the trace log
Code
2011-04-19 02:00:59:980 ERROR: Failed to call 'Add' method for period type 'LineBreakWckTest': The process cannot access the file 'C:\Documents and Settings\Zac\My Documents\NinjaTrader 7\LBWickedTest _2011.04.19.txt' because it is being used by another process.
2011-04-19 02:01:18:419 ERROR: Failed to call 'Add' method for period type 'LineBreakWckTest': The process cannot access the file 'C:\Documents and Settings\Zac\My Documents\NinjaTrader 7\LBWickedTest _2011.04.19.txt' because it is being used by another process.
2011-04-19 02:01:18:763 (AMP Zen-Fire Live GRT) Data.Bars.GetBarsNow: instrument='TF 06-11' from='2011-04-13' to='2011-04-15 23:59:59' period=1 Tick splitAdjusted=False dividendAdjusted=False bars=0 session='CME US Index Futures RTH'
2011-04-19 02:01:22:013 ERROR: Failed to call 'Add' method for period type 'LineBreakWckTest': The process cannot access the file 'C:\Documents and Settings\Zac\My Documents\NinjaTrader 7\LBWickedTest _2011.04.19.txt' because it is being used by another process.
2011-04-19 02:01:22:450 (AMP Zen-Fire Live GRT) Data.Bars.GetBarsNow: instrument='TF 06-11' from='2011-04-11' to='2011-04-15 23:59:59' period=1 Tick splitAdjusted=False dividendAdjusted=False bars=0 session='CME US Index Futures RTH'
2011-04-19 02:01:27:732 ERROR: Failed to call 'Add' method for period type 'LineBreakWckTest': The process cannot access the file 'C:\Documents and Settings\Zac\My Documents\NinjaTrader 7\LBWickedTest _2011.04.19.txt' because it is being used by another process.
2011-04-19 02:01:28:357 (AMP Zen-Fire Live GRT) Data.Bars.GetBarsNow: instrument='TF 06-11' from='2011-04-07' to='2011-04-15 23:59:59' period=1 Tick splitAdjusted=False dividendAdjusted=False bars=0 session='CME US Index Futures RTH'
2011-04-19 02:01:35:186 ERROR: Failed to call 'Add' method for period type 'LineBreakWckTest': The process cannot access the file 'C:\Documents and Settings\Zac\My Documents\NinjaTrader 7\LBWickedTest _2011.04.19.txt' because it is being used by another process.
2011-04-19 02:01:36:717 (AMP Zen-Fire Live GRT) Data.Bars.GetBarsNow: instrument='TF 06-11' from='2011-03-23' to='2011-04-15 23:59:59' period=1 Tick splitAdjusted=False dividendAdjusted=False bars=0 session='CME US Index Futures RTH'
I've gotten the best results using this
Code
private string path = Cbi.Core.UserDataDir.ToString()+"LBWickedTest "+DateTime.Now.ToString("_yyyy.MM.dd")+".txt";
private System.IO.StreamWriter sw;
public override void Add(Bars bars, double open, double high, double low, double close, DateTime time, long volume, bool isRealtime)
{
sw = File.AppendText(path);
int barcnt = bars.Count;
sw.WriteLine("{0} : Barcnt = {1}",time, barcnt);
....
....
sw.Flush(); sw.Close(); // CLEAN UP
}
// Bar logic code End ----------------------------------------------------------------------------
I would appreciate any other suggestion.
Attached Files
Elite Membership required to download: LineBreakWickedTestBarsType.cs
April 19th, 2011, 10:39 PM
Idaho
Experience: Intermediate
Platform: NinjaTrader,ToS
Broker: Amp Futures, ToS
Trading: ES, E7, CL, GC
Posts: 149 since Aug 2009
Thanks Given: 87
Thanks Received: 180
I got things working, and will post a Wiki later after I'm done debugging. Thanks David for pointing me in the right direction.
April 28th, 2011, 09:45 AM
Galveston ,TX
Experience: Intermediate
Platform: NT7
Broker: Zaner
Trading: Futures
Posts: 386 since Mar 2010
Thanks Given: 364
Thanks Received: 435
hey zac - did you ever have a chance to post that wiki ? i saw you were able to fix your issues with LBW
cheers,
-e
Last Updated on November 20, 2014