Posted by Mohammad Rahhal, Last modified by Mohammad Ghawanmeh on 28 July 2015 10:49 AM



Public Sub MACDOnArray(ByVal OpenAry As Variant, ByVal HighAry As Variant, ByVal LowAry As Variant, ByVal CloseAry As VariantByVal SignalPeriod As Integer, ByVal FastEMA As Integer, ByVal SlowEMA As Integer, ByRef Result As Variant, ByRef Signal As Variant)

Procedure that calculate MACD, based on custom array, and the result passed by result parameter as array, each index of the result array represent indicator value corresponds to that index of the source array.


Parameter  Description 
OpenAry The open array 
HighAry The High array 
LowAry The low array 
CloseAry The close array 
SignalPeriod SignalPeriod as integer
FastEMA FastEMA as integer
SlowEMA SlowEMA as integer
Result The Result Array
Signal Byref parameter, return signal value

Return value

Returns a double value.


Public Sub main()

        Dim HighAry ()

        Dim LowAry ()

        Dim OpenAry ()

        Dim CloseAry ()

        Dim result()

        Dim SignalPeriod

        Dim FastEMA

        Dim SlowEMA

        Dim Signal

        SignalPeriod = 9

        FastEMA = 12

        SlowEMA = 26

        CopyHigh 0, 1, Bars (0), HighAry

        CopyLow 0, 1, Bars (0), LowAry

        CopyOpen 0, 1, Bars (0), OpenAry

        CopyClose 0, 1, Bars (0), CloseAry

        MACDOnArray OpenAry, HighAry, LowAry, CloseAry, CInt (SignalPeriod), CInt (FastEMA), CInt (SlowEMA), Result, Signal

        AlertMessage "The indicator value of the record 50 : " & Result(50)

End Sub


See Also

Back to VTL Client Script Index

(0 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name:
CAPTCHA Verification 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Help Desk Software by Hybrid Solutions