Retrieve Balance in MT4 using AutoIt

417 views Asked by At

I'm trying to get the values of a listView of the software called MetaTrader Terminal 4 ( for details, ref. ).

I was able to retrieve the number of lines, but that's all, not the actual item texts ( and I've tried that many many ways ).

How is it that it is so hard to retrieve values from an external program?

Are there other ways to do so?

$Win2 = WinGetHandle( "2000100748" , "EURAUD") ;get window handle
ConsoleWrite("$Win2="&$Win2&@lf)
$Ctl2 = ControlGetHandle ($Win2,"",'[CLASS:SysListView32; INSTANCE:4]') ;get treeview inside $Win2 handle
ConsoleWrite("$Ctl2="&$Ctl2&@lf)

$aa = ControlListView($Win2, "", "[CLASS:SysListView32; INSTANCE:4]", "Selectall")
MsgBox($MB_SYSTEMMODAL,"", $aa)

$a =  _GUICtrlListView_GetItemCount($Ctl2)
MsgBox($MB_SYSTEMMODAL,"", $a)

$b = _GUICtrlListView_FindText ($Ctl2,"Volume")
MsgBox($MB_SYSTEMMODAL,"", $b)

enter image description here

EDIT: when using _GUICtrlListView_GetItemTextString($Ctl2, $i) I get "|||||||" as a result

thanks

Jeff

1

There are 1 answers

0
user3666197 On BEST ANSWER

May use MQL4 tools available to help better automate the task:

The MetaTrader Terminal 4 has a built-in programming language ( MQL4 ). That provides all possible automation tools one may need, incl. the Account profit, balance and all other details.

Based on one's need, the double AccountBalance() can get

  • printed Print( "Account balance = ", AccountBalance() );

  • displayed Comment( "Account balance = ", AccountBalance() ); in graph-area

  • stored FileWrite( aFileHANDLE, "Account balance = ", AccountBalance() );

  • sent SendMail( "Account balance = " + (string) AccountBalance() ) ); by email

whichever representation of the account balance detail is easier for one's automation needs, be it using an AutoIt or other tools.