logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ABDULLAH7044  
#1 Posted : Saturday, April 7, 2012 1:48:41 AM(UTC)
ABDULLAH7044

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
wabbit  
#2 Posted : Saturday, April 7, 2012 8:39:59 PM(UTC)
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)
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]

ABDULLAH7044  
#3 Posted : Sunday, April 8, 2012 8:07:28 AM(UTC)
ABDULLAH7044

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
ABDULLAH7044  
#4 Posted : Sunday, April 8, 2012 8:14:06 AM(UTC)
ABDULLAH7044

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

wabbit  
#5 Posted : Sunday, April 8, 2012 5:50:49 PM(UTC)
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]
wabbit  
#6 Posted : Sunday, April 8, 2012 10:40:51 PM(UTC)
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)
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]

devesh2  
#7 Posted : Monday, July 1, 2013 5:33:23 AM(UTC)
devesh2

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.