Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 46
  1. #31
    Administrator Hassan-HS's Avatar
    Join Date
    Jun 2013
    Posts
    795

    Smile Vtl

    Dear,,
    Please assign a value to variables that exist in OnInit() .

    Code:
    Public Sub OnInit()
    	Buys = 0
    	Sells = 0
    	PendingBuy = 0
    	PendingSell = 0
    	BuyLots = 0
    	SellLots = 0
    	PendingBuyLots = 0
    	PendingSellLots = 0
    	Profit = 0
    	lastBarTime = CurTime()
    
    	If CInt(Digits) = 3 or CInt(Digits) = 5 then
    		TrailingStop = CDBL(TrailingStop * DECIMAL_CONVERSION)
    		TrailingProfit =CDBL( TrailingProfit * DECIMAL_CONVERSION)
    		StopLoss = CDBL(StopLoss * DECIMAL_CONVERSION)
    		Anchor = CDBL(Anchor * DECIMAL_CONVERSION)
    	end if
    
    	trailingStop1 = CDBL(TrailingStop * CDbl(Point))
    	trailingProfit1 = CDBL(TrailingProfit * CDbl(Point))
    	stopLoss2 = CDBL(StopLoss * CDbl(Point))
    
    	STOPLEVEL = 0
    	Denominator = 200
    	lastBarTime = CurTime() 
    End Sub

  2. #32
    diannt
    Guest

    Default

    Okay. I did it well, thank you.

    Can you help me now with DeleteLimitOrder function?

    How can I get ticket for this function, if I have to get ticket from limit order, not market?

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

    Post Vtl

    Hello Dinat,

    Already we are developing OrderGetTicket function, that made you able to retrieve order id by it is index, It will be released ASAP.

    I will update you very soon, please standby.

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

    Post Requested Features-VTL

    Dear Sir,

    The following features that requested by you are under process.
    1-STOPLEVEL ( SL/TP Offset ).
    2-iHigh,iLow etc...
    3-Leavarge.
    4-Load All Chart Data by VTL.
    5-OrderGetTicket.



    Note: And you can contact our technical support to increase numbers of the bars of charts if you are use VertexFX Trader 10 (Demo System)
    or contact your dealing room if you are use another system.

    Please let me know if you have another inquiry.

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

    Post Vtl

    Dear Dinnat,


    I have checked our source code, then i found function that is called OrderGetID returns The OrderID based on it is index.


    Code:
    Public Sub main()
    	Msgbox OrderGetID (1)
    End Sub
    Last edited by Hassan-HS; 10-27-2013 at 02:09 PM.

  6. #36
    diannt
    Guest

    Default

    Hello! Nice, that you found this function.

    Please, help me with one more now... I'm trying to count selllots and buylots.
    And my function crashes when it try to get OrderSymbol().

    What's wrong with it?

    Dim Counter
    For Counter=1 to PositionTotal() 'opened orders
    OrderSelectByIndex Clng(Counter)
    PositionSelect Clng(Counter)
    if OrderSymbol() = CSTR(named) then
    OrderGetDouble ORDER_TP,ProfitOld
    PositionGetDouble POSITION_SWAP,Swap
    Profit = Profit + ProfitOld + Swap
    If OrderType() = -1 then 'sell limit and sell
    SellLots = CDBL(SellLots + OrderLots(Clng(Counter)))
    Sells = Sells + 1
    End if
    If OrderType() = 1 then 'buy and buy limit
    BuyLots = CDBL(BuyLots + OrderLots(Clng(Counter)))
    Buys = Buys + 1
    End if
    End if
    Next

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

    Post Vtl

    Dear Sir,

    maybe you have misunderstanding between Positions and the Orders.

    Positions: The orders that have been already opened.

    Orders: The pending orders (limits orders.managed orders)

    In the attachment photo that describe the location of the positions and orders in the trade panel.
    1=> Positions
    2=>Orders

    Functions related to positions:
    PositionTotal
    PositionGetSymbol
    PositionSelect
    PositionGetDouble
    GetPositionType
    GetPositionTime
    GetPositionSymbol
    CloseMultiPositions
    PositionGetTicket
    RequestManageOrders



    Functions related to orders:
    OrdersTotal
    OrderSelect
    OrderGetDouble
    OrderGetString
    OrderPrice
    OrderSymbol
    OrderTime
    OrderType
    OrderLots
    OrderSelectByIndex
    OrderGetID


    Total Lots For Positions Sample & Total Lots For Orders Sample:


    Code:
    Public Sub main()
    
    Dim TotalPostionsLots
    Dim Temp
    TotalPostionsLots=0
    Temp=0
    For Counter=1 To PositionTotal()
    	If PositionSelect(PositionGetTicket(Clng(Counter))) Then
    		If PositionGetDouble(POSITION_AMOUNT,Temp) Then
    			TotalPostionsLots=TotalPostionsLots + Temp
    		End If
    	End If
    
    Next
    
    
    MsgBox "The total positions lots is: " & TotalPostionsLots
    
    Dim TotalOrdersLots
    Dim Temp1
    TotalOrdersLots=0
    Temp1=0
    
    For Counter=1 To OrdersTotal()
    	Temp1=OrderLots(OrderGetID(CInt(Counter))) 
    	TotalOrdersLots=TotalOrdersLots+Temp1
    Next
    
    MsgBox "The total orders lots is: " & TotalOrdersLots
    
    End Sub
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	1-Trade..jpg 
Views:	78 
Size:	22.6 KB 
ID:	281  

  8. #38
    diannt
    Guest

    Default

    Thank you very much, it was really helpful.

    Now one more question.

    http://www.hybrid-solutions.com/supp...icle/View/3632

    Can we use this function for positions?
    How can we make trailing stop for positions, if we cant use this function for positions?

  9. #39
    b_morar
    Guest

    Post VTL-Making SLTP Orders

    Dear Dinnat,

    If you need to manage a position (give it SL/TP) for the first time you have to pass PositionID to NewSLTPOrder function.

    Notice That is a new order will be add into Pending Order list view and it is called Manage Order.

    This Sample create new EUR/USD position and manage it for the first time.
    Code:
    Dim PositionType
    Dim Amount
    Dim SymbolName
    Dim PositionID
    Dim TP
    Dim SL
    Dim Offset
    
    Public Sub main()
    ' Open A New Market Order
    PositionType= TRADE_ACTION_SELL
    Amount= 1
    Offset=10
    SymbolName="EUR/USD"
    NewMarketOrder Cint(PositionType),CSTR(SymbolName),CDBL(Amount)
    End Sub
    
    
    'To Get Market Order ID
    Public Sub OnPositionTrade (actionType ,ticketID)
    Dim Temp
    ' 5 Means New Position Has Been Opened
    If  actionType = 5 then 
          PositionID= ticketID
          'Set Manage Order for this Position for the 1st time
          MsgBox "THE POSITION HAS BEEN CREATED"
          SymbolInfoDouble CSTR(SymbolName),SYMBOL_ASK,Temp
          
          If PositionType = -1 then
            SL=Temp+Offset
            TP=Temp-Offset
          elseif PositionType=1 then
            SL=Temp-Offset
            TP=Temp+Offset
          End if
           NewSLTPOrder Clng(PositionID),Cdbl(Amount),Cdbl(SL),Cdbl(TP) 
      
          
    
    end if
    ' 9 Means A Position Has Been Managed
    If  actionType = 9 then 
        MsgBox "THE POSITION HAS BEEN MANAGED"
    End if
    End Sub
    Now if you need to update the SL/TP for a position that already have SL/TP you must know it's managed OrderID and you can get it using RequestManageOrders.

    Why all this ? Becuase the VertexFX platform supports the Partial Position Managment, that means the one position may have more than one managed order.

    Ex:
    Position : "GOLD"- 10 lot
    May managed partially as following:
    "GOLD" 2 lots SL: 1300
    "GOLD" 3 lots SL: 1400 TP 1000
    "GOLD" 5 lots SL: 1300 TP 900


    This sample describe how to get the managed order ID.

    Code:
     Public Sub main()
        If AccountInfoInteger(ACCOUNT_LOGIN) Then
       ' 3666=> Position ID
    
          If RequestManageOrders (3666) Then
            MsgBox "The Request has been sent to the server to get all manage orders related to ticket number 3666 "
        Else
          MsgBox  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()
         MsgBox CSTR(manageOrders. Orders(i))
        Next
       End Sub
    Finally you can update the SL/TP by passing the managed orderID to UpdateSLTPOrder function.

    Code:
    Public Sub main()   If AccountInfoInteger(ACCOUNT_LOGIN) Then 
    
       ' 1334=> managed OrderId 
    
            If UpdateSLTPOrder (1334,0.1,1980,0.36578) Then    MsgBox "Order has been Updated " 
         Else
       MsgBox ErrorDescription(GetLastError())
        End If
       End If
    
      End Sub

  10. #40
    diannt
    Guest

    Default

    b_morar, thank you!

    But we need something else:

    Our expert's logic open pending orders with SL and TP. And when our pending order is position we have to change it. Can we do it in the same way?
    Can we just RequestManageOrders and then get our and do UpdateSLTPOrder on it?
    Last edited by diannt; 10-29-2013 at 05:00 AM.

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

    Post Vtl

    Dear dinnat,


    I didn't understand your idea at all, anyway I'll explain what you have to do in the all cases.


    1-If you have a position and it's not have SL/TP , you can assign SL/TP by passing PositionID to NewSLTPOrder.

    Note : NewSLTPOrder takes PositionID only.

    2-If you have managed order and you need to update it's SL/TP values you can pass order ID to UpdateSLTPOrder


    3-If you have limit order and you need to update it's SL/TP values you can pass order ID to UpdateLimitOrder

    Tips about RequestManageOrders

    1- There is no necessary to call it if are you know the ID of the pending order whether limit order or manage order.

    2- You should call it if you have position and do you need to retrieve its managed orders to update it's SL/TP, because the UpdateSLTPOrder function takes OrderID only.
    Last edited by Hassan-HS; 10-29-2013 at 08:12 AM.

  12. #42
    diannt
    Guest

    Default

    h.abukrayem, okay, thank you. I got it in the same way.

    Now, please, let me know - what's wrong with this code?

    This one works well!
    Public Sub main()

    Dim OpenPrice
    Dim Offset
    SymbolInfoDouble "EUR/USD",SYMBOL_ASK,OpenPrice
    Offset=0.1
    OpenPrice=OpenPrice+0.01

    if not NewLimitOrder (2,"EUR/USD",0.1,Cdbl(OpenPrice),Cdbl(OpenPrice)-Cdbl(Offset),Cdbl(OpenPrice)+Cdbl(Offset) ) then
    MsgBox ErrorDescription(GetLastError())
    end if
    End Sub

    And now... Magic! this one can't work!
    It says "Invalid Price" without SL and TP, which are "Option" for NewLimitOrder function.

    Public Sub main()

    Dim OpenPrice
    Dim Offset
    SymbolInfoDouble "EUR/USD",SYMBOL_ASK,OpenPrice
    Offset=0.1
    OpenPrice=OpenPrice+0.01

    if not NewLimitOrder (2,"EUR/USD",0.1,Cdbl(OpenPrice) ) then
    MsgBox ErrorDescription(GetLastError())
    end if
    End Sub

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

    Post VTL/New Limit Order

    You can open 4 types of orders with its prices as following :

    Notes :
    1-You can define OpenPrice,TP,SL for your custom order.
    2-There is two parameter of offset Stop offset / Limit offset



    Buy Limit

    Open Price < Ask- Limit Offset

    SL < Open Price - Stop Offset

    TP > Open Price +Limit Offset


    Sell Limit

    Open Price > Bid+ Limit Offset

    SL > Open Price + Stop Offset

    TP < Open Price - Limit Offset


    Buy Stop

    Open Price > Ask+ StopOffset

    SL < Open Price - Stop Offset

    TP > Open Price +Limit Offset



    Sell Stop

    Open Price < Bid - StopOffset

    SL > Open Price + Stop Offset

    TP < Open Price - Limit Offset

    You can contact your dealer ( or our support department if you are use our system )to get your Stop & Limit Offsets.

  14. #44
    diannt
    Guest

    Default

    Thank you very much, finally we did it!

    Can you help now with logging function?

    We have'nt seen any one yet. "Print" does'nt work.

  15. #45
    b_morar
    Guest

    Post Vtl

    Dear sir,

    You have to use PrintData function to enters a message in the log file.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Convert from MQL to VTL
    By Snake in forum VertexFX API/VTL Forum
    Replies: 19
    Last Post: 04-21-2014, 03:02 PM
  2. Converting MQL to VTL
    By Snake in forum VertexFX API/VTL Forum
    Replies: 5
    Last Post: 01-09-2014, 12:54 PM
  3. Convert MQL EA to VTL
    By Snake in forum VertexFX API/VTL Forum
    Replies: 4
    Last Post: 09-12-2013, 08:42 AM
  4. Convert MQL EA to VTL
    By Snake in forum VertexFX API/VTL Forum
    Replies: 4
    Last Post: 09-12-2013, 08:42 AM

Posting Permissions

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