Client Terminal Events
Posted by Mohammad Rahhal, Last modified by Salameh Abu Hashish on 20 February 2019 10:14 AM


After the client loads a script to the chart and starts the process of initialization, it will be processed by OnInit().

Public Sub OnInit( )


DeInit( )

The DeInit event is generated when the script is stopped or a new script is attached to chart.

Public Sub DeInit( )


OnTick( symboolName ) 

The OnTick event is generated whenever there is a new tick.

Public Sub OnTick(symbolName)


OnCalculate( symbolName, symPeriod, OpenVal, highVal, lowVal, closeVal )

This event is generated when a new candle arrives.

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


OnTimer( )

This function is called when enabling the timer using EnableTimer() and set its IntervalTimer.

Public Sub OnTimer( )


OnOrderTrade( )

This event rises after taking a new order and receiving its result from the server.

Public Sub OnOrderTrade (actionType ,orderID , returnValue)


Parameters Name Description
actionType The value can be one of ENUM_TRADE_ACTION_TYPE
orderID ID of order
returnValue The value can be one of ENUM_TRADE_RESULT

Return Value

Returns order lots as a double value.


OnPositionTrade( )

This event rises after taking a new position and receiving its result from the server.

Public Sub OnPositionTrade (actionType ,ticketID)


Parameters Name Description
actionType The value can be one of ENUM_TRADE_ACTION_TYPE
TicketID Ticket ID



This event rises after calling RequestManageOrders() method and receiving its result from the server.

Public Sub OnManageOrdersReceived (manageOrders)


Parameters Name Description
manageOrders ManageOrders object


 Public Sub main()

  If AccountInfoInteger(ACCOUNT_LOGIN) Then

     If RequestManageOrders (3666) Then

    AlertMessage "The Request has been sent to the server to get all manage orders related to ticket number 3666 "


    AlertMessage  ErrorDescription(GetLastError())

   End If

  End If

 End Sub

'This event raised when calling RequestManageOrders method successfully

 Public Sub OnManageOrdersReceived(manageOrders)

    Dim i

' Receiving Manage Order related to Ticket 3666

  For i=1 To manageOrders.Count()

   AlertMessage CSTR(manageOrders.Orders(i))


 End Sub



This event rises after calling GetAccountHistory() method and receiving its result from the server.

Public Sub AccountHistoryReceived (AccountHistoryBuffer)


Parameters Name Description
AccountHistoryBuffer Trade history collection, which contain CAccountHistory


 Public Sub main()

    GetAccountHistory "", ""

 End Sub


 Public sub AccountHistoryReceived (AccountHistoryBuffer)

    AlertMessage "Count” & AccountHistoryBuffer.Count

    AlertMessage "Ticket ID” & AccountHistoryBuffer.HistoryRow (1).Ticket

    AlertMessage "HisTime” & AccountHistoryBuffer.HistoryRow(1).HisTime

    AlertMessage "SymbolID” & AccountHistoryBuffer.HistoryRow (1).SymbolID

    AlertMessage "Lots” & AccountHistoryBuffer.HistoryRow (1).Lots

    AlertMessage "BuySell” & AccountHistoryBuffer.HistoryRow (1).BuySell

 End Sub



This event rises after request the prices or time by using HighPrices, LowPrices, ClosePricesOpenPrices and DataTimes
from the server.

Public Sub PriceLoaded (TimeArr As Variant, OpenArr As Variant, HighArr As Variant, LowArr As Variant, closeArr As Variant)


Parameters Name Description
TimeArr Array which contain the time values from server.
OpenArr Array which contain the open prices value from server .
HighArr Array which contain the high prices value from server.
LowArr Array which contain the low prices value from server. 
closeArr Array which contain the close prices value from server. 


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