View Full Version : history to file
daglas
03-23-2011, 03:13 AM
Hello my dear friends.
I want to save historical data quotes for txt or csv file in a format OHCL.
I have write such script for MT4 a few years ago, it get history form every time frame and write into different text files (last 2000 bars), so I can analyze it with external tools.
Who have wrote such script? I can give you my script for MT4. I just need to know a few rows of code to accessing to historical data and writing it to a file.
Baruch
03-23-2011, 03:34 AM
Here you go
daglas
03-24-2011, 08:08 AM
Here you go
Thanks for the example of sources, but they did not work.
This code produce two rows into a file, a caption and zero data for 1800 year.
I have modify it a little. It give last 100 bars, but they are wut zero data too. How change it, how to get normal data?
Baruch
03-24-2011, 08:54 AM
Of course it works. I would not give something that doesn't.
How did you run it?
Baruch
03-24-2011, 08:55 AM
Just go into strategy analyzer and run a backtest.
daglas
03-24-2011, 09:25 AM
Ok, I try it. But why it does not at work at chart? I thought that it can work correct from chart.
When I create such solution for MT4 I just push script into a chart.
daglas
03-24-2011, 01:30 PM
Just go into strategy analyzer and run a backrest.
It's work perfect. Thanks a lot. I have all history I need in CSV files for analysis.
But how I can send real -time data to files or to dll.
Could you geve me samples of code for pushing OHCl data of two last candles to text file, and how I can call dll from NT7 and import function from it, because a have a huge algorithm's into dll's written on Delphi.
NinjaTrader_RyanM
03-24-2011, 02:04 PM
daglas, these samples can help writing information to a file using NinjaScript:
http://www.ninjatrader-support.com/vb/showthread.php?t=3477
http://www.ninjatrader-support.com/vb/showthread.php?t=3475
daglas
03-24-2011, 03:08 PM
daglas, these samples can help writing information to a file using NinjaScript:
thanks for links. May be you can give me some links for working with external dll, I want to know syntax of calling procedures and functions from it, and just want to see a few samples.
NinjaTrader_RyanM
03-24-2011, 03:57 PM
There is not a sample available for working with dlls. If you import the dll successfully, then the methods, properties, etc are available to access the same as other indicators. You can export a custom indicator as dll and then import it back in to see how this works. In some cases you will have to delete existing source prior to import.
http://www.ninjatrader.com/support/helpGuides/nt7/export.htm
daglas
03-24-2011, 04:08 PM
There is not a sample available for working with dlls.
How can I work with external dll? Can NT7 works with external dll not .NET based, writen on other languages like Delphi, or work with a standard windows dll like wininet.dll or gdi32.dll?
NinjaTrader_RyanM
03-24-2011, 04:37 PM
You can try with your external dll, by adding a reference to it through the Right Click > References screen in the NinjaScript code editor. Unfortunately our support for running external dlls is limited, so you will have to try on your end to see if your particular dll is compatible.
daglas
03-27-2011, 12:20 PM
You can try with your external dll, by adding a reference to it through the Right Click > References screen in the NinjaScript code editor. Unfortunately our support for running external dlls is limited, so you will have to try on your end to see if your particular dll is compatible.
Where can I read about working with external dll? For example with standard Windows dll like wininet, gdi32.dll? How can I cal their finctions from ninjaTrader scripts?
NinjaTrader_Austin
03-27-2011, 02:22 PM
daglas, as RyanM said, we only provide limited support for external .dlls, such as how to add a reference to those .dlls in your scripts, which RyanM already did. Once you have the reference added, you are on your own, as every .dll is different and we would not know how to use each and every .dll.
I would imagine you could utilize Google to find some examples of how to use wininet and gdi32.dll in your code.
daglas
04-01-2011, 08:22 AM
I would imagine you could utilize Google to find some examples of how to use wininet and gdi32.dll in your code.
Thanks. I know how to work with wininet and gdi32. But when I add reference to my indicator I receive error message - can't open meta data fille c:\***\wininet.dll. I also try different types of dll from Microsoft and my own dll's write in Delphi 6.