Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Specific Date for indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
tradehawk
Posted : Tuesday, June 8, 2010 8:50:05 AM
Registered User
Joined: 4/19/2009
Posts: 18

i currently have an indicator set up to find % return from prior date to get quarterly return for example:

Dim Ref As Single
For i As Integer = 0 To 90
 If price.datevalue(i).year = 2010 And price.datevalue(i).month = 4 And price.datevalue(i).day = 1 Then
  Ref = price.Close(i)
 End If
Next

plot = ((price.close - Ref) / Ref) * 100

my question is there a way to access a specific date in the code without looping to find it 

Tim

Kuf
Posted : Monday, June 14, 2010 11:46:50 AM


Administration

Joined: 9/18/2004
Posts: 3,522
Yes.

Try this:

static ref as single
if isFirstBar then
   ref = price.ValueForDate("4/1/2010 4:00 PM")
end if

if ref > 0 then
   plot = ((price.close - ref) / ref) * 100
end if

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
tradehawk
Posted : Wednesday, June 16, 2010 8:36:21 PM
Registered User
Joined: 4/19/2009
Posts: 18
perfect,

thanks Ken

Tim
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.