PDA

View Full Version : VTL Functions



AmitSharma
02-14-2014, 08:21 AM
Hi Sir,

I have convert following function in vtl. Please verify it.

MQL Function:
1.
double MACD = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow,
MACD_Signal, PRICE_CLOSE, MODE_MAIN, i);

MACD_Data =CSTR(MACD(0,CINT(MACD_Fast), CINT(MACD_Slow),CINT(MACD_Signal)))

BarsVal = Bars(0) - i
MACDVALUE = ObjectSeriesGetValue(0, CSTR(MACD_Data), CLNG(BarsVal), MACDValRes)

2. double MACD_Sig = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow,
MACD_Signal, PRICE_CLOSE, MODE_SIGNAL, i);

MACD_Data =CSTR(MACD(0,CINT(MACD_Fast), CINT(MACD_Slow),CINT(MACD_Signal)))

BarsVal = Bars(0) - i
MACDVALUE = ObjectSeriesGetValue(0, CSTR(MACD_Data), CLNG(BarsVal), MACDValRes)


I have following doubt...

How to use "PRICE_CLOSE" Enum and MODE_SIGNAL and i value in VTL?

Thank you

Hassan-HS
02-14-2014, 08:59 AM
Hello Amit,




You can send the close prices to this procedure (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/3487) which is calculate MACD based on your custom prices.
Also its return MODE_SIGNAL results values in byref function


Sample:




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

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

End Sub

bharat.ecb
02-14-2014, 02:38 PM
Hi Sir,

How can i use these ENUM in vtl? Can you give me sample?

MODE_MAIN 0 Base indicator line.
MODE_SIGNAL 1 Signal line.

Thank you

Hassan-HS
02-14-2014, 02:58 PM
Hello,


in vtl there is no need to use this enums cause the two results return to you..



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



Result: this array represent the base indicator line


Signal : this array represent the signal line



So using the previous sample you can print :




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


OR



MsgBox "The signal value of the record 50 : " & Signal(50)

bharat.ecb
03-10-2014, 05:33 PM
Hi dear,

1. here we are passing different array like high,low and close of array

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

I want to just confirm one think

I need Price_Close array value.

so i need to send one array. I have to pass blank array for other value like HighArry and LowArry.

Is it way correct to calculate value ?

Thank you

Hassan-HS
03-10-2014, 09:03 PM
Hi,
I will update you soon please standby....

Hassan-HS
03-11-2014, 02:48 PM
Hello,,,


The 4 array sources is required to calculate the MACD, I think that you have to ask TA expert....