PDA

View Full Version : How to get the voluome

delhusagjon
12-03-2013, 05:46 AM
hello, please will someone help me? I have a very simple question. How do i get volume data in VTL (i need a similar function like Volume[] in mql4)? I have checked the forum, and the VTL Client Script page, but i didn't find the answer. Thank you!

Hassan-HS
12-03-2013, 09:36 AM
Dear Sir,

Unfortunately the volume value is not available right now in VertexFX, but it is already in the development queue to be available in next versions.

delhusagjon
12-06-2013, 06:21 AM
hello. i have an another problem that i can't figure out.
Here is my code:

Dim indKey
Dim i
Dim pricehigh
Public Sub Main()
Dim highArry()
redim highArry(bars(0))
for i = bars(0) to 1 step -1
pricehigh=GetHigh(0,CLNG(i))
'''
''
''
highArry(i)=pricehigh
next
End Sub

and here is the result:
293

Hassan-HS
12-06-2013, 07:16 AM
Dear sir,

The first index of arrays is 0, Ex: if you redim it with X "Redim High(X)" that's mean the first index is 0 and the last index is X.

Note:The first index of arrays after use one of copy functions (CopyHigh,CopyLow,CopyOpen,CopyClose) is one.

Dim indKey
Dim i
Dim pricehigh
Public Sub Main()
Dim highArry()
redim highArry(bars(0)-1)
for i = bars(0) to 1 step -1
pricehigh=GetHigh(0,CLNG(i))
highArry(i-1)=pricehigh
next
End Sub

delhusagjon
12-06-2013, 11:23 AM
hello, thank you for the quick reply. I have an another question, sorry if i am asking too much.
I tried to use the simplemovingaverageonarray function, but it gaves me an "out of bounds error".
Here is the code:

Dim indKey
Dim i
Dim pricehigh
Public Sub Main()
Dim highArry()
redim highArry(bars(0)-1)
for i = bars(0) to 1 step -1
pricehigh=GetHigh(0,CLNG(i))
highArry(i-1)=pricehigh
next

Dim arr()
SimpleMovingAverageOnArray highArry,14, arr

End Sub

Hassan-HS
12-06-2013, 11:48 AM
Dear Sir,

You can apply SimpleMovingAverage over HighArray in this way:

Public Sub Main()
Dim ary()
Dim result()
Dim Period
Period = 14
CopyHigh 0, 1, Bars (0), Ary
SimpleMovingAverageOnArray Ary,CInt (Period), Result
End Sub

delhusagjon
12-06-2013, 12:07 PM
Dear Sir,

You can apply SimpleMovingAverage over HighArray in this way:

Public Sub Main()
Dim ary()
Dim result()
Dim Period
Period = 14
CopyHigh 0, 1, Bars (0), Ary
SimpleMovingAverageOnArray Ary,CInt (Period), Result
End Sub

Thanks, i know this, but i want to make some changes on highArry() before i apply the movingaverage. So, the highArry is not the the same as CopyHigh 0, 1, Bars (0), Ary .

Is it possible?

Hassan-HS
12-06-2013, 12:27 PM
Dear Sir,

You are welcome any time bro, it's the 100% the same.

Ary(1) = GetHigh(0,1)
Ary(bars(0)) = GetHigh(0,Bars(0))

You can modify the array that's returned after using "CopyHigh 0, 1, Bars (0), Ary " as the following.

Ex:
Ary(10) = Ary(10) * 2 / Ary(9)

delhusagjon
12-06-2013, 09:08 PM
You are right! i have made something and it has worked with ver 10.1.18 but only on my computer, and it doesn't want to work with 10.2.3. It shows this: ActiveX component can't create object

Here is the code:

Dim indKey,indKey2,indKey3
Dim i,num1,num2,num3
Dim pricehigh
Dim pricelow
Dim tr,pdm,mdm
Dim resultValue
Dim resultValue2
Dim resultValue3
Dim div
Public Sub Main()
'Input parameters
DiPlusPeriod= 34
DiMinusPeriod= 34
'----------------
'variables
Dim tempbuffer()
Dim pdi()
Dim mdi()
Dim resPDI()
Dim resMDI()
ObjectDeleteAll 0

CopyHigh 0, 1, Bars (0), pdi
CopyHigh 0, 1, Bars (0), mdi
CopyHigh 0, 1, Bars (0), tempbuffer
for i = bars(0) to 2 step -1
pricehigh=GetHigh(0,CLNG(i))
pricelow=GetLow(0,CLNG(i))
pdm=0
mdm=0
if(pricehigh>GetHigh(0,CLNG(i)-1)) then
pdm=pricehigh-GetHigh(0,CLNG(i)-1)
end if
if(pricelow<GetLow(0,CLNG(i)-1)) then
mdm=GetLow(0,CLNG(i)-1)-pricelow
end if
if pdm<mdm then
pdm=0
else if mdm<pdm then
mdm=0
end if
end if
num1=MathAbs(pricehigh-pricelow)
num2=MathAbs(pricehigh-GetClose(0,CLNG(i)-1))
num3=MathAbs(pricelow-GetClose(0,CLNG(i)-1))
if (num1>num2) then
tr=num1
else
tr=num2
end if
if(num3>tr) then
tr=num3
end if
pdi(i-1)=pdm
mdi(i-1)=mdm
next

ExponentialMovingAverageOnArray pdi,cint(DiPlusPeriod), resPDI
ExponentialMovingAverageOnArray mdi,cint(DiMinusPeriod), resMDI
'
for i = bars(0) to 1 step -1
end if
next

for i = bars(0) to 2 step -1
div=MathAbs(pdi(i)+mdi(i))
if (div=0) then
tempbuffer(i)=tempbuffer(i-1)
else
tempbuffer(i)=MathAbs(pdi(i)-mdi(i))/div
end if
next

for i = bars(0) to 2 step -1
resPDI(i)=pdi(i-1)*100
resMDI(i)=mdi(i-1)*100
next

LineColor 0, indKey, RGBColor(32, 178, 170)
LineColor 0, indKey2, RGBColor(154, 205, 50)
LineColor 0, indKey3, RGBColor(245, 222, 179)
hline="hline"
ObjectSet 0, cstr(hline), 5, STYLE_DASH
End Sub

Public Sub OnTick(SymbolName)

'resultValue= rsDX(bars(0))
'resultValue2= rsDII(bars(0))
'resultValue3= rsMDII(bars(0))
'ObjectSeriesSetValue 0,CSTR(indKey),CLNG(bars(0)),CDBL(resultValue)
'ObjectSeriesSetValue 0,CSTR(indKey2),CLNG(bars(0)),CDBL(resultValue2)
'ObjectSeriesSetValue 0,CSTR(indKey3),CLNG(bars(0)),CDBL(resultValue3)
End Sub
Public Sub OnCalculate(symbol ,symPeriod, openVal , highVal , lowVal , closeVal )
'SetIndicatorData 0,CSTR(indKey),CDbl(highVal)
' SetIndicatorData 0,CSTR(indKey2),CDbl(highVal)
' SetIndicatorData 0,CSTR(indKey3),CDbl(highVal)
main
End Sub

Hassan-HS
12-07-2013, 06:40 AM
Dear Sir,

VertexFX Client Terminal 10.2.3 it's a beta a version for testing, you may face some issues. any way i will check this issue ASAP and update you, please stand by.

delhusagjon
12-09-2013, 09:21 AM
Alright thanks, it works with the older version. But i can't update this with each new bar. Currently it deletes the custom indicators when new bar comes and redraw it. But i want to use setindicator. How should i do that?

Hassan-HS
12-09-2013, 11:14 AM
Dear Sir,

The best way to update custom indicator value over the current bar is using SetIndicatorData (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2663) function

Dim indKey

Dim vchartId

Dim vchartName

Dim resultValue

Public Sub Main()

Dim highArry()

vchartId=chartId

vchartName=ChartSymbol(Clng(vchartId))

CopyHigh 0,1, bars(0),highArry

End Sub

Public Sub OnTick(SymbolName)
If SymbolName = ChartSymbol(0) then

ObjectSeriesGetValue 0,cstr(vchartName & ".High"),CLNG(bars(CLNG(vchartId))),resultValue

ObjectSeriesSetValue 0,CSTR(indKey),CLNG(bars(CLNG(vchartId))),CDBL(res ultValue)

End if

End Sub

Public Sub OnCalculate(symbol ,symPeriod, openVal , highVal , lowVal , closeVal )

SetIndicatorData 0,CSTR(indKey),CDbl(highVal)

End Sub