PDA

View Full Version : Please help to check open orders in client side script



nhasan
11-19-2013, 12:24 PM
Hi Dear

I am trying to check all open orders from client side script as follows -

For i = 1 To OrdersTotal()

OrderSelectByIndex(CLNG(i))

IF OrderSymbol() = ChartSymbol(0) AND OrderGetID(CINT(i)) = 0 Then
MsgBox OrderType()
End IF
Next

This should prompt order type for each open order of current symbol having no open position i.e. pending orders.

But it's not showing anything when I have open pending order in current pair

Please help me to get all orders in loop by client side script.

Thanks

Hassan-HS
11-19-2013, 02:01 PM
Dear sir,

if you need to know what is the type of order you have to use OrderType which is returns to you either of the following values

(I) 1 Market Type means the order is in the chatting screen waiting the dealer approval.
(II) 2 Limit Type means the order is pending order (Buy Limit, Sell Limit, Buy Stop, Sell Stop)
(III) 3 SLTP Type manage order for a open position







For i = 1 To OrdersTotal()
OrderSelectByIndex(CLNG(i))
IF OrderSymbol() = ChartSymbol(0) Then
IF OrderType = 2 Then
'Pending Order
MsgBox OrderGetID(Clng(i))
End IF

End IF
Next

nhasan
11-20-2013, 03:49 AM
Thanks for the help

From OrderType property we can find pending orders
But how can we identify whether it's a Buy Limit or Sell Limit or Buy Stop or Sell Stop?

nhasan
11-20-2013, 06:57 AM
Sorry, I am not asking to about opening new SLTP Order

After opening a SLTP order how can we identify it's parent position. It's required to update SLTP order for Break Even, Trailing SL etc.
In managed order there is no Open Price parameter to calculate Break Even or Update SL or TP based on market condition - This property is available in open positions
So position's ticket number related to managed order is required to find out open price of concern managed order.
I hope it's clear now.

Hassan-HS
11-20-2013, 06:59 AM
Dear Hasan,





From OrderType property we can find pending orders
But how can we identify whether it's a Buy Limit or Sell Limit or Buy Stop or Sell Stop?

This feature is in the development cycle, it will be ready soon.

Hassan-HS
11-20-2013, 07:08 AM
Dear Hasan,




Sorry, I am not asking to about opening new SLTP Order

After opening a SLTP order how can we identify it's parent position. It's required to update SLTP order for Break Even, Trailing SL etc.
In managed order there is no Open Price parameter to calculate Break Even or Update SL or TP based on market condition - This property is available in open positions
So position's ticket number related to managed order is required to find out open price of concern managed order.
I hope it's clear now.




I have answered you after separating your post in a new thread (http://www.hybrid-solutions.com/forum/showthread.php?31435-VTL-SLTP-Orders).

Hassan-HS
01-09-2014, 09:02 AM
Dear Hasan,


Now you can use OrderGetInteger (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/4005) to get the order type.





Dim TradeDescription
Dim OrderDescription

Public Sub main()

Dim barNumber
Dim result
Dim orderId

For i= 1 to OrdersTotal

result=OrderSelectByIndex(Clng(i))

If Cbool(result)= TRUE Then

orderId = OrderGetID(cint(i))

GetOrderType result

OrderGetInteger OPERATION_TYPE_ENUM,result

GetTradeAction result

' The data will be Logged in this path ...\VTL10\Log

PrintData "Order Id is : " & CSTR(orderId) & " , Operation Type is : " & CSTR(TradeDescription)

OrderGetInteger ORDER_TYPE_ENUM,result

GetOrderType result

' The data will be Logged in this path ...\VTL10\Log

PrintData "Order Id is : " & CSTR(orderId) & " , Order Type is : " & CSTR(OrderDescription)

End If

next

End Sub

Public sub GetOrderType( orderValue )

If orderValue=1 then

OrderDescription="Market Order"

elseif orderValue=2 then

OrderDescription="Limit Order"

elseif actionValue=3 then

OrderDescription="SL/TP Order"

else

OrderDescription="Nothing"

End If

End Sub

Public sub GetTradeAction( actionValue )

If actionValue= -2 then

TradeDescription="Sell stop"

elseif actionValue=2 then

TradeDescription="Buy stop"

elseif actionValue=-1 then

TradeDescription="Sell Limit"

elseif actionValue=1 then

TradeDescription="Buy Limit"

else
OrderDescription="Nothing"

End If

End Sub