| thnkbigr |
|
Member, Platinum User
|
| Registered User |
|
|
|
|
| Unsure |
|
| Friday, March 31, 2006 |
| Friday, September 10, 2010 7:57:00 PM |
1,886 [0.91% of all post / 1.16 posts per day] |
|
I see what you did
Sum(1) adds all of the differences from the every bars high to the Lin Reg and then LTAD(0) plots some multiple of the avg diff
Sum(1) += System.Math.Abs(Price.High - EndPoint(0))
LRAD(0) = Width * Sum(1) / Count(0)
I'll play with it
thx
|
Yes
The EndPoint(1) is plotting the Linear Reg which is the middle line
SD(1) is the standard deviation from the mean during the pull back. I like to change that to measure the standard deviation of the high's from the Linear Reg rather than the mean.
This indicator plots the Lin Reg and I plot the SD(1) by plotting the Open value of this indicator then I Plot the Upper and Lower channels as a separate indicator at 1, 1.5 and 2 SD from the EndPoint(1) which the Lin Reg.
|
Bruce,
This is the Auto LR that plots the upper and lower channel at a certain Standard deviation from the mean.
Rather than calculating the SD from the mean how can I adjust this so that it calculates how far the High of each bar deviates from the middle line and plot the upper and lower ch using that SD?
'# Width = UserInput.Single = 1
Static Count(5) As Single
Static Sum(3) As Single
Static Slope(1) As Single
Static SD(1) As Single
Static EndPoint(1) As Single
Static LowSince(1) As Single
If isFirstBar Then
Count(0) = Single.NaN
Count(1) = Single.NaN
Count(2) = 0
Count(3) = Single.NaN
Sum(0) = Single.NaN
Sum(1) = Single.NaN
Sum(2) = Single.NaN
LowSince(0) = Single.NaN
LowSince(1) = Single.NaN
Slope(1) = Single.NaN
SD(1) = Single.NaN
EndPoint(1) = Single.NaN
Else If Price.High > Price.MaxHigh(62, 1) Then
Count(0) = 1
Count(1) = 1
Count(2) = 1
Count(3) = 1
Sum(0) = Price.High
Sum(1) = Price.High ^ 2
Sum(2) = Price.High
LowSince(0) = Price.Last
LowSince(1) = Price.Last
Else
Count(0) += 1
Sum(0) += Price.High
Sum(1) += Price.High ^ 2
Sum(2) += Count(0) * Price.High
LowSince(0) = System.Math.Min(LowSince(0), Price.Low)
LowSince(1) = System.Math.Min(LowSince(1), Price.Last)
End If
If Count(0) >= 2 Then
Slope(0) = (Sum(2) - ((Count(0) + 1) / 2 * Sum(0))) / (Count(0) * (Count(0) ^ 2 - 1) / 12)
SD(0) = Width * (((Sum(1) - Sum(0) ^ 2 / Count(0)) / Count(0)) ^ .5)
EndPoint(0) = Sum(0) / Count(0) + (Count(0) - 1) * Slope(0) / 2
If Price.Low = LowSince(0) OrElse _
Price.Last = LowSince(1) Then
Count(1) = 0
Count(2) = 0
Count(4) = 0
Count(5) = 0
Count(3) = Count(0)
Slope(1) = Slope(0)
SD(1) = SD(0)
EndPoint(1) = EndPoint(0)
Else
EndPoint(1) += Slope(1)
End If
Else
Slope(0) = 0
SD(0) = 0
EndPoint(0) = Price.High
Slope(1) = 0
SD(1) = 0
EndPoint(1) = Price.High
End If
If Count(0) > -1 Then
OpenValue = SD(1)
HighValue = Count(0)
LowValue = Slope(1) / (Sum(0) / Count(0))
Plot = EndPoint(1)
Else
OpenValue = Single.NaN
HighValue = Single.NaN
LowValue = Single.NaN
Plot = Single.NaN
End If
|
If I am trading through Intractive Brokers and I am using let say the 50 day MA as my stop loss. As the 50 day changes does the stop in Intractive Brokers change as well automatically?
|
|
thx
|
Bruce,
I get math is not declared
Also I am in V4 i don't know if that makes a difference
|
Bruce,
Here is a quick 2 min video on the issue with the Volatility stop being plotted on an indicator.
The RealCode is from your post above on Monday, July 13, 2009 12:55:03 PM
let mw know
thx
http://www.screencast.com/t/YzM5NzdmNT
|
|
Bruce,
On your Thursday, July 22, 2010 10:06:24 AM you said
I don't know if you would need to just multiply the results by the number of stocks in the WatchList or multiply the results by the number of stocks in the WatchList and then divide by the number of open positions to get the old number (but suspect the second)
From my testing it seems to be the later as well. We need to multiply by the Num of the stocks in the watchlist and then divide that by the num of the open positions.
Here is a video
http://www.screencast.com/t/NDk5NDE2Y
and I shared my Layout under My Equity Line in V4
Here is what I did
WEL is the Watchlist Equity Line from the backscanner
IC is a Custom Index on a Rule Price > 0 to plot teh Count of teh stocks in the watchlist
CT is Num of open positions from the backscanner
So this plot the Average Point Gain/Loss of the stocks that are in trade. All trades are doen at teh next days open.
'# WEL = indicator.WatchListEquityLine
'# IC = indicator.Index-MyRuleCount
'# CT = indicator.CountTrades
Static AA As Single
If isFirstBar Then
AA = 0
Else If WEL.Value(1) = 100 AndAlso _
CT.Value > 0 Then
AA = ((WEL.Value - 100) * IC.Value) / CT.Value
Else If CT.Value(1) = 0 AndAlso _
CT.Value > 1 Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value) / CT.Value
Else If CT.Value > 0 AndAlso _
CT.Value(1) > 0 AndAlso _
CT.Value >= CT.Value(1) Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value(1)) / CT.Value
Else If CT.Value > 0 AndAlso _
CT.Value(1) > 0 AndAlso _
CT.Value < CT.Value(1) Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value(1)) / CT.Value(1)
Else If CT.Value = 0 AndAlso _
CT.Value(1) > 0 Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value(1)) / CT.Value(1)
Else If CT.Value(1) = 0 Then
AA = 0
End If
Plot = AA
And below should plot the correct equity line
PC is teh above indicator
'# PC = indicator.AvgPChofStocksinTrade.2.3
'# CT = indicator.CountTrades
Static AA(1) As Single
If isFirstBar Then
AA(0) = 100 + PC.Value
Else If CT.Value > 0 Then
AA(1) = AA(0)
AA(0) = AA(1) + PC.Value
Else If CT.Value(1) > 0 Then
AA(1) = AA(0)
AA(0) = AA(1) + PC.Value
End If
Plot = AA(0)
Please let me know if I did everything correctly
thx
|
|
thx
|
thx
and if I need to screen for IPO's 3 and 4 days ago what do I need to adjust
Sub New
AutoLoop = False
End Sub
Public Overrides Sub CallUserCode()
If Price.Bar.Count = 2 OrElse Price.Bar.Count = 1 Then
AddToOutput(Price.Bar.DateValue(Price.Bar.Count - 1), True)
Else
AddToOutput(Price.Bar.DateValue(Price.Bar.Count - 1), False)
End If
End Sub
End Class
|
|