Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    haider.ali
    Guest

    Default Request for VTL Auto trade Script with capability to read from excel file

    Sir our some clients want VTL Auto trade Script linked with Excel file to read from specific cell of excel file for auto buy/sell execution with automatic trailing stop at their desired gap.
    Waiting for your valuable comments & guidance.

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

    Default

    Dear Sir,

    Sorry we just assist developers about how to use the VTL, but we can not write full script as you ask.

    at first you may find some VTL client scripts with the same functionality at vstore.co
    if you don't find such script you can use our portal VFXLancer.com to post your own projects easily, then you will receive many bids from Freelancers and development companies that have interest in developing your projects.
    For more info:
    http://www.vfxlancer.com
    To register please check this link:
    http://www.vfxlancer.com/component/j...showfront.html


    Feel free to let us know if you have any further inquiries.

  3. #3
    haider.ali
    Guest

    Default

    Here is my script. when i try to launch but it gives errors

    '''############################################### ######################################
    '''#### Script Name: Autotrading ######
    '''#### Author : Haider Ali ######
    '''#### Website : www.Hybrid-solutions.com ######
    '''#### Date : 07/09/2015 17:04:18 ######
    '''#### Description: Description ######
    '''############################################### ######################################

    ''' <summary>
    ''' The main function is the entry point for any Script program
    ''' </summary>

    Public Sub main()
    Dim filename
    Dim fileMode
    fileMode = FILE_APPEND
    fileName = "C:\Vertex.xlsx"
    msgbox GetEntry (Cstr(fileName),sheet1, d5)
    'L means the line number
    End Sub

    sub main()

    if d5 = 2, ("C:\Vertex.xlsx") then
    'NewMarketOrder 1',"MININQU5",0.5 '(1 = Buy, SymbolName, Lots)'
    End if

    End Sub

    ''' <summary>
    ''' The function is generated when a new tick is received for any symbol
    ''' </summary>

    Public Sub OnTick(symbolName)
    End Sub

    ''' <summary>
    ''' The function is generated when initialization script
    ''' </summary>

    Public Sub OnInit()
    '''TODO: initialization method
    End Sub

    ''' <summary>
    ''' The function is generated when deinitialization script
    ''' </summary>

    Public Sub OnDeInit()
    '''TODO: deinitialization method
    End Sub

    ''' <summary>
    ''' The OnTimer function called when the timer event occurs
    ''' </summary>

    Public Sub OnTimer()
    '''TODO: Timer Function
    End Sub

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

    Default

    Dear

    try this code , it to read from excel file for cell (1,1)
    let me know if you need any things .

    Code:
    Public Sub main()
    ''''TODO: Script program start method
    
    
    Dim xlApp 
    Dim xlBook 
    Dim xlSheet 
     
    Set xlApp = CreateObject("Excel.Application") 
    xlApp.visible = false
    Set xlBook = xlApp.Workbooks.open("C:\Vertex.xlsx" )
    Set xlSheet = xlBook.Worksheets("Sheet1") 
     
    AlertMessage xlSheet.Cells(1,1).Value 
     
      if xlSheet.Cells(1, 1).Value = 2 then
    NewMarketOrder 1,"EUR/USD",1
    End if 
    
    
    
    
    End Sub

  5. #5
    haider.ali
    Guest

    Default

    Brother thanks for your attention: Following issues related to script provided may please be clarified.

    1. In this script, where i can mentioned that it is VTL client script or VTL Server side script?
    2. If xls sheet is active then can i modify code to "xlapp.visible = true"
    3. Can i specify cell description i.e "B4" or "D8", etc in the script.
    4. Can i add description of new market order whether sell or buy like (1/-1 = Buy / Sell, SymbolName, Lots)
    5. How to add strong auto desired SL/TP in this script.

    Thanking you in anticipation.

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

    Default

    Dear sir ,

    first of all we are not expert about windows API so we can't help you about how to get the cell description

    - please read this course to know the differences between VTL Client and VTL Server
    - you can modify the code to be xlapp.visible=true , this line it just to make the sheet visible to you or not
    and yes you can add description for the market order by using ENUM_TRADE_ACTION to be like this

    NewMarketOrder TRADE_ACTION_BUY,"EUR/USD",1
    try this code to open the SLTP order

    Code:
     
        Public Sub main()
    
    
    
    
         Dim xlApp 
         Dim xlBook 
        Dim xlSheet 
     
         Set xlApp = CreateObject("Excel.Application") 
        xlApp.visible = true
        Set xlBook = xlApp.Workbooks.open("C:\Vertex.xlsx" )
       Set xlSheet = xlBook.Worksheets("Sheet1") 
    
    
          if xlSheet.Cells(1, 1).Value = 2 then
             NewMarketOrder TRADE_ACTION_BUY,"EUR/USD",1 
         End if 
    
    
      End Sub
    
    
      Public Sub OnPositionTrade (actionType ,ticketID)
           If actionType= 5 then 
    
    
           NewSLTPOrder Clng(ticketID), 1,  1.11502 , 1.11632
    
    
         end if 
     End Sub
    Last edited by Rawan-HS; 09-09-2015 at 05:08 PM.

  7. #7
    haider.ali
    Guest

    Default

    Dear Rawan, Thanks for your kind attention.

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

    Default

    you are welcome , and tell me if you need any things else

  9. #9
    haider.ali
    Guest

    Default

    Sir i tried the code but neither the script read .xl sheet1/cell nor any order executed. plz guide.

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

    Default

    Dear

    this is the Full VTL Client Code just copy it to VTL and attach to chart after select Account
    and be notice it executed the order if the value of the Cell number (1,1) equal 2
    this code is working fine in my side

    Code:
    '''#####################################################################################
    '''####     Script Name: Script Name                                              ######
    '''####     Author     : Author Name                                              ######
    '''####     Website    : www.Hybrid-solutions.com                                 ######
    '''####     Date       : 09/09/2015 19:51:11                                      ######
    '''####     Description: Description                                              ######
    '''#####################################################################################
    
    ''' <summary>
    ''' The main function is the entry point for any Script program
    ''' </summary>
    
    
    Public Sub main()
    
    ''''TODO: Script program start method
    
    
         Dim xlApp 
         Dim xlBook 
        Dim xlSheet 
     
         Set xlApp = CreateObject("Excel.Application") 
        xlApp.visible = true
        Set xlBook = xlApp.Workbooks.open("C:\Vertex.xlsx" )
        Set xlSheet = xlBook.Worksheets("Sheet1") 
    
    
          if xlSheet.Cells(1, 1).Value = 2 then
             NewMarketOrder TRADE_ACTION_BUY,"EUR/USD",1 
         End if 
    
    
      End Sub
    
    
      Public Sub OnPositionTrade (actionType ,ticketID)
           If actionType= 5 then 
    
    
           NewSLTPOrder Clng(ticketID), 1,  1.11502 , 1.11632
    
    
         end if 
     End Sub
    
    
    
    ''' <summary>
    ''' The function is generated when a new tick is received for any symbol
    ''' </summary>
    
    Public Sub OnTick(symbolName)
    
    End Sub
    
    
    ''' <summary>
    ''' The function is generated when initialization script
    ''' </summary>
    
    Public Sub OnInit()
    ''''TODO: initialization method
    
    End Sub
    
    
    ''' <summary>
    ''' The function is generated when deinitialization script
    ''' </summary>
    
    Public Sub OnDeInit()
    ''''TODO: deinitialization method
    
    End Sub
    
    
    ''' <summary>
    ''' The OnTimer function called when the timer event occurs
    ''' </summary>
    
    Public Sub OnTimer()
    ''''TODO: Timer Function
    End Sub
    
    ''' <summary>
    ''' The OnCalculate function called when a new candle received
    ''' </summary>
    
    Public Sub OnCalculate(symbol, symbolPeriod, openVal, highVal, lowVal, closeVal)
    
    End Sub
    ''' <summary>
    ''' Raise when all data  are loaded after Login 
    ''' </summary>
    
    Public Sub AllDataLoaded()
    
    End Sub
    ''' <summary>
    ''' Raise when Account Selected 
    ''' </summary>
    
    Public Sub AccountSelected(accountNumber)
    
    End Sub
    ''' <summary>
    ''' Raise when the server returns order result 
    ''' </summary>
    
    Public Sub OnOrderTrade(actionType ,orderID , returnValue)
    
    End Sub
    
    
    public sub OnManageOrdersReceived(manageOrders)
    
    End Sub
    Last edited by Rawan-HS; 09-10-2015 at 02:58 PM.

  11. #11
    haider.ali
    Guest

    Default Dear Rawan Sir, Still facing problems

    I tried the below code as you advised, i.e attached the vtl script to chart but it won't wok. Error report is enclosed. (Furthermore, also guide to get data from a already opened / active excel file)

    Public Sub main()

    ''''TODO: Script program start method


    Dim xlApp
    Dim xlBook
    Dim xlSheet

    Set xlApp = CreateObject("Excel.Application")
    xlApp.visible = false
    Set xlBook = xlApp.Workbooks.open("D:\ali.xlsx" )
    Set xlSheet = xlBook.Worksheets("Sheet1")


    if xlSheet.Cells(1, a).Value = 2 then

    NewMarketOrder TRADE_ACTION_BUY,"MINI_NQ_U5",1

    End if


    End Sub
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Error.jpg 
Views:	55 
Size:	20.1 KB 
ID:	391  

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

    Default

    Dear Sir ,


    the error appeared on the calls coordinate the script can't read the coordinate as (1,a) .
    so (1,a) it equal to Cell (1, 1) , and cell (1, b ) it equal to (1,2 ) and so on

    so according to this just change the line


    if xlSheet.Cells(1, a).Value = 2 then
    to this


    if xlSheet.Cells(1, 1).Value = 2 then

  13. #13
    haider.ali
    Guest

    Default

    Dear Rawan Sir, this script is to read an closed excel file. If i want to read or continuously read an already opened /active worksheet, then what will be the change in this script. Thanks for your kind attention.

  14. #14
    haider.ali
    Guest

    Default

    I following your guidelines but this time recieved following error.
    Click image for larger version. 

Name:	Again Error.png 
Views:	57 
Size:	8.1 KB 
ID:	392

    code: (5, 4) stands for (5, d)

    Public Sub main()

    ''''TODO: Script program start method


    Dim xlApp
    Dim xlBook
    Dim xlSheet

    Set xlApp = CreateObject("Excel.Application")
    xlApp.visible = false
    Set xlBook = xlApp.Workbooks.open("D:\vertex.xlsx" )
    Set xlSheet = xlBook.Worksheets("Sheet1")


    if xlSheet.Cells(5, 4).Value = 1 then

    NewMarketOrder TRADE_ACTION_BUY,"MINI_NQ_U5",1

    End if


    End Sub

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

    Default

    Dear

    I have tested your code and there is no error

    is this your fully code ??

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to read from a text file
    By abdulaziz in forum VertexFX API/VTL Forum
    Replies: 2
    Last Post: 07-22-2015, 01:58 PM
  2. read from file
    By haytham in forum VertexFX API/VTL Forum
    Replies: 3
    Last Post: 08-06-2014, 12:12 PM
  3. How can we read positions from history in local script
    By nhasan in forum VertexFX API/VTL Forum
    Replies: 2
    Last Post: 05-18-2014, 12:29 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
  •