Registered User Joined: 10/7/2004 Posts: 56
|
I downloaded from kuf.blocks.com/post/4121 the sample layout with a MarketDataReader and FileReader and the sample data file that goes with it but all I'm getting are blank indicator windows. I tried to fix it by moving sample data file from StockFinder5\... to StockFinder\... folder but that didn't fix it.
Is it possible to import data to stockfinder5? Besides CSV to Line block?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It definitely works. Make sure you have extracted the data to the \My Documents (or Documents)\StockFinder5\(your Username)\DataFiles\SFSampleImportData\ folder.
Also note that the data being displayed goes from 6/30/2008 through 4/15/2009 and is for a limited selection of symbols (look in the folder to find out which symbols as the file names match the symbols).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 10/7/2004 Posts: 56
|
I scrolled back to 4/15/2009 and there it was! That was silly. Thank you.
I opened the sample data text files and there are dates and OHLC, like this:
06/30/2008,38.17,38.68,37.61,37.67
07/01/2008,37.95,40.14,37.77,40.02
07/02/2008,40.11,40.90,39.50,39.62
and yet the graph will not display OHLC bars when I set it to OHLC in edit window.
Another question:
How could I modify this code to display intraday data? And should I use FileReader or DataReader for my purpose (plotting a history of my trades)?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It doesn't output OHLC data because the RealCode is only reading the Date and Close data fields and only outputting the Close data for the Date. You would need to read data from the fields for the Open, High and Low in order to have the data to output. You would then need to explicitly output the OHLC data instead of just outputting the Close.
I would use the RealCode File Reader and use AddToOutput(Date & Time, Open, High, Low, Close) to output OHLC data. To output a time of day as part of the date, it must be included in the Date & Time data.
You'll probably need to know at least something about VB.NET's DateTime structure to include the time of day as part of the date. I would do an internet search or get a book on Visual Basic .NET to learn more about it.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Hi Bruce, I forgot about this feature.
couple questions:
Since Stockfinder doesn't support futures;
Assuming I have a file with minute bar data of SPX futures, Can I chart that, not just as an indicator but on the main pane, instead of a ticker's data ?
And since Futures trade after hours, will it support charting after 4PM?
Actually I editied your CSV file and added a couple entries after 4PM, and it seems that it charts it.
So main question is how can I create a chart that only shows the data from the file? In blocks maybe?
thanks as always.
P.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You can't actually import the data, you can only plot it as an indicator. There are a lot of things you can do with it once it is plotted, but it won't actually act as the price plot.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Let's say I have a csv file with dat/time - close price, and volume.
In order to plot close price, and volume on the same bar, Do I need to make two indicators, each accessing the same csv file? one for the close price, and one for the volume?
Is there anyway to do this in a single indicator?
thanks.
P.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You can plot four values for each bar in a single indicator by using AddToOutput(Date & Time, Open, High, Low, Close) instead of using AddToOutput(Date & Time, Value). But you would have to output four values if you wanted to do this even if you are only interested in two of the values (you could duplicate values).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Yes I was thinking of that, but wouldn't that raise the issue of scaling?
if price is around 20, and volume around 1000, you would barely see the price move.
And you couldn't plot two lines; one for the price, and one for the volume. correct?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If you are worried about visualization, you are probably better of just plotting two indicators instead of one indicator.
Using bar data for things that really don't scale together is just a way to get data out of RealCode so it is available for something else.
You could use the Line Plot Style (I think this works to keep the scale isolated to the one value) to plot one value. Then you could just reference the other values and not plot them as part of the indicator. This would mean the second plot would still be a second indicator (not sure if it would be more or less efficient).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
got it. thanks Bruce
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Hi Bruce, this is working rather well. I have a file with over 120,000 records, and the indicator plots without any noticeable delay.
The records are not at specific intervals, so in realcode, based on selected Timeframe, I accumulate the values I need of the records in between bars, and then plot them at the correct interval.
The file holds data for multiple tickers. so again in realcode I use "currentsymbol" to select only the records of the current selected ticker.
I have one problem, and that is when I jump through different timeframes and tickers for a while, it sometimes stops plotting and the blue arrow circle thingy (calculating) shows up nextto the indicator name. And I have to restart SF.
I suspect it is because the file wasn't closed before I changed to a different timeframe or ticker.
I have done similar routines in VB.net. but there you have the option to check for "connectionstate", as follows:
Try
reader.open
While reader.endoffile = false
........
........
End While
Catch ex as Exception
If reader.state = ConnectionState.open then
reader.close()
end if
end try
So, if there's a problem, it checks if the file is still open and closes it.
But this doesn't work in realcode.
Any idea on how to do this? or do some sort of error checking in the "Catch" routine?
Thanks,
P.
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
forgot to add:
added this after he Catch ex as Exception statement, but a message never appears.
showmessage(ex.message + "from filereader")
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
oh and ofcourse I do have the :
Finally
Reader.close
End try
at the end.
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
one more issue:
Created three indicators based on the same file.
two of them are overlayed, bottom pane.
It's been a while since I used the paintscheme.
If you look carefull at the bottom pane, you can see that the 2:07 bar plots both values from both indicators. other bars will do the same. but most of them don't.
For example the 2:03 bar's "Dollar weighte CallTrades" shows 124,326.00.
But when I move the crosshair over the bar, it shows a value for "Dollar weighted PutTrades" at 37,638.00, but it doesn't paint it on the bar.
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Oh wait, never mind. I see what's happening.
The "Dollar Weighted PutTrades" value was 37,638.00 on the 2:02 bar. and subsequent bars were 0, up to the 2:07 bar.
However the crosshairtool shows the value of the last bar that has a value > 0, when you hover over a bar that is 0.
So the plot is correct.
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
If I don't change ticker or timeframe it runs perfectly, but if I start switching tickers/tframe, it stops.
any idea on my previous question? If you want I can email the indicator and the file to support.
Also I would like to see if we can create some sort of paintscheme. I guess it depends on how you overlay the two indicators. but if the green indicator is bigger than the red one, it still shows the red one.
But if the red one is bigger then the green one, then the green one doesn't show
see arrow on chart. the green indicator value is smaller than the red indicator, but has a value of 5.45K but it doesn't show.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please select Help | Send Layout so technical support can take a look. Please include a description of the issue you are experiencing when sending the Layout to technical support.
You aren't seeing the green bar when the red bar is bigger because the red bar is in front of the green bar. One option would be to not plot the red bars in front of the green bars (for example, have them point down instead of up by making the values negative).
The only thing I can think of to do with the red and green bars if you need them to plotted in the same place would be to play with the transparency so if the green bar is behind the red bar it doesn't get completely hidden.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
OK, I thought of another thing you could do, but it seems way more complicated than just adjusting the transparency on the red indicator. You could create another green indicator which only plots when the red indicator is greater than the original green indicator and have it plot in front of the red indicator.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Thanks. forgot all about the transparency setting. that'll work for now.
I have an app that updates every couple of seconds a txt file. and the SF indicator reads it every 5seconds.
The TradeTime and Date are in epoch notation.
to get the date you need to add the values as days to 1/1/1970 , and the time as seconds added to 00:00:00
So 9:30AM is 34200
Currently I have the indicator walk through the file, check for currentsymbol = values(5) and Values(6) is either "C" or "P"
then add the records that fall within bar duration as per selected timeframe, and plot it at time of price bar's close.
so for example if timeframe is 5min, the indicator will add the values(1) of the records between 34200 and 34500 and plots it at 9:35, and so on.
My question is: what would be better: using the date and time, like so:
AddToOutput(date1 & " " & time1, TotPuts, TotPuts, TotPuts, TotPuts)
or should it be better to use the chart index and use
AddtoOutput(Price.Bar.Datevalue(i), TotPuts, TotPuts, TotPuts, Totputs)
'values(0) = Symbol
'values(1) = Close Price
'values(2) = Volume
'values(3) = TradeTime (epoch)
'values(4) = Tradedate (epoch)
'values(5) = UnderlyingSymbol
'values(6) = Call or Put C,P
'values(7) = Qty
'values(8) = Dollar amount Trade (Qty*ClosePrice*100)
'values(9) = DaysToExpiration
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
so for example if timeframe is 5min, the indicator will add the values(1) of the records between 34200 and 34500 and plots it at 9:35, and so on.
Should be:
so for example if timeframe is 5min, the indicator will add the values(8) of the records between 34200 and 34500 and plots it at 9:35, and so on.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I have not tested your other method, but I almost always use Price.Bar.DateValue(i) instead of constructing the datetime manually if I am going to plotting any price data at the same time. I do it this way because I then know for sure the datetime is going to match the other plots on the chart instead of creating something that might be off by a fraction of a second and plot in a different place. It should be also be slightly less resource intensive to reference an existing datetime than to construct one.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Yes I was thinking the same thing.Thank you very much, that helps a lot.
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
Bruce,
Can you find out what the members are of the RealcodeFileReader?
From the various posts on this topic I see that we can use:
reader.open
reader.close
reader.EndOfFile
are there any more?
I was looking for reader.connectionstate (something that is supported in VB.NET with the IO. streamreader class) But not implemented in realcode under the RealcodeFileReader class?
Thanks,
P.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I'm not quite sure why it would not have everything available in the System.IO.StreamReader, but I've asked.
"The RealCode file reader wraps the System.IO.StreamReader class. All of the .net properties and methods of the StreamReader class are available to the RealCodeFileReader. Additionally, the RealCodeFileReader has the ability to monitor a file for changes.
If you keep a class member variable of your RealCodeFileReader and instatiate the class in your constructor, you can call the WatchFile method to watch for changes to the file. See the RealCode sample: Reading and external trade log file for an example of using WatchFile."
I got that from page 42 of the following file. It is an older version of the documentation than the reference on the main StockFinder page.
RealCode Reference
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
I got another aha moment from your last response.
Didin't know you could address class variables in a dictionary, and didn't even know you could even use another class. wow cool.
Going over the example in the pdf file, I want to try the following:
initially read the whole file, and put the values as a member of a class into a dictionary, and keep an index as the key. will make this index static. From researching online, I should be able to read specific lines from the file instead of the whole file. So when the file changed, I only have to read the lines from the last index value to end of file. This will be much better, I guess, when the file grows larger.
I always use a messageboxes while working on a new indicator, to show me that it is doing what I expect it to do.
I just made a start with the new indicator. something weird: I can't get the messageboxes to show anything at all. no matter what variable I want to show in my messagebox:
code:
inherits RealCodeIndicator_base
Private OptionsFile As RealCodeFileReader
Private OptionsData As New System.Collections.Generic.Dictionary(Of Integer,TradeData)
Sub New
Me.autoloop = False
Dim filename As String = currentsymbol & ".csv"
showmessage(filename)
showmessage(currentsymbol)
OptionsFile = New RealCodeFileReader(filename)
OptionsFile.WatchFile(Me)
End Sub
Public Overrides function Plot() as System.Single
Dim idx As Integer = 0
showmessage(idx)
If OptionsFile.FileChanged Then
Try
OptionsFile.Open
While OptionsFile.EndOfStream = False
Dim line As String = OptionsFile.ReadLine
Dim td As New TradeData(line)
OptionsData.add(idx, td)
idx = idx + 1
End While
Catch ex As System.Exception
Me.log.info("Err", ex)
Finally
OptionsFile.Close
End Try
End If
showmessage(idx)
End Function
Private Class TradeData
Sub New(line As String)
On Error Resume Next
Dim values() As String = line.split(",")
Me.symbol = values(0)
Me.ClosePrice = values(1)
Me.Volume = values(2)
Me.TradeTime = values(3)
Me.TradeDate = values(4)
Me.UnderlyingSymbol = values(5)
Me.CallPut = values(6)
Me.Qty = values(7)
Me.Amount = values(8)
Me.DaysToExp = values(9)
End Sub
Public Symbol As String
Public ClosePrice As Single
Public Volume As Integer
Public TradeTime As Integer
Public TradeDate As Integer
Public UnderlyingSymbol As String
Public CallPut As String
Public Qty As Integer
Public Amount As Single
Public DaysToExp As Integer
End Class
End Class
|
|
Registered User Joined: 5/6/2014 Posts: 81
|
the weirdest thing ever
I deleted the showmessage lines from previous code, and only did a showmessage(idx). and see what happens:
http://screencast.com/t/rihgRerI
I can restart SF, reboot my computer, same thing, it shows all the messages as per previous code !!!!??
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
That does seem strange. Please select Help | Send Layout so technical support can take a look. Please include a description of the issue you are experiencing and a link to the video (or this topic) when sending the Layout to technical support.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |