;
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
;
; Script Function:
; Opens Notepad, types in some text and then quits.
;
#include<Date.au3>
Opt("WinTitleMatchMode", 2) ;1=complete, 2=quick
$title = WinGetHandle("OANDA")
If $title = 0 Then
MsgBox(0,"Not Found", "The window title specified was not found!")
Else
$date = @YEAR & "." & @MON & "." & @MDAY
WinActivate($title)
WinWaitActive($title)
Send("^x")
WinWaitActive("Alert")
Send("{ENTER}")
FileMove("C:\program files\OANDA\experts\files\*", "C:\program files\OANDA\experts\files\" & $date & "\*",9)
EndIf
MQL4 Tutorial
dimanche 22 mai 2011
How to schedule a script through a hotkey
Autoit source code to run this script through a hotkey ctrl+x associated with the script.
MQL4 special functions.
Special functions in MQL4 are init(), start() and deinit(). These functions will be called by the system, not by the user. init and deinit can be missing. start() is the main function where all calculations will be performed.
Definition:
init() will be called at the initialization of the program once historical data has been uploaded.
start() will be called after each new tick (tick in between will be discarded) if Expert Advisor has been enabled and if EA properties window is not open. In script it will be called only once.
deinit() will be called when the program shuts down.
Default Parameters Values:
These functions can have default parameters values.
Definition:
init() will be called at the initialization of the program once historical data has been uploaded.
start() will be called after each new tick (tick in between will be discarded) if Expert Advisor has been enabled and if EA properties window is not open. In script it will be called only once.
deinit() will be called when the program shuts down.
Default Parameters Values:
These functions can have default parameters values.
vendredi 20 mai 2011
How to export historical quotes
Metatrader allows you to export historical quotes by hand. But it's rather cumbersome. Here's how to do it by script:
Source code formatted with http://codeformatter.blogspot.com
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string symbols[]={"EURUSD","EURGBP"};
int periods[] = {1,5,15,60,240,1440,10080,43200};
int count = ArraySize(symbols);
int counttf = ArraySize(periods);
string symbol;
int period;
for (int ii=0; ii<count; ii++){
symbol = symbols[ii];
for (int jj=0; jj<counttf; jj++){
period = periods[jj];
export(symbol, period);
}
}
//----
Alert("the end");
return(0);
}
//+------------------------------------------------------------------+
int export(string symbol, int theperiod)
{
string filename = StringSubstr(symbol,0,6) + theperiod + ".csv";
int handle = FileOpen(filename, FILE_CSV|FILE_WRITE, ";");
if(handle>0)
{
// table column headers recording
FileWrite(handle, "Time;Open;High;Low;Close;Volume");
// data recording
for(int i=iBars(symbol,theperiod); i>=0; i--) {
datetime t = iTime(symbol,theperiod,i);
// int year = TimeYear(Time[i]);
int year = TimeYear(t);
if (year > 1970) {
string strdatetime = TimeToStr(t);
strdatetime = StringSetChar(strdatetime,4,'-');
strdatetime = StringSetChar(strdatetime,7,'-');
double Open_i = iOpen(symbol,theperiod,i);
double High_i = iHigh(symbol,theperiod,i);
double Low_i = iLow(symbol,theperiod,i);
double Close_i = iClose(symbol,theperiod,i);
double Volume_i = iVolume(symbol,theperiod,i);
FileWrite(handle, strdatetime, Open_i, High_i, Low_i, Close_i, Volume_i);
}
}
FileClose(handle);
}
return(0);
}
Source code formatted with http://codeformatter.blogspot.com
Inscription à :
Articles (Atom)