NexusFi: Find Your Edge


Home Menu

 





Debugging a BarsType help


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one zacharydw00 with 6 posts (3 thanks)
    2. looks_two MXASJ with 3 posts (0 thanks)
    3. looks_3 eman with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 7,325 views
    2. thumb_up 7 thanks given
    3. group 2 followers
    1. forum 13 posts
    2. attach_file 2 attachments




 
 

Debugging a BarsType help

 
 
zacharydw00's Avatar
 zacharydw00 
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.

Milk-a-What?
Started this thread

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
33 thanks
Just another trading journal: PA, Wyckoff & Trends
28 thanks
Tao te Trade: way of the WLD
23 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
21 thanks
 
 MXASJ 
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.

 
 MXASJ 
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?

 
 
zacharydw00's Avatar
 zacharydw00 
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 View Post
... BarsType. And, of course Print() does not work in that class.

And, there is no OnStartUp() in a BarsType class.

Thanks for trying MXASJ.

Milk-a-What?
Started this thread
 
 MXASJ 
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...

Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	138
Size:	104.6 KB
ID:	36931  
 
 
DavidHP's Avatar
 DavidHP 
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,611 since Aug 2009
Thanks Given: 11,341
Thanks Received: 2,744

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 ! ! !
Follow me on Twitter
Thanked by:
 
 
zacharydw00's Avatar
 zacharydw00 
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.

Milk-a-What?
Attached Files
Elite Membership required to download: LineBreakWickedTestBarsType.cs
Started this thread
Thanked by:
 
 
zacharydw00's Avatar
 zacharydw00 
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.

Milk-a-What?
Started this thread
Thanked by:
 
 eman 
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


© 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