Results 1 to 4 of 4
  1. #1
    Senior Member
    Join Date
    May 2014
    Posts
    145

    Default Which Event handler fires first - OnCalculate or OnTick

    Hello,

    As the Heading suggests, I would like to know

    When a new candle is formed, which event fires first, The OnCalculate() or OnTick()

    My checks suggests OnCalculate triggers first and then the Ontick, but I am not sure about it.

    Please help

    Thanks

  2. #2
    Administrator Hassan-HS's Avatar
    Join Date
    Jun 2013
    Posts
    795

    Default

    Hello Edakad,

    The OnTick event is fire before the OnCalculate event.

  3. #3
    Senior Member
    Join Date
    May 2014
    Posts
    145

    Default

    Hello Hassan

    I use this simple code to check which one fires first and I think it shows the opposite order, first OnCalculate and then Ontick when newBar is formed.

    Please avoid the very fist message u get when the vtl is attached to chart, thereafter it work when new candle is formed.
    Code:
    dim barTime
    
    function newBar()
        Dim bTime
        bTime = GetTime( 0, Bars(0) - 1 )
        IF CDATE(barTime) < CDATE(bTime)  Then 
            barTime = bTime
            NewBar = True
            Exit Function
       End If
       
       NewBar = False
    
    end function
    
    Public Sub main()
    
    
    
    End Sub
    
    Public Sub OnTick(symbolName)
    if symBolName = chartSymbol() then
        if newBar() Then 
            msgBox "OnTick"
        end if
    end if
    End Sub
    
    
    Public Sub OnCalculate(symbol, symbolPeriod, openVal, highVal, lowVal, closeVal)
    if symbol = chartSymbol() then 
        msgbox "OnCalculate" 
    end if
    End Sub
    Last edited by Edakad; 06-05-2014 at 07:56 AM.

  4. #4
    Administrator Hassan-HS's Avatar
    Join Date
    Jun 2013
    Posts
    795

    Default

    Hello,


    You don't need to use this condition,
    if newBar() Then
    .


    The ontick() raise with the current price in the first second of the new bar to draw it to the chart.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help neede on OnCalculate method
    By Edakad in forum VertexFX API/VTL Forum
    Replies: 7
    Last Post: 05-24-2014, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •