StreamWriter and System IO Aggro... - NinjaTrader Programming | futures io social day trading
futures io futures trading


StreamWriter and System IO Aggro...
Updated: Views / Replies:2,084 / 5
Created: by MXASJ Attachments:3

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

StreamWriter and System IO Aggro...

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

StreamWriter and System IO Aggro...

Hi all,

I'm trying to add some new functionality to my ExportData strategy. As it is, it will write the DateTime format to a file based on your systems settings. Current code is:

 
Code
string data = (Time[0] + dataSeparator + Open[0] + dataSeparator + High[0] + dataSeparator + Low[0] + dataSeparator + Close[0] + dataSeparator + Volume[0]);
 
if (splitDateTime == true)
{
//Replace the space in DateTime with the DataSeparator
data = data.Replace(@" ",dataSeparator);
}
 
sw.WriteLine(data);
So Time[0] outputs a DateTime struct based on your Windows settings. I would like to add an enum that allows the user to choose an output format of choice, using (for example)

 
Code
string data = (Time[0].ToString("yy-MM-dd HH:mm:ss") etc etc (pseudocode)
I know I can't use special characters in enums and I can work around that. My issue is that something as basic as this:

 
Code
bool x = true;
 
if(x)
{
string data = (Time[0] + dataSeparator + Open[0] + dataSeparator + High[0] + dataSeparator + Low[0] + dataSeparator + Close[0] + dataSeparator + Volume[0]);
}
... outputs a blank file (actually one that only has carriage returns).

So I can hard-code the output DateTime format but any time I try to give the user an option that is called either in OnStartUp() or OnBarUpdate() I get a blank output file.

Any thoughts I what I could be doing wrong?

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


Full code attached.

Attached Files
Register to download File Type: cs ExportData.cs (8.7 KB, 41 views)
Reply With Quote
 
  #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,352 given, 83,231 received


MXASJ View Post
So I can hard-code the output DateTime format but any time I try to give the user an option that is called either in OnStartUp() or OnBarUpdate() I get a blank output file.

Any thoughts I what I could be doing wrong?

Wild guess - the file isn't being opened or closed in the right order, maybe check your Print() statements to make sure they contain data, and if so, then it's definitely an issue with how the file is opened or closed as data is being written to it. Assuming you checked the Log tab for errors? The path resides in the Users\Documents directory (write access)?

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #5 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Thanks Mike. Making some positive progress with this in OnBarUpdate():

 
Code
switch(dateTimeFormat)
{
case MyDateTime.PCTimeFormat:
{
string data = (Time[0] + dataSeparator + Open[0] + dataSeparator + High[0] + dataSeparator + Low[0] + dataSeparator + Close[0] + dataSeparator + Volume[0]);
if (splitDateTime == true)
{
//Replace the space in DateTime with the DataSeparator
data = data.Replace(@" ",dataSeparator);
}
 
sw.WriteLine(data);
 
break;
}
case MyDateTime.ISO8601Basic:
{
string data = (Time[0].ToString("yyyyMMdd HHmmss") + dataSeparator + Open[0] + dataSeparator + High[0] + dataSeparator + Low[0] + dataSeparator + Close[0] + dataSeparator + Volume[0]);
if (splitDateTime == true)
{
//Replace the space in DateTime with the DataSeparator
data = data.Replace(@" ",dataSeparator);
}
 
sw.WriteLine(data);
break; 
}
case MyDateTime.ISO8601Extended:
{
string data = (Time[0].ToString("yyyy-MM-dd HH:mm:ss") + dataSeparator + Open[0] + dataSeparator + High[0] + dataSeparator + Low[0] + dataSeparator + Close[0] + dataSeparator + Volume[0]);
if (splitDateTime == true)
{
//Replace the space in DateTime with the DataSeparator
data = data.Replace(@" ",dataSeparator);
}
 
sw.WriteLine(data);
break; 
}
 
}

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

Still needs a bit of testing and cleanup but if anyone wants to try my latest ExportData strategy and take a particular look at DateTime output formats that would be great. Open to suggestions on ways to make it better.

cs file attached.

Attached Thumbnails
StreamWriter and System IO Aggro...-dialog.jpg  
Attached Files
Register to download File Type: cs ExportData.cs (12.6 KB, 43 views)

Last edited by MXASJ; December 2nd, 2010 at 07:11 PM. Reason: Add JPEG of dialog box
Reply With Quote
The following 3 users say Thank You to MXASJ for this post:

Reply



futures io > > > > > StreamWriter and System IO Aggro...

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
Would you trade this system??? NW27 Elite Automated Trading 5 February 17th, 2011 02:12 AM
a CCI system cory Traders Hideout 13 February 15th, 2011 07:45 AM
eminishark system sysot1t Trading Reviews and Vendors 24 September 14th, 2010 02:54 PM
Buying A System... ziebarf Traders Hideout 9 July 31st, 2010 12:45 PM
example of trading system iwannatoscript NinjaTrader Programming 3 March 4th, 2010 08:38 PM


All times are GMT -4. The time now is 01:21 PM.

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-14 in 0.12 seconds with 20 queries on phoenix via your IP 54.234.255.29