Oanda forex auotmation script

trading100

Member
Messages
70
Likes
4
;Oanda AutoIt Script Home Page

$main_window = "OANDA FXTrade - XXXXX - Primary (XXXXX)"
$username="USERNAME"
$password="PASSWORD"

; OANDA FXMessage Forex Forum: FYI int_topic;f=16;t=011221


$win_x = 4
$win_y = 28
ConsoleWrite("TRUE" & @CRLF)
If Not WinActivate($main_window) Then
Run("C:\WINDOWS\system32\javaws.exe "&Chr(34)&"C:\Documents and Settings\USERNAME\Application Data\Sun\Java\Deployment\cache\6.0\16\c798210-5433f404"&Chr(34))
WinWaitActive("OANDA FXTrade Login")
$win_pos = WinGetPos("OANDA FXTrade Login")
ControlSend("OANDA FXTrade Login","","[CLASS:SunAwtCanvas; INSTANCE:2]",$username&"{TAB}"&$password)
MouseClick("left",$win_pos[0]+$win_x+155,$win_pos[1]+$win_y+125)
Sleep(5000)
WinActivate($main_window)
EndIf

If WinWaitActive($main_window,"",5) Then
$win_pos = WinGetPos($main_window)
$fh = FileOpen("d:\fx\latest.trade.txt",0)
$trade = Number(FileReadLine($fh))
FileClose($fh)
$fh = FileOpen("d:\fx\latest.limit.txt",0)
$trade_limit = Number(FileReadLine($fh))
FileClose($fh)
If $trade_limit==0 Then
If $trade>0 Then BuyMarket(Abs($trade),$win_pos)
If $trade<0 Then SellMarket(Abs($trade),$win_pos)
Else
If $trade>0 Then BuyLimit(Abs($trade),$trade_limit,$win_pos)
If $trade<0 Then SellLimit(Abs($trade),$trade_limit,$win_pos)
EndIf
ConsoleWrite("FALSE" & @CRLF)
Else
ProcessClose("javaw.exe")
EndIf

Func SellMarket($amount,$xwin_pos)
MouseClick("left",$xwin_pos[0]+$win_x+200,$xwin_pos[1]+$win_y+400,1,2)
WinWaitActive("Market Order")
$order_win_pos = WinGetPos("Market Order")
ControlSend("Market Order","","[CLASS:SunAwtCanvas; INSTANCE:2]","{BS}{BS}{BS}{BS}{BS}{BS}" & $amount)
MouseClick("left" ,$order_win_pos[0]+$win_x+165,$order_win_pos[1]+$win_y+445,1 ,2)
WinClose("[ACTIVE]", "")
EndFunc

Func SellLimit($amount,$limit,$xwin_pos)
MouseClick("left",$xwin_pos[0]+$win_x+200,$xwin_pos[1]+$win_y+400,1,2)
WinWaitActive("Market Order")
$order_win_pos = WinGetPos("Market Order")
MouseClick("left" ,$order_win_pos[0]+$win_x+150,$order_win_pos[1]+$win_y+50,1, 2)
ControlSend("[ACTIVE]","","[CLASS:SunAwtCanvas; INSTANCE:2]","{BS}{BS}{BS}{BS}{BS}{BS}" & $amount)
MouseClick("left" ,$order_win_pos[0]+$win_x+210,$order_win_pos[1]+$win_y+155,1 ,2)
ControlSend("[ACTIVE]","","[CLASS:SunAwtCanvas; INSTANCE:2]","{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}" & $limit)
MouseClick("left" ,$order_win_pos[0]+$win_x+165,$order_win_pos[1]+$win_y+445,1 ,2)
WinClose("[ACTIVE]", "")
EndFunc

Func BuyMarket($amount,$xwin_pos)
MouseClick("left",$xwin_pos[0]+$win_x+275,$xwin_pos[1]+$win_y+400,1,2)
WinWaitActive("Market Order")
$order_win_pos = WinGetPos("Market Order")
ControlSend("Market Order","","[CLASS:SunAwtCanvas; INSTANCE:2]","{BS}{BS}{BS}{BS}{BS}{BS}" & $amount)
MouseClick("left" ,$order_win_pos[0]+$win_x+165,$order_win_pos[1]+$win_y+445,1 ,2)
WinClose("[ACTIVE]", "")
EndFunc

Func BuyLimit($amount,$limit,$xwin_pos)
MouseClick("left",$xwin_pos[0]+$win_x+275,$xwin_pos[1]+$win_y+400,1,2)
WinWaitActive("Market Order")
$order_win_pos = WinGetPos("Market Order")
MouseClick("left" ,$order_win_pos[0]+$win_x+150,$order_win_pos[1]+$win_y+50,1, 2)
ControlSend("[ACTIVE]","","[CLASS:SunAwtCanvas; INSTANCE:2]","{BS}{BS}{BS}{BS}{BS}{BS}" & $amount)
MouseClick("left" ,$order_win_pos[0]+$win_x+210,$order_win_pos[1]+$win_y+155,1 ,2)
ControlSend("[ACTIVE]","","[CLASS:SunAwtCanvas; INSTANCE:2]","{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}" & $limit)
MouseClick("left" ,$order_win_pos[0]+$win_x+165,$order_win_pos[1]+$win_y+445,1 ,2)
WinClose("[ACTIVE]", "")
EndFunc
 
It was an old forum post , one should test it and tweak it. At least it provides a good outline of what to do.
 
Top