Knowledgebase:
NewSLTPOrder
Posted by Mohammad Rahhal, Last modified by Rawan Al Hourani on 16 July 2017 11:23 AM

Syntax

Public Function NewSLTPOrder(Ticket As Long, Lots As Double, Optional SL As Double =0 , Optional TP As Double =0) As Boolean

This function is used to create a manage order at specific ticket number.To get result from the server, you have to consume OnOrderTrade event.

Parameters

Key Description 
Ticket Postion number to create manage order on it, a value of type Long.
Lots Amount of lots, a value of type Double.
SL Stop loss, a value of type Double.
TP Take Profit, a value of type Double.

Return value

Returns true if successful, otherwise returns false. In order to get an error, call GetLastError() function.

Sample

 Public Sub main ()

 If AccountInfoInteger (ACCOUNT_LOGIN) Then

 Dim Ticket

 

 Dim lot
 Dim Symbol
 Dim Bid
 Dim Ask
 Dim price

 

 Symbol = ChartSymbol (0)
 SymbolInfoDouble cstr (Symbol), SYMBOL_BID, Bid
 SymbolInfoDouble cstr (Symbol), SYMBOL_ASK, ask
 Ticket = PositonGetTicket (1)
 PositionSelect Clng (Ticket)
 PositionGetDouble POSITION_AMOUNT, lot
 PositionGetDouble POSITION_OPEN_PRICE, Price
 If( GetPositionSymbol() = Symbol) then
 If (GetPositionType() = TRADE_ACTION_BUY) then
 If NewSLTPOrder(Clng(Ticket), cdbl(lot),Bid - price , 0 ) = false then
 AlertMessage ErrorDescription(GetLastError())
 End IF
 End IF
 End IF
 End IF
 End sub      

See Also


Back to VTL Client Script Index

(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
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