PDA

View Full Version : How to modify script/ ea of vertexfx



a11ever
06-09-2015, 07:22 PM
I want to modify following script

to open limit orders or buy stop / sell stop orders (e.g 10 pips away from market price) at specific time with take profit and stop loss value. (e.g tp is 20 pips and stop loss is 10 pips )


script code:

Public Sub main()

NewMarketOrder -1,"GOLD",0.5 '(1/-1 = Buy / Sell, SymbolName, Lots)

End Sub

Public Sub OnTick(SymbolName)

End Sub

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

End Sub

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

End Sub

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

Hassan-HS
06-11-2015, 10:02 AM
Greetings :)

At first you must replace NewMarketOrder (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1736) method with NewLimitOrder (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/1737)Method, Please open the links for more info, and you can check this course (http://www.hybrid-solutions.com/VTL%20Course.pdf)to learn more about VTL.

Before:



NewMarketOrder -1,"GOLD",0.5 '(1/-1 = Buy / Sell, SymbolName, Lots)


After:



Public Sub main()

If AccountInfoInteger(ACCOUNT_LOGIN) Then ' Check if account is selected
Dim OpenPrice
Dim SL
Dim TP
OpenPrice=1.12400
SL=1.12200
TP=1.12700
IF Not NewLimitOrder (TRADE_ACTION_BUY,"EUR/USD", 1 , Cdbl(OpenPrice) ,Cdbl(SL) , Cdbl(TP)) Then
'Returns True if BuyLimit operation was successful
'NewLimitOrder will set the SL and TP of the position.
MsgBox "Unable to place order due to :" & ErrorDescription(GetLastError()) 'Returns a description of the error


End If
ELse
MsgBox "Please Select Account"
End If


End Sub

a11ever
06-11-2015, 01:59 PM
thanks for your reply

but

i want limit orders to placed at specified time e.g 23:59

with specified number of pips difference from market price and put tp/sl
with specified number of pips from limit order price.

means in ea i specify time and number of pips not the exact price for limit orders and tp /sl

Hassan-HS
06-13-2015, 05:54 PM
Hello,

Yes you can do this using VTL, but let me know the time value based is on your machine time or System time?

Rawan-HS
06-14-2015, 07:04 AM
Dear ,

try this code , just change the hourstart parameter with time that you need




Dim hourStart
hourStart = 10


Public Sub main()


If AccountInfoInteger(ACCOUNT_LOGIN) Then ' Check if account is selected
Dim OpenPrice
Dim SL
Dim TP
OpenPrice=1.12400
SL=1.12200
TP=1.12700
If Hour(CurTime()) = hourStart then
IF Not NewLimitOrder (TRADE_ACTION_BUY,"EUR/USD", 1 , Cdbl(OpenPrice) ,Cdbl(SL) , Cdbl(TP)) Then
'Returns True if BuyLimit operation was successful
'NewLimitOrder will set the SL and TP of the position.
MsgBox "Unable to place order due to :" & ErrorDescription(GetLastError()) 'Returns a description of the error
End If
End IF
ELse
MsgBox "Please Select Account"
End If




End Sub

a11ever
06-18-2015, 07:16 PM
i want to use brokers time.


and i want to mention e.g 10 pips away from market price at specified time for limit orders.


in ea i shouldn't specify exact price but the ea should place order at specified time e.g 10 away from market price.

Rawan-HS
07-13-2015, 07:32 AM
Dear a11ever ,

I'm sorry about this delay to replying you

The below code allow to you to open the limit order with specified number of pips , try it and tell me if you need any help :)





Dim hourStart
hourStart = 10


Public Sub main()
If AccountInfoInteger(ACCOUNT_LOGIN) Then ' Check if account is selected
Dim OpenPrice
Dim SL
Dim TP
Dim pipLoc
Dim PiP
OpenPrice=1.11600
SymbolInfoInteger ChartSymbol(0), SYMBOL_PIP_LOCATION, pipLoc
pip = 10 ^ pipLoc
SL= OpenPrice - pip
TP= OpenPrice + pip
If Hour(CurTime()) = hourStart then
If Not NewLimitOrder (TRADE_ACTION_BUY,"EUR/USD", 1 , Cdbl(OpenPrice) ,Cdbl(SL) , Cdbl(TP)) Then
'Returns True if BuyLimit operation was successful
'NewLimitOrder will set the SL and TP of the position.
AlertMessage "Unable to place order due to :" & ErrorDescription(GetLastError())
'Returns a description of the error
End If
End IF
ELse
AlertMessage "Please Select Account"
End If
End sub

Rawan-HS
07-13-2015, 07:57 AM
Dear e11ever ,

this another sample for full date time try it :)




Dim hourStart
hourStart = "13/07/2015 10:39:21"


Public Sub main()
If AccountInfoInteger(ACCOUNT_LOGIN) Then ' Check if account is selected
Dim OpenPrice
Dim SL
Dim TP
Dim pipLoc
Dim PiP
OpenPrice=1.11600
SymbolInfoInteger ChartSymbol(0), SYMBOL_PIP_LOCATION, pipLoc
pip = 10 ^ pipLoc
SL= OpenPrice - pip
TP= OpenPrice + pip
If CurTime() = hourStart then
If Not NewLimitOrder (TRADE_ACTION_BUY,"EUR/USD", 1 , Cdbl(OpenPrice) ,Cdbl(SL) , Cdbl(TP)) Then
'Returns True if BuyLimit operation was successful
'NewLimitOrder will set the SL and TP of the position.
AlertMessage "Unable to place order due to :" & ErrorDescription(GetLastError())
'Returns a description of the error
End If
End IF
ELse
AlertMessage "Please Select Account"
End If

End Sub