Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 7/26/2006 Posts: 23
|
Bruce,
In the following code in order to achieve what I want, I need the variable 'countconst' to retain its value from bar to bar. As it is, for each bar,' count' and 'countconst' assume the value of '0' and unless the middle set of if statements are true, keeps the value of zero thru the entire code. The code is
'#wickpercenttop = userinput.single = 2.0
'#wickpercentbottom = userinput.single = 10.0
'#BenchmarkSize = userinput.single = 1.5
'#Retracement = userinput.single = 0.5
Static atr As Single = 0
Dim wickbottom As Single
Dim TH As Single
Dim TL As Single
Dim wicktop As Single
Dim countconst As Single
Dim count As Single
wicktop = wickpercenttop / 100
wickbottom = wickpercentbottom / 100
atr = 0
For i As Integer = 1 To 5
th = system.Math.Max(price.high(i), price.Close(i + 1))
tl = system.Math.Min(price.low(i), price.Close(i + 1))
atr += th - tl
Next i
atr = atr / 5
If price.Close >= price.Open AndAlso _
price.TradeRange >= Benchmarksize * ATR AndAlso _
price.Open - price.Low < wickbottom * price.TradeRange AndAlso _
price.High - price.Close < wicktop * price.TradeRange Then
count = currentindex
If count = currentindex Then countconst = currentindex
End If
If count <= currentindex Then
count = currentindex - count
End If
plot = countconst
Eliezer
|
|
Registered User Joined: 9/13/2008 Posts: 99
|
Eliezer,
Currently countconst is declared as:
Dim countconst As Single
perhaps you want to declare it as:
Static counconst As Single
to ensure the value does not go out of scope at the end of the bar?
_mad
|
|
Registered User Joined: 7/26/2006 Posts: 23
|
Thank you mad, that is the answer!! I figured it out after I posted the question. Bruce, if you read this I would like to thank you for your past and future help.
Eliezer
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
edrichmond,
You're welcome. Our pleasure.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |