Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Writing Bar High and Low to a file
Collapse
X
-
Originally posted by skiguy View PostCalculateOnBarClose = true;
as per the sample provided.
I did try it with false and it not make a difference.
Having said that given the "random" results it would be hard to know if it made a difference.
I would only run this when I did not need the very latest bar so for my purposes I would be happy to use what works reliably.
What do you suggest is the best setting?
Probably neither - but it could be close depending on:
What is your Session Template set to? 24x7 or something that closes an hour or more after the real close might work better? I could see issues with 4pm EST close....(RTH)... some sort of ETH should work?
Leave a comment:
-
Thanks.
Basically Josh's sample with a column added to the output and date >.
Also I tried MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
but it did not make a any difference.
protectedoverridevoid Initialize()
{
CalculateOnBarClose = false;
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
/* The try-catch block is used for error handling.
In this case it is used to ensure you only have one stream object operating on the same file at any given moment. */
try
{
// If file at 'path' doesn't exist it will create the file. If it does exist it will append the file.
if (CurrentBar == 0)
sw = File.AppendText(path);
// This is the output of all lines. The output format is as follows: Date Open High Low Close
//sw.WriteLine(ToDay(Time[0]) + " " + Open[0] + " " + High[0] + " " + Low[0] + " " + Close[0] + " " + ToDay(Time[0]));
if (ToDay(Time[0]) > 20150101)
sw.WriteLine(ToDay(Time[0]) + " " + Time[0].TimeOfDay + " " + Open[0] + " " + High[0] + " " + Low[0] + " " + Close[0]);
}
Leave a comment:
-
CalculateOnBarClose = true;
as per the sample provided.
I did try it with false and it not make a difference.
Having said that given the "random" results it would be hard to know if it made a difference.
I would only run this when I did not need the very latest bar so for my purposes I would be happy to use what works reliably.
What do you suggest is the best setting?
Last edited by skiguy; 03-04-2015, 11:59 PM.
Leave a comment:
-
Skiguy.
I am not aware of anything with that.
However, I would like to take a look at your code to get a better idea of what is being done there and potentially testing it on my end.
Leave a comment:
-
Issue --- not all data is exported?
60 min bar example.
I have tried various things but there seems to be a limitation on how much data is output for each execution i.e. never get right to the end of the most recent data.
Even after adding a date limitation e.g.
if (ToDay(Time[0]) > 20150101)
I get variable results. Test 1 I get 990 rows. Test 2 I get 959 rows.
Even the 990 row example did not quite get to the very lasts data i.e. it stopped at:
20150302 15:00:00 2111.5 2115.5 2111 2115.25
959 row example stopped at:
20150227 07:00:00 2107.25 2107.75 2106 2107.25
20150227 08:00:00 2107.25 210
NB it did not even complete writing the entry.
Curiously, it has stopped here:
20150227 08:00:00 2107.25 210 a number of times that I have run the test.
Same data, same chart, same code.
When I add
if (ToDay(Time[0]) > 20150228)
I do get March data to the very current closed bar.
Is it possible "big" data extractions get interrupted somehow?
Leave a comment:
-
Think I have it sorted
Think I have it sorted.
Need to do some QA on the output.
Added:
+ Time[0].TimeOfDay
Leave a comment:
-
Hi,
Should the time be being output from that code?
Snipped from the code >>>>>> ToDay(Time[0]
I am getting multiple bars for the day - tick but not times.
I cannot figure out how to get the time ATM.
I tried to add the TimeOfDay property but that did not.
This is the output:
20150301 2107 2107.5 2106 2106
20150301 2106.25 2106.25 2104.25 2104.75
20150301 2104.5 2106 2104.5 2104.75
20150301 2104.75 2105.75 2104.5 2105.5
20150301 2105.5 2105.75 2105.25 2105.5
20150302 2105.5 2105.75 2105 2105
20150302 2105 2105.5 2104.75 2105
20150302 2104.75 2105.5 2104.5 2104.5Last edited by skiguy; 03-03-2015, 06:29 PM.
Leave a comment:
-
Hello Skiguy,
Thank you for your note.
Please take a look at the reference samples below on writing to a file -
http://www.ninjatrader.com/support/f...ead.php?t=3477
http://www.ninjatrader.com/support/f...ead.php?t=3475
Let me know if I can be of further assistance.
Leave a comment:
-
Writing Bar High and Low to a file
Example.
Have a chart for ES 03-15 with 60 minute bars.
I want to output to a file the high and low of every 60 min bar for all the data loaded e.g. I may have selected 60 days when loading the chart.
I also want to output the date and the time of the bar as displayed in the NT chart.
I have my computer set to Chicago time and hence I want the data to be Chicago time as displayed in my NT charts.
I had a look around I cannot find anything to build on.
HelpTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by NINZAMANA, Yesterday, 01:36 PM
|
1 response
10 views
0 likes
|
Last Post
|
||
Started by TraderTimmy71, Today, 07:05 AM
|
0 responses
4 views
0 likes
|
Last Post
![]() |
||
Started by Marty125, Yesterday, 01:48 PM
|
1 response
15 views
0 likes
|
Last Post
|
||
Started by Nightmaregpu, Yesterday, 10:55 AM
|
4 responses
28 views
0 likes
|
Last Post
|
||
Started by PH_GMT, 02-12-2025, 12:40 PM
|
10 responses
66 views
0 likes
|
Last Post
|
Leave a comment: