Debugging a BarsType help - NinjaTrader Programming | futures io social day trading
futures io futures trading


Debugging a BarsType help
Updated: Views / Replies:3,348 / 13
Created: by zacharydw00 Attachments:2

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

Debugging a BarsType help

  #1 (permalink)
Elite Member
Idaho
 
Futures Experience: Intermediate
Platform: NinjaTrader,ToS
Broker/Data: Amp Futures, ToS
Favorite Futures: ES, E7, CL, GC
 
zacharydw00's Avatar
 
Posts: 139 since Aug 2009
Thanks: 81 given, 164 received

Debugging a BarsType help

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?
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)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received


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.

Reply With Quote
 
  #4 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

 
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?

Reply With Quote
 
  #5 (permalink)
Elite Member
Idaho
 
Futures Experience: Intermediate
Platform: NinjaTrader,ToS
Broker/Data: Amp Futures, ToS
Favorite Futures: ES, E7, CL, GC
 
zacharydw00's Avatar
 
Posts: 139 since Aug 2009
Thanks: 81 given, 164 received


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?
Reply With Quote
 
  #6 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

BarsType has a ToString() method. But again I don't understand what you are trying to do...

Attached Thumbnails
Debugging a BarsType help-capture.jpg  
Reply With Quote
 
  #7 (permalink)
Market Wizard
New Orleans, La (Mardi Gras City)
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Ninjatrader / Optimus Futures / AmpFutures
Favorite Futures: ES / 6E / 6B / CL
 
DavidHP's Avatar
 
Posts: 1,002 since Aug 2009
Thanks: 803 given, 1,367 received

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 - NinjaTrader Support Forum

Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Reply With Quote
The following user says Thank You to DavidHP for this post:
 
  #8 (permalink)
Elite Member
Idaho
 
Futures Experience: Intermediate
Platform: NinjaTrader,ToS
Broker/Data: Amp Futures, ToS
Favorite Futures: ES, E7, CL, GC
 
zacharydw00's Avatar
 
Posts: 139 since Aug 2009
Thanks: 81 given, 164 received

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
Register to download File Type: cs LineBreakWickedTestBarsType.cs (31.4 KB, 14 views)
Reply With Quote
The following 2 users say Thank You to zacharydw00 for this post:
 
  #9 (permalink)
Elite Member
Idaho
 
Futures Experience: Intermediate
Platform: NinjaTrader,ToS
Broker/Data: Amp Futures, ToS
Favorite Futures: ES, E7, CL, GC
 
zacharydw00's Avatar
 
Posts: 139 since Aug 2009
Thanks: 81 given, 164 received

FYI

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?
Reply With Quote
The following user says Thank You to zacharydw00 for this post:
 
  #10 (permalink)
 Vendor: www.coroin.com 
Galveston ,TX
 
Futures Experience: Intermediate
Platform: NT7
Broker/Data: Zaner
Favorite Futures: Futures
 
Posts: 386 since Mar 2010
Thanks: 364 given, 433 received


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

Reply With Quote

Reply



futures io > > > > > Debugging a BarsType help

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
NinjaTrader 7 List of used BarsType base(PeriodType.?) zacharydw00 NinjaTrader Programming 13 December 16th, 2015 01:59 PM
Momentum BarsType (NT7) eman The Elite Circle 308 June 24th, 2014 12:52 PM
BarsType.Add method - how to always detect if (bars.Count == 0)? jdfagan NinjaTrader Programming 2 June 29th, 2010 06:33 PM
need some help with debugging. kaywai NinjaTrader Programming 1 January 18th, 2010 05:40 AM


All times are GMT -4. The time now is 11:10 AM.

Copyright © 2017 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
Page generated 2017-12-16 in 0.12 seconds with 20 queries on phoenix via your IP 54.226.34.209