PDA

View Full Version : Please help to return value from functions in client script



nhasan
10-22-2013, 12:36 PM
Dear Team

I am trying to return values from private function in client side script.
But it's not working.
Here is the very simple code -

Public Sub main()

Dim res

res = DoSum( 4, 9 )

MsgBox res

End Sub

Private Function DoSum( N1, N2 )
Dim rSum
rSum = N1 + N2
return( rSum )
End Function

Can anyone please help me to find out the errors in this code?

b_morar
10-22-2013, 01:22 PM
Dir Sir,

In this way you can return a value.


Public Sub main()
MsgBox DoSum( 4, 9 )
End Sub
Public Function DoSum( N1, N2 )
Dim rSum
DoSum = N1 + N2
End Function

nhasan
10-23-2013, 11:15 AM
Thanks
I got it
It's classical VB6 style!

nhasan
10-27-2013, 07:07 AM
Hi Dear
Now we need Exponential Moving Average for last few candles(10-20)
The given function in knowledge base is
ExponentialMovingAverage(0,PRICE_CLOSE,10)

Where the candle on which it calculate is not included, seems it only calculate moving average of 10 candles from current one. How can I get moving average calculated on last few candles, say current -1, Current -2, current - 3 . . . etc.
Also we have only four Applied Price Price_High, Price_Low, Price_Open, Price_Close but don't find Price_Median in this list. How can I get MA on Price_Median?

Hassan-HS
10-27-2013, 09:53 AM
Dear Hassan,


ExponentialMovingAverageOnArray():Procedure that calculate ExponentialMovingAverage, based on custom prices array.


ExponentialMovingAverageOnArray will be available in VertexFX Client Terminal 10.2 that will be released very soon.


Note: Median_Price => (High+Low)/2

nhasan
10-30-2013, 08:56 AM
The given function on knowledge base for simple moving average just draw the indicator on chart and return it's name

SimpleMovingAverage(0,PRICE_CLOSE,10)

Is there any way to get MovingAverage value on current candle in current version of client terminal?

nhasan
10-30-2013, 08:58 AM
There are four types of moving average -

MODE_SMA
Simple averaging
MODE_EMA
Exponential averaging
MODE_SMMA
Smoothed averaging
MODE_LWMA
Linear-weighted averaging

Do we have equivalent function for all of them in current or next version of client terminal?

Hassan-HS
10-30-2013, 09:42 AM
Absolutely you can get any indicator value for any bar using ObjectSeriesGetValue (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2664)
function.

Sample:



Public Sub main()
Dim IndName
Dim BarsVal
Dim SMAlineResult
BarsVal = Bars(0)
IndName= SimpleMovingAverage(0,PRICE_CLOSE,10)

If ObjectSeriesGetValue(0, CSTR(IndName), CLNG(BarsVal), SMAlineResult) Then
MsgBox CStr(IndName & " value for the latest bar is : " & SMAlineResult)
End If

End Sub





MODE_SMA
Simple averaging
MODE_EMA
Exponential averaging
MODE_SMMA
Smoothed averaging
MODE_LWMA
Linear-weighted averaging

Do we have equivalent function for all of them in current or next version of client terminal?



Yes the following functions are exist in current version

SimpleMovingAverage (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1786)


ExponentialMovingAverage (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1784)


WeightedMovingAverage (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1792)


See also
(http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2567)

Note: And All XXXXOnArray functions will be available in next version.

Hassan-HS
01-09-2014, 09:40 AM
Dear Naem
Please update us if every thing is clear now or not, and let me know if you need any further assistance.