Syntax
Public Function NewSLTPOrder(Ticket As Long, Lots As Double, Optional SL As Double =0 , Optional TP As Double =0) As Boolean
Description
This function is used to create a manage order at specific ticket number.To get result from the server, you have to consumeOnOrderTradeevent.
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