Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce
Take a look at the chart I just shated in v4 under AI pls.
The RC in your post on Tuesday, January 24, 2012 4:37:21 PM doesn't start plotting at the same value as price from the date input. I have your RC above in Red in the chart. As you can see it is scaled in with price but it doesn't start plotting from the same value as of 1/3/2011.
Also when I change the time frame from 1 min to 5, 10, 15 and so on in the Price and Volume indicators that are pinned the indicator no longer start from 1/3/2011 it becomes shorter and shorter. Try changing the time frame from 1 min to 5 and 15.
The yellow indicator has a 15 min time frame feeding it and as you can see it starts ploting from 7/14/2011
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Try replacing all six instances of Price. with PHwT. instead.
Then change both instances of:
AD = PHwT.Bar.Value(i)
DI = PHwT.Bar.Value(i)
To:
AD = PHwT.Bar.Value(i) / 2
DI = PHwT.Bar.Value(i) / 2
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
The Indicator below is set to start plotting from the closing price of 1/1/2011 and it's scaled wirth Price but when we have IPO's such as TNGO that weren't around back on 1/1/2011 it starts to plotting way above the price.
Can I do anyting to adjust this so if the stock hasn't been around on the start date it would start plotting from the closing price of the IPO date
thx
Sub New
AutoLoop = False
'# Cumulative
End Sub
Public Overrides Function Plot() As System.Single
'# StartDate = UserInput.Date = "01/01/2011"
Dim Trigger As Boolean = False
Dim sumWeight As Single = 1
Dim termRatio As Single = 21 / 22
Dim TR As Single = Price.Bar.HighValue(0) - Price.Bar.LowValue(0)
Dim ATR As Single = TR
sumWeight = sumWeight * termRatio + 1
Dim SumV As Single = Volume.Line.Value(0)
Dim AD As Single = Price.Bar.Value(0) / 2
Dim DI As Single = Price.Bar.Value(0) / 2
If Price.Bar.Count > 1 Then
For i As Integer = 1 To System.Math.Min(29, Price.Bar.Count - 1)
TR = System.Math.Max(Price.Bar.HighValue(i), _
Price.Bar.Value(i - 1)) - _
System.Math.Min(Price.Bar.LowValue(i), _
Price.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += Volume.Line.Value(i)
If Price.Bar.Value(i) - Price.Bar.Value(i - 1) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / (i + 1) Then
AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
If Volume.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
End If
If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / (i + 1) Then
DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
If Volume.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
End If
If Trigger = True Then
If Price.Bar.DateValue(i).Hour = 16 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(Price.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(Price.Bar.DateValue(i), 0)
End If
End If
Else
If Price.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = Price.Bar.Value(i)
DI = Price.Bar.Value(i)
End If
End If
Next
If Price.Bar.Count > 30 Then
For i As Integer = 30 To Price.Bar.Count - 1
TR = System.Math.Max(Price.Bar.HighValue(i), _
Price.Bar.Value(i - 1)) - _
System.Math.Min(Price.Bar.LowValue(i), _
Price.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += Volume.Line.Value(i) - Volume.Line.Value(i - 30)
If Price.Bar.Value(i) - Price.Bar.Value(i - 1) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
AD += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
End If
If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
DI += Price.Bar.Value(i) - Price.Bar.Value(i - 1)
End If
End If
If Trigger = True Then
If Price.Bar.DateValue(i).Hour = 16 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(Price.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(Price.Bar.DateValue(i), 0)
End If
End If
Else
If Price.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = Price.Bar.Value(i) / 2
DI = Price.Bar.Value(i) / 2
End If
End If
Next
End If
End If
end function
End Class
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Try changing the:
Trigger = True
AD = Price.Bar.Value(i)
DI = Price.Bar.Value(i)
To:
Trigger = True
AD = Price.Bar.Value(i) / 2
DI = Price.Bar.Value(i) / 2
So it matches the values at the top and bottom of your RealCode.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Thx
As you can see below I added the VS indicator in the RC and the only diff with the one above is that I muliply the Net Change in Price on the Acc and Dis days with Volume Surge.
This way if price gained 1 point today buy VS was 2 the indicator will add 2 points instead of 1 and if VS was 1 it will add 1 point and on the days that VS is less than 1 such as 0.75 it will add 0.75 * the net change.
I feel like my adjustments rae correct but it the indicator is not plotting it right
'# VS = indicator.VolumeSurge
'# StartDate = UserInput.Date = "01/01/2011"
Dim Trigger As Boolean = False
Dim sumWeight As Single = 1
Dim termRatio As Single = 21 / 22
Dim TR As Single = Price.Bar.HighValue(0) - Price.Bar.LowValue(0)
Dim ATR As Single = TR
sumWeight = sumWeight * termRatio + 1
Dim SumV As Single = Volume.Line.Value(0)
Dim AD As Single = Price.Bar.Value(0) / 2
Dim DI As Single = Price.Bar.Value(0) / 2
If Price.Bar.Count > 1 Then
For i As Integer = 1 To System.Math.Min(29, Price.Bar.Count - 1)
TR = System.Math.Max(Price.Bar.HighValue(i), _
Price.Bar.Value(i - 1)) - _
System.Math.Min(Price.Bar.LowValue(i), _
Price.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += Volume.Line.Value(i)
If Price.Bar.Value(i) - Price.Bar.Value(i - 1) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / (i + 1) Then
AD += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
If Volume.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
AD += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
End If
If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / (i + 1) Then
DI += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
If Volume.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
DI += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
End If
If Trigger = True Then
If Price.Bar.DateValue(i).Hour = 16 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(Price.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(Price.Bar.DateValue(i), 0)
End If
End If
Else
If Price.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = Price.Bar.Value(i) / 2
DI = Price.Bar.Value(i) / 2
End If
End If
Next
If Price.Bar.Count > 30 Then
For i As Integer = 30 To Price.Bar.Count - 1
TR = System.Math.Max(Price.Bar.HighValue(i), _
Price.Bar.Value(i - 1)) - _
System.Math.Min(Price.Bar.LowValue(i), _
Price.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += Volume.Line.Value(i) - Volume.Line.Value(i - 30)
If Price.Bar.Value(i) - Price.Bar.Value(i - 1) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
AD += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
AD += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
End If
If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
DI += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
DI += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * VS.Value
End If
End If
If Trigger = True Then
If Price.Bar.DateValue(i).Hour = 16 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(Price.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(Price.Bar.DateValue(i), 0)
End If
End If
Else
If Price.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = Price.Bar.Value(i) / 2
DI = Price.Bar.Value(i) / 2
End If
End If
Next
End If
End If
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
It looks fine to me when I plot it. What specifically makes you feel the indicator is not plotting correctly?
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
I shared a chart under AD Issue in V5
I still use V4 a lot so if you make any adjustments just keep that in mind pls
Take a look at HEES on 10/27/2011 pls
The green indicator is the original and the blue one is the one with the * VS.Value
HEES Price gained 1.34 on 10/27/2011 and the green indictaor added 1.34 as well going from 20.28 to 21.62 since it was an Accumulation day
As you can see the Vol Surge that day was 1.23 so noe the blue indicator needs to add (1.34 * 1.23)= 1.648
But it added 0.18 from 11.46 to 11.64.
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
OK. I see why it doesn't work and it is something you have run into before. I apologize for not noticing it earlier.
When you aren't using the AutoLoop, RealCode does not automatically interpolate the indicators for you. The indicators aren't synced. Your RealCode Indicator is using the same value for Volume Surge for every bar.
If your Volume Surge is just going to be using periods of 1 and 30 anyway, you could multiply the result by the following the first four times it appears in the RealCode:
(i + 1) * Volume.Line.Value(i) / SumV
And by the following the last four times it appears in the RealCode:
30 * Volume.Line.Value(i) / SumV
As we are already summing the most recent 30-Volumes to calculate SumV.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
No reason for the Aplogy. Without you there will be no SF.
Plug your adjustments in and take a look at AAPL pls on 10/19/2011
AAPL dropped 23.62 on 10/19 and the VS was 1.64
The Value of the blue indicator on 10/18/2011 was 75.17 so it needs to subtract (1.64 * 23.62)=38.73
But it dropps to a negative num.
Any reason why
thx
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
There are two reasons for the discrepency.
One is minor. The Volume Surge being created in our RealCode is Simple while the Volume Surge on the chart is Exponential.
One is major.
Volume.Line.Value(i) > 1.01 * SumV / 30
And:
Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01
Are both true. So DI is getting adjusted twice during this bar. You've pretty much done it this way since originally posting the indicator. As a result, I thought it was your intent.
If you only want DI adjusted once, you need to do some sort of Else If thing like:
If Price.Bar.Value(i - 1) - Price.Bar.Value(i) >= .33 * ATR Then
If Volume.Line.Value(i) > 1.01 * SumV / 30 Then
DI += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * _
30 * Volume.Line.Value(i) / SumV
Else If Volume.Line.Value(i - 1) / (SumV / 30) > .75 AndAlso _
Volume.Line.Value(i) > Volume.Line.Value(i - 1) * 1.01 Then
DI += (Price.Bar.Value(i) - Price.Bar.Value(i - 1)) * _
30 * Volume.Line.Value(i) / SumV
End If
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
Quick question
Why are you multipling 30 by Volume.Line.Value(i) Then / SumV to get today's Volume Surge
Shouldn't it be just Today's Volume / SumV
Volume.Line.Value(i) / SumV
Rather than
30 * Volume.Line.Value(i) / SumV
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
SumV isn't average volume. It is, as its name would suggest, the sum of volume over the most recent 30-bars.
We could convert it into an Average Volume by dividing it by 30 and then compare it to current volume to get our Volume Surge. It is mathematically the same to just compare 30 times the current volume to the sum however.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
kk
thx
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
I like to see if we can take this indicator one step further.
Below is the AD indicator that calculates on a 1 min time frame while plotting on a daily.
Is it possible to make an adjustment so that it will ignore the 1st minute of trading. I want to ignore 9:30-9:31 bc of gaps.
Pls take a look at CTCT's action today on a 1 min time frame. At the open we have huge gap on a major surge in volume but eversince stock has been rising on heavy volume on Up min's and low volume on Dn min's
So by avoiding the first min gaps I can see what's happening afterward
Let me know if possible
Many thx
Sub New
AutoLoop = False
'# Cumulative
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame.4
'# VBwT = chart.VolumeBarswTimeFrame.4
'# ATRPeriod = UserInput.Single = 390
'# VolPeriod = UserInput.Integer = 390
'# StartDate = UserInput.Date = #01/01/2011#
If PHwT.Bar.Count >= System.Math.Max(2, VolPeriod) Then
Dim Trigger As Boolean = False
Dim sumWeight As Single = 1
Dim termRatio As Single = (ATRPeriod - 1) / ATRPeriod
Dim TR As Single = PHwT.Bar.HighValue(0) - PHwT.Bar.LowValue(0)
Dim ATR As Single = TR
sumWeight = sumWeight * termRatio + 1
Dim SumV As Single = VBwT.Line.Value(0)
Dim AD As Single = PHwT.Bar.Value(0) / 2
Dim DI As Single = PHwT.Bar.Value(0) / 2
If PHwT.Bar.Count > 1 Then
For i As Integer = 1 To System.Math.Min(VolPeriod, PHwT.Bar.Count) - 1
TR = System.Math.Max(PHwT.Bar.HighValue(i), _
PHwT.Bar.Value(i - 1)) - _
System.Math.Min(PHwT.Bar.LowValue(i), _
PHwT.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += VBwT.Line.Value(i)
If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
If Trigger = True Then
If PHwT.Bar.DateValue(i).Hour = 16 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(PHwT.Bar.DateValue(i), 0)
End If
End If
Else
If PHwT.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = PHwT.Bar.Value(i) / 2
DI = PHwT.Bar.Value(i) / 2
End If
End If
Next
If PHwT.Bar.Count > VolPeriod Then
For i As Integer = VolPeriod To PHwT.Bar.Count - 1
TR = System.Math.Max(PHwT.Bar.HighValue(i), _
PHwT.Bar.Value(i - 1)) - _
System.Math.Min(PHwT.Bar.LowValue(i), _
PHwT.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += VBwT.Line.Value(i) - VBwT.Line.Value(i - VolPeriod)
If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / VolPeriod) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / VolPeriod) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
If Trigger = True Then
If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
i = PHwT.Bar.Count - 1 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), 0)
End If
End If
Else
If PHwT.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = PHwT.Bar.Value(i) / 2
DI = PHwT.Bar.Value(i) / 2
End If
End If
Next
End If
End If
End If
end function
End Class
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Maybe something like the following?
Sub New
AutoLoop = False
'# Cumulative
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame
'# VBwT = chart.VolumeBarswTimeFrame
'# ATRPeriod = UserInput.Single = 390
'# VolPeriod = UserInput.Integer = 390
'# StartDate = UserInput.Date = #01/01/2011#
If PHwT.Bar.Count >= System.Math.Max(2, VolPeriod) Then
Dim Trigger As Boolean = False
Dim sumWeight As Single = 1
Dim termRatio As Single = (ATRPeriod - 1) / ATRPeriod
Dim TR As Single = PHwT.Bar.HighValue(0) - PHwT.Bar.LowValue(0)
Dim ATR As Single = TR
sumWeight = sumWeight * termRatio + 1
Dim SumV As Single = VBwT.Line.Value(0)
Dim AD As Single = PHwT.Bar.Value(0) / 2
Dim DI As Single = PHwT.Bar.Value(0) / 2
If PHwT.Bar.Count > 1 Then
For i As Integer = 1 To System.Math.Min(VolPeriod, PHwT.Bar.Count) - 1
TR = System.Math.Max(PHwT.Bar.HighValue(i), _
PHwT.Bar.Value(i - 1)) - _
System.Math.Min(PHwT.Bar.LowValue(i), _
PHwT.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += VBwT.Line.Value(i)
If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
If PHwT.Bar.DateValue(i).DayOfYear = PHwT.Bar.DateValue(i - 1).DayOfYear Then
If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / (i + 1) Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / (i + 1)) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
End If
If Trigger = True Then
If PHwT.Bar.DateValue(i).Hour = 16 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(PHwT.Bar.DateValue(i), 0)
End If
End If
Else
If PHwT.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = PHwT.Bar.Value(i) / 2
DI = PHwT.Bar.Value(i) / 2
End If
End If
Next
If PHwT.Bar.Count > VolPeriod Then
For i As Integer = VolPeriod To PHwT.Bar.Count - 1
TR = System.Math.Max(PHwT.Bar.HighValue(i), _
PHwT.Bar.Value(i - 1)) - _
System.Math.Min(PHwT.Bar.LowValue(i), _
PHwT.Bar.Value(i - 1))
Dim Weight As Single = 1 / sumWeight
ATR = ATR * (1 - Weight) + Weight * TR
sumWeight = sumWeight * termRatio + 1
SumV += VBwT.Line.Value(i) - VBwT.Line.Value(i - VolPeriod)
If PHwT.Bar.DateValue(i).DayOfYear = PHwT.Bar.DateValue(i - 1).DayOfYear Then
If PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / VolPeriod) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
AD += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
If PHwT.Bar.Value(i - 1) - PHwT.Bar.Value(i) >= .33 * ATR Then
If VBwT.Line.Value(i) > 1.01 * SumV / VolPeriod Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
If VBwT.Line.Value(i - 1) / (SumV / VolPeriod) > .75 AndAlso _
VBwT.Line.Value(i) > VBwT.Line.Value(i - 1) * 1.01 Then
DI += PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)
End If
End If
End If
If Trigger = True Then
If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
i = PHwT.Bar.Count - 1 Then
If AD + DI <> 0 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), AD + DI)
Else
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), 0)
End If
End If
Else
If PHwT.Bar.DateValue(i) >= StartDate Then
Trigger = True
AD = PHwT.Bar.Value(i) / 2
DI = PHwT.Bar.Value(i) / 2
End If
End If
Next
End If
End If
End If
End Function
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce
The RC below is multiplying the net change by Volume and plots it as cumulative indicator
I calculate this in multiple time frames such as 1, 5, 30 min, 3 day and 1 week while the indicator is being plotted on a daily time frame.
Do you think I need to change anything else other than the Price and Volume with Time frame indicators that I drag and drop in here (First 2 lines)
Do I need to change that 16 number since the PHwt and VBwT are running on diff time frames?
'# PHwT = chart.PriceHistorywTimeFrame.8
'# VBwT = chart.VolumeBarswTimeFrame.8
If PHwT.Bar.Count >= 2 Then
Dim SumV As Single = 0
For i As Integer = 1 To PHwT.Bar.Count - 1
SumV += (PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)) * VBwT.Bar.Value(i)
If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
i = PHwT.Bar.Count - 1 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), SumV)
End If
Next
End If
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I can't think of anything you would need to change. The 16 is just checking to see if it is 4:00 PM ET.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Why does it take forever for it to plot.
Take a look at the chart I just shared under bb in v5
I even have the chart time frame set to 1 day not streaming and its been trying to plot it for 10 min's now and still no plot
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You need to do this as AutoLoop = False in the Class tab.
As you are doing it now, you are looping through the entire price history at each bar.
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame.4
'# VBwT = chart.VolumeBarswTimeFrame.4
If PHwT.Bar.Count >= 2 Then
Dim SumV As Single = 0
For i As Integer = 1 To PHwT.Bar.Count - 1
SumV += (PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)) * VBwT.Bar.Value(i)
If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
i = PHwT.Bar.Count - 1 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i)), SumV)
End If
Next
End If
End Function
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
Rather than multiplying by Volume I am trying to mulitiply by Volume Surge so I adjusted the block diagram that plots the Volume with diff Time Frame to plot the volume surge.
I have the chart shared in V5 under ADI VS
Now again it takes a long time to plot meanwhile it's the same RC. All I did was connecting the Volume block to a Simple Moving average and then taking the Ratio of the Voluem by the SMA
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I can't find your shared chart in StockFinder 5.
That said, the structure of the most recent RealCode assumes there is the same number of price bars as volume bars. For the most part, this should generally be a good assumption.
If Volume has the same number of bars, then Volume Surge is going to have fewer bars than Price History when using the same Time Frame and Length Limits however.
You can calculate this difference using something like (I have no idea what your variable name is for your Volume Surge indicator):
Dim j As Integer = PHwT.Bar.Count - VSwT.Line.Count
Then you could loop through Volume Surge instead of Price History. Whenever you are accessing:
VSwT.Line.Value(i)
You would need to be referencing:
PHwT.Bar.Value(i + j)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
I thk that's is the issue
There was a problem yesterday with sharing charts in V5
I don't understand all of the adjumtments you are talking about.
The looping thing is still confusing to me and do I add + j on all places we have PHwT.Bar.Value
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame.4
'# VSwT = chart.VolumeSurgewTimeFrame.4
If PHwT.Bar.Count >= 2 Then
Dim SumV As Single = 0
Dim j As Integer = PHwT.Bar.Count - VSwT.Line.Count
For i As Integer = 1 To PHwT.Bar.Count - 1
SumV += (PHwT.Bar.Value(i) - PHwT.Bar.Value(i - 1)) * VSwT.Bar.Value(i)
If PHwT.Bar.DateValue(i).Hour = 16 OrElse _
i = PHwT.Bar.Count - 1 Then
AddToOutput(EndOfDay(PHwT.Bar.DateValue(i + j)), SumV)
End If
Next
End If
end function
End Class
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I haven't tried it, but what I mean is something like the following:
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame.4
'# VSwT = chart.VolumeSurgewTimeFrame.4
If VSwT.Line.Count >= 2 Then
Dim SumV As Single = 0
Dim j As Integer = PHwT.Bar.Count - VSwT.Line.Count
For i As Integer = 1 To VSwT.Line.Count - 1
SumV += (PHwT.Bar.Value(i + j) - PHwT.Bar.Value(i + j - 1)) * VSwT.Line.Value(i)
If VSwT.Line.DateValue(i).Hour = 16 OrElse _
i = VSwT.Line.Count - 1 Then
AddToOutput(EndOfDay(VSwT.Line.DateValue(i)), SumV)
End If
Next
End If
End Function
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
No luck
still no plot. it keeps thinking
I just shared it under ADI VS
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I've altered the RealCode slightly. I had to select Apply, OK and restart StockFinder to get it to work.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
I need to give this a start date and I've made adj below but not plotting from the date I set it to
Am I missing something
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame.12
'# VSwT = chart.VolumeSurgewTimeFrame.9
'# StartDate = UserInput.Date = #01/01/2011#
If VSwT.Line.Count >= 2 Then
Dim SumV As Single = 0
Dim j As Integer = PHwT.Bar.Count - VSwT.Line.Count
For i As Integer = 1 To VSwT.Line.Count - 1
SumV += (PHwT.Bar.Value(i + j) - PHwT.Bar.Value(i + j - 1)) * VSwT.Line.Value(i)
If PHwT.Bar.DateValue(i) >= StartDate AndAlso _
VSwT.Line.DateValue(i).Hour = 16 OrElse _
i = VSwT.Line.Count - 1 Then
AddToOutput(EndOfDay(VSwT.Line.DateValue(i)), SumV)
End If
Next
End If
end function
End Class
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You are looping through Volume Surge. You need to check the date for Volume Surge, not Price History.
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
'# PHwT = chart.PriceHistorywTimeFrame.12
'# VSwT = chart.VolumeSurgewTimeFrame.9
'# StartDate = UserInput.Date = #01/01/2011#
If VSwT.Line.Count >= 2 Then
Dim SumV As Single = 0
Dim j As Integer = PHwT.Bar.Count - VSwT.Line.Count
For i As Integer = 1 To VSwT.Line.Count - 1
SumV += (PHwT.Bar.Value(i + j) - PHwT.Bar.Value(i + j - 1)) * VSwT.Line.Value(i)
If VSwT.Line.DateValue(i) >= StartDate AndAlso _
(VSwT.Line.DateValue(i).Hour = 16 OrElse _
i = VSwT.Line.Count - 1) Then
AddToOutput(EndOfDay(VSwT.Line.DateValue(i)), SumV)
End If
Next
End If
End Function
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
|
Guest-1 |