![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Mar 2011
Location: Ukraine
Posts: 146
Thanks: 19
Thanked 2 times in 2 posts
|
Dear friends.
I have create strategy which save last bar data to file (only one row OHCL data), but it working slow and unstable. I move code from this strategy to indicator and indicator works better. Than I find sample stream writer indicator which write ohcl data to file. But I need only one row in file only last bar data, I don't need all history from chart. So how should I fix stream writer indicator for saving only last bar data? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,567
Thanks: 261
Thanked 1,016 times in 997 posts
|
daglas, using System IO here would be liklely better performing for your task - http://www.ninjatrader.com/support/f...ad.php?t=48902
You can simply move the if (Historical) return; statement you see, so it would only save current realtime data going forward for example, currently it would store all historical data as well in the sample and then output the RT saved data to the output window.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Bertrand for this post: |
|
|
|
#3 |
|
Senior Member
Join Date: Mar 2011
Location: Ukraine
Posts: 146
Thanks: 19
Thanked 2 times in 2 posts
|
I prefer such solution
if (CurrentBar>Bars.Count-100) { File.WriteAllText(path, Open[0]); } |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Mar 2011
Location: Ukraine
Posts: 146
Thanks: 19
Thanked 2 times in 2 posts
|
Now I have such trouble. If my program which periodically read this file cause collision (read the file when nt7 try to save data to this file), indicator stops and I have error message in log windows. Something like indicator can't access to file ****. How can I write some exception in body of indicator, to retry reading file after collision or something also which help to write data even after errors.
|
|
|
|
|
|
#5 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,567
Thanks: 261
Thanked 1,016 times in 997 posts
|
daglas, you would need to look into locking the file to ensure no concurrent access is possible - for ideas you can check into this link - http://stackoverflow.com/questions/7...ed-environment
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| saving quotes to file at each new bar | daglas | General Programming | 4 | 07-22-2011 11:53 AM |
| Looking for independant ninjascript writer | Johnnyninja | Strategy Development | 1 | 09-28-2010 10:33 AM |
| DX Indicator - Need C Sharp writer | nelsonnelson | Indicator Development | 0 | 07-29-2010 05:00 PM |
| To: CalculateValueArea : writer | T2020 | Charting | 1 | 12-21-2008 08:52 AM |
| code writer needed | upwardtrade | ATM Strategies (Discretionary Trading) | 1 | 05-05-2008 04:41 PM |