Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

"daysPerBar" function - Is there one? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
joelfour
Posted : Thursday, December 28, 2006 1:24:17 PM
Registered User
Joined: 7/30/2005
Posts: 7
This is the pertinent portion of an e-mail I sent to Worden Bros, and was instructed to post here for discussion and comment:

Question: I now know why you are enthusiastic about snap sheets; they are addictive to work with. I am trying to build a more complicated widget and I am stuck; hoping now you can help:

I have proceeded from your million dollar barchart to build different versions of barcharts that construct bars based not on days, but other critereon, and therefore each bar encompasses a variable number of days. I had the idea that it might be useful to plot an indicator displaying the number of days per bar over time, and depending on what it looks like (I haven't seen it yet) creating a moving average to begin with, or possibly applying other indicators to that data stream (each data bar should carry with it a value for # of days) so you could apply technical analysis tools to that data stream.

The problem, which is preventing me from sleeping, is that I can't seem to pull out the number of days per bar. All the blocks I have tried only seem to come up with a price value, or total number of days from the start of the chart, or if I set up two date value pointers as timeframe limiters, it only reads the number of bars, not the number of days within each bar.

Is there something like a "datespan" function that returns the number of days per bar, or for a certain bracket of start and end dates.

Hope you can help, and thanks for bringing this product to us.

StockGuy
Posted : Friday, December 29, 2006 9:32:50 AM

Administration

Joined: 9/30/2004
Posts: 9,187
We don't have a block to provide this information.
Kuf
Posted : Friday, December 29, 2006 9:37:06 AM


Administration

Joined: 9/18/2004
Posts: 3,522
You could write your own code block for this though.

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
Kuf
Posted : Friday, December 29, 2006 9:50:50 AM


Administration

Joined: 9/18/2004
Posts: 3,522
I took the liberty to write the code for you. Make a new code block and select Bar to Line. Name it DaysPerBar. Pase the code where it says '*** Your Code Here ***. You might have to add the carridge returns when you pase it. Just make it match the lines below and hit save. Add it to a new plot and hook it up to your bars.





For i As Integer = 1 To Me.input.Count -1
Dim date1 As Date = MyBase.input.datevalue(i-1)
Dim date2 As Date = MyBase.input.datevalue(i)
Dim diff As Integer = Microsoft.VisualBasic.DateAndTime.DateDiff("d",date1,date2)

MyBase.CodeBlock.AddToOutput(MyBase.input.DateValue(i),diff)

Next


Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
joelfour
Posted : Friday, December 29, 2006 3:35:35 PM
Registered User
Joined: 7/30/2005
Posts: 7
Thank you so much; I'll give it a try.
I used to be an excellent programmer - I've built a computer from interpreter to machine language on up; but that was a long time ago and this code language so far is incomprehensible to me!

Thanks again - I'll post back if having trouble ....

joelfour
Posted : Saturday, December 30, 2006 7:48:06 PM
Registered User
Joined: 7/30/2005
Posts: 7
Ken -
I copied the codeblock that you wrote and it works!

Thanks so much.

I'm impressed that you did it so quickly - I don't understand the logic of the language - is there a basic instruction manual to introduce the concepts?

Thanks again.

Joel
Craig_S
Posted : Saturday, December 30, 2006 8:56:40 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
It is just .Net code. You can find a million resources on the net or in a Barnes and Noble.

- Craig
Here to Help!
joelfour
Posted : Sunday, December 31, 2006 4:32:15 PM
Registered User
Joined: 7/30/2005
Posts: 7
Thanks,
I guess i'm behind the times. I thought Pascal and C were the modern languages!
joelfour
Posted : Sunday, December 31, 2006 4:47:37 PM
Registered User
Joined: 7/30/2005
Posts: 7
I'm just realizing that there are 3 of you who have been helping me - thanks to all of you.

I've got another question. I've got 2 curves of fundamental data analysis plotted on snap sheets. One is the Relative Strength 1-year versus S&P 500; the other is the Price to Sales Ratio.

I want to create a plot of the Division: (Relative Strength 1-year S&P500) / (Price-Sales Ratio).

It seems that the Divide block does not accept Date-Number inputs. If I try to take the last value, it works; but the information is erroneous, as the value applies only to the most recent date; but I want a value for each date of the plot.

Would you be able to help with this one? I suppose the general question is how to divide one date-number sequence by another.

Hope you can help.
Craig_S
Posted : Tuesday, January 2, 2007 8:00:46 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
You want to use the Ratio block. You can also add the Compare 2 Lines plot from the Utilities folder in the Web Library.

- Craig
Here to Help!
joelfour
Posted : Tuesday, January 2, 2007 12:42:25 PM
Registered User
Joined: 7/30/2005
Posts: 7
thanks - I'll post back if successful.
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.