Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Jun 2015
    Posts
    19

    Exclamation How to take current spread in OnTick event ?

    I am trying to detect the current spread in the OnTick event.
    The problem I am facing is SymbolInfoInteger() returns TRUE (success), but
    the value of spread is NULL.


    Sample code follows :




    Public Sub OnTick(symbolName)


    If( symbolName <> ChartSymbol(0) ) Then Exit Sub
    Dim spread
    If( SymbolInfoInteger(ChartSymbol(0), SYMBOL_SPREAD, spread) ) Then
    ' Display the spread in message box
    MsgBox "spread = " & spread
    Else
    ' SymbolInfoInteger failed.
    MsgBox "Could not fetch spread"
    End If


    End Sub

  2. #2
    Administrator Rawan-HS's Avatar
    Join Date
    Apr 2015
    Posts
    410

    Default

    Dear Sir,


    Thanks for contacting us.


    When the retrieved value of the spread is null that means the system administrator set the spread to be “Source ” so the spread value calculated from the Data Feed side.


    But you can get the spread manually by calculate the difference between ask and bid prices on your market watch.


    Check this code

    Code:
    Public Sub OnTick(symbolName)
    
    
    If( symbolName <> ChartSymbol(0) ) Then Exit Sub
    Dim Spread 
    Dim Bid 
    Dim Ask
    Dim Result 
    If(SymbolInfoInteger(ChartSymbol(0), SYMBOL_SPREAD, spread)) Then
        If not ISNUMERIC(spread) then 
            SymbolInfoDouble ChartSymbol(0) , SYMBOL_BID , Bid 
            SymbolInfoDouble ChartSymbol(0) , SYMBOL_ASK , ask
            result = ask-bid 
            AlertMessage result 
        else  
             AlertMessage result 
         end if 
    Else
            AlertMessage "Could not fetch spread"
    End If 
    
    
    
    
    End Sub
    Last edited by Hassan-HS; 07-12-2015 at 11:08 AM.

  3. #3
    Junior Member
    Join Date
    Jun 2015
    Posts
    19

    Default

    If I calculate the spread as Ask - Bid, then how to convert this value into points ? I could not find any value in ENUM_SYMBOL_INFO_DOUBLE or ENUM_SYMBOL_INFO_INTEGER that specifies the number of digits or point.

  4. #4
    Administrator Rawan-HS's Avatar
    Join Date
    Apr 2015
    Posts
    410

    Default

    Dear NCD ,


    you can calculate it by division the of result of Ask - bid by the numbers of pip

    check this code and tell me if you need any things

    Code:
     Public Sub OnTick(symbolName)    
      If( symbolName <> ChartSymbol(0) ) Then Exit Sub
           Dim Spread 
           Dim Bid 
           Dim Ask
           Dim pipLoc
           Dim PiP
           Dim Result 
             If(SymbolInfoInteger(ChartSymbol(0), SYMBOL_SPREAD, spread)) Then
              If not ISNUMERIC(spread) then 
              SymbolInfoInteger ChartSymbol(0), SYMBOL_PIP_LOCATION, pipLoc 
              SymbolInfoDouble ChartSymbol(0) , SYMBOL_BID , Bid 
              SymbolInfoDouble ChartSymbol(0) , SYMBOL_ASK , ask
              pip = 10 ^ pipLoc 
              result = (ask-bid )/pip
              AlertMessage result
            else  
              AlertMessage result 
            end if 
       Else
           AlertMessage "Could not fetch spread"
     End If 
    
    
    End Sub
    Last edited by Rawan-HS; 07-14-2015 at 07:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. OnOrderTrade event Handler Issue
    By Edakad in forum VertexFX API/VTL Forum
    Replies: 3
    Last Post: 04-01-2015, 06:21 AM
  2. How to get highest and lowest price on the current chart (screen) ?
    By blaidd drwg in forum VertexFX API/VTL Forum
    Replies: 3
    Last Post: 06-18-2014, 07:17 AM
  3. Which Event handler fires first - OnCalculate or OnTick
    By Edakad in forum VertexFX API/VTL Forum
    Replies: 3
    Last Post: 06-05-2014, 08:22 AM
  4. WCF GetChartData does not include the current bar
    By jcollins in forum VertexFX API/VTL Forum
    Replies: 4
    Last Post: 07-25-2013, 01:02 PM

Tags for this Thread

Posting Permissions

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