Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 4/15/2011(UTC) Posts: 10
|
Hello Evertbody does anybody have source code in c language or vb for the two functions HIGHEST AND LOWEST
I alredy implement stochastics using vba for any interseted here it is
For i = 1 To LastInt HHV = -200 LLV = 200
For k = i To Period + i - 1 If (Period + i - 1) <= LastInt Then If LLV > Array1(k) Then LLV = Array1(k) If HHV < Array1(k) Then HHV = Array1(k) End If Next k
If (Period + i - 1) <= LastInt Then S1(Period + i - 1) = Array1(Period + i - 1) - LLV If HHV - LLV = 0 Then S2(Period + i - 1) = 1 Else S2(Period + i - 1) = HHV - LLV End If S(Period + i - 1) = S1(Period + i - 1) / S2(Period + i - 1) End If Next i
Tahnk you
|
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,112 Location: Perth, Western Australia
Was thanked: 17 time(s) in 17 post(s)
|
If you used the proper code tags, your post would have been formatted properly.
Why are you recreating the wheel? The Stoch() function is already implemented in MS.
wabbit [:D]
|
|
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 4/15/2011(UTC) Posts: 10
|
Hello wabbit, MS cant do itration however the code for stochastics is as follow with remarks
Ode In Excel VBA
Dim LastInt As Integer LastInt = CInt(UBound(Array1())) 'Data array Dim HHV As Double Dim LLV As Double Dim Sum As Double Sum = 0 ReDim S(1 To LastInt) As Double 'ARRAY OF STOCHASTICS ReDim S1(1 To LastInt) As Double ReDim S2(1 To LastInt) As Double
For i = 1 To LastInt HHV = -200 LLV = 200
For k = i To Period + i - 1
If (Period + i - 1) <= LastInt Then
If LLV > Array1(k) Then LLV = Array1(k) 'find the lowest low value in period If HHV < Array1(k) Then HHV = Array1(k) 'find the highest high value in period
End If Next k
If (Period + i - 1) <= LastInt Then
S1(Period + i - 1) = Array1(Period + i - 1) - LLV If HHV - LLV = 0 Then S2(Period + i - 1) = 1 Else S2(Period + i - 1) = HHV - LLV End If S(Period + i - 1) = S1(Period + i - 1) / S2(Period + i - 1)
End If Next i
|
|
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 4/15/2011(UTC) Posts: 10
|
The code is not posted as i pasted it this statement is missed If HHV < Array1(k) Then HHV = Array1(k) 'find the highest high value in period
I did write the highest and lowest codes
thank you wabbit
|
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,112 Location: Perth, Western Australia
Was thanked: 17 time(s) in 17 post(s)
|
Use the proper code tags to post code.
wabbit [:D]
|
|
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,112 Location: Perth, Western Australia
Was thanked: 17 time(s) in 17 post(s)
|
How do you think your code is different to the MS Stoch() function? Or even the reconstruction of the Stoch() function which is shown in the MS User Manual?
wabbit [:D]
|
|
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 5/15/2013(UTC) Posts: 4
|
Hi, Have a query. How do you run your code written in VBA into metastock. I mean how does Metastock understands this code. Sorry, If I am asking very basic question. Thanks
|
|
|
|
|
|
| Users browsing this topic |
|
Guest (Hidden)
|
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.