ni kat atas skali (global variable)
double tempTimeStartTrade, tempTimeFinishTrade, tempCurrentTime;
ni sumbat dlm int init()
tempTimeStartTrade=(HoursStartTrade*100)+MinuteSta rtTrade;
tempTimeFinishTrade=(HoursFinishTrade*100)+MinuteF inishTrade;
ni dalam int start() ( mula2 skali lepas tanda "{" )
if (TradeTime()==false) return;
pastu last, paste sume2 ni kat bawahhhh skali... (new module)
bool TradeTime()
{
tempCurrentTime=(Hour()*100)+Minute();
if(tempTimeStartTrade<tempTimeFinishTrade)
{
if (tempCurrentTime>=tempTimeStartTrade && tempCurrentTime<=tempTimeFinishTrade)
return(true);
}
else if(tempTimeStartTrade>tempTimeFinishTrade)
{
if (tempCurrentTime>=tempTimeStartTrade || tempCurrentTime<=tempTimeFinishTrade)
return(true);
}
return(false);
}
ni kod aku la, tak tau kalo ada simple lagik...
Programming - editing - modification EA, Script or Indicator for MT4 OR MT5 ---- Trading on the Forex market involves substantial risks, including complete possible loss of funds and other losses and is not suitable for all members. Client should make an independent judgments as to whether trading is appropriate for him/her in light of his/her financial condition, investment experience, risk tolerance and other factors.
Saturday, 22 September 2012
Belajar MQ4 Programming
http://indo.mt5.com/showthread.php?1103-Belajar-MQ4
======================================================================
Belajar MQ4 #1 - Jenis Program
Sumber: Dokumentasi MetaEditor
Terdapat 4 jenis program pada MQL4, yaitu:
1. Expert Advisor
2. Custom Indicator
3. Script
4. Library
5. Included File
Expert Advisor (EA)
-------------------
Program yang mempunyai kemampuan untuk menganalisa suatu chart dan mengeksekusi transaksi.
EA mempunyai siklus: init - start - deinit.
init
Dieksekusi saat: EA di-compile, EA di-attach ke chart, terjadi perubahan timeframe, terjadi perubahan user, atau MetaTrader di-restart.
start
Dieksekusi setiap kali terjadi perubahan tick pada chart.
start merupakan bagian utama dari EA, bagaimana EA akan bertindak, semuanya terdapat di dalam start.
Terkadang terjadi perbedaan kecepatan antara waktu eksekusi start dengan waktu perubahan tick, terutama pada komputer yang kemampuan komputasinya rendah.
Jika perbedaan ini terjadi, maka eksekusi start akan dilanjutkan sampai selesai walaupun telah terjadi perubahan tick.
Eksekusi start pada perubahan tick berikutnya akan terjadi jika eksekusi yang sebelumnya telah selesai tuntas.
deinit
Dieksekusi saat: EA di-compile, EA di-remove dari chart, terjadi perubahan timeframe, terjadi perubahan user, atau MetaTrader di-restart.
Custom Indicator (CI)
---------------------
Program yang mempunyai kemampuan menganalisa suatu chart tetapi tidak dapat mengeksekusi transaksi.
CI mempunyai siklus: init - start - deinit
Script
------
Berbeda dengan EA, script tidak dieksekusi saat terjadi perubahan tick, tetapi oleh permintaan langsung dari user.
Script hanya memiliki start saja.
Library
-------
Program yang merupakan himpunan dari function-function.
Library tidak dapat bekerja secara otomatis.
Library digunakan dengan cara di-attach-kan ke dalam program lain (EA, CI)
Included File (IF)
------------------
Program yang berisi himpunan function-function, tetapi lebih mengarah pada content berupa text.
Penggunaan IF lebih ringan dibanding Library.
Dapat digunakan oleh EA, CI, Script, dan Library.
=====================================================================
Belajar MQ4 #2 - MQ4 vs C
Sumber: Dokumentasi MetaEditor
Rekan-rekan yang berkecimpung di dunia programming, terutama yang menggunakan Bahasa C/C++, tentunya tidak asing dengan MQ4.
Ya, betul, karena MQ4 merupakan bahasa yang menggunakan dasar Bahasa C.
Tetapi tidak semua reserved word, operator, dan tata cara Bahasa C ada pada MQ4.
Yang tidak ada pada MQ4 adalah:
1. no address arithmetic;
Saya belum tahu persis apa maksudnya point yang satu ini, tapi dugaan saya adalah tidak ada penggunaan pointer pada MQ4.
2. no operator do ... while;
Yang ini saya pernah mengalami, waktu saya menggunakan do ... while dan di-compile langsung dapat error.
Ternyata MQ4 hanya mengenali while, tetapi tidak mengenali do.
do dianggap sebagai variabel yang tidak/belum dideklarasikan.
Sehingga struktur perulangan yang bisa digunakan hanya while dan for saja.
3. no operator goto ...;
Rupanya MQ4 sudah menerapkan "Pemrograman Terstruktur" jadi tidak lagi menggunakan goto.
Semua alur program harus diatur menurut kaidah "Terstruktur".
4. no operation of [condition]?[expression 1]:[expression 2];
Operator kondisi cepat juga tidak lagi ada.
Padahal menyenangkan juga menggunakan operator yang satu ini.
5. no compound data types (structures);
Terkadang tanpa ada structure, pengaturan struktur data menjadi rumit, karena tidak bisa membuat array of structure.
Tetapi masih dapat dipecahkan dengan menggunakan multiple-array.
======================================================================
Belajar MQ4 #3 - Switch
Saya tertarik untuk membahas perintah switch karena pernah mengalami error saat menggunakannya.
Kesalahan yang pernah saya lakukan adalah:
Ternyata setelah case, tidak boleh menggunakan variabel atau output function, tetapi harus menggunakan angka biasa atau konstanta.
Akhirnya diubah seperti ini baru error mau hilang:
Dasar pemikirannya adalah bahwa switch merupakan padanan if, tetapi switch mempunyai batasan-batasan, sehingga tidak bisa leluasa seperti saat menggunakan if.
Jika menggunakan if, maka tidak akan ada error, seperti berikut:
Jadi apakah switch lebih buruk dibandingkan if ???
Jelas tidak, masing-masing mempunyai kekuatan dan kecocokan pada suatu masalah.
switch
Sangat membantu saat menghadapi pilihan yang sifatnya seragam.
Misalnya, sebuah hari, jika sudah dinyatakan Senin, pasti tidak bisa dinyatakan hari yang lain.
Sebuah order, jika sudah bertipe OP_BUY, pasti pada saat yang sama bertype yang lain.
Dari sisi estetika, barangkali switch lebih "indah" dibanding if.
if
Sangat leluasa untuk segala jenis kondisi.
Penyusun kondisi tidak harus operand bertype integer seperti pada switch.
Mereka berdua, switch dan if, akan sangat baik bila disinergikan.
Karena, tidak semua switch bisa dilakukan secara mudah dengan if.
Sebaliknya, tidak semua if bisa dilakukan dengan switch.
Belajar MQ4
Halo rekan-rekan sekalian.
Saya buka thread ini dengan tujuan belajar bersama-sama tentang MQ4.
Saling mengisi dan saling diisi, sehingga dapat bersama-sama maju.
Saya belajar MQ4 secara mandiri, tapi masih sedikit yang saya bisa dan banyak hal yang belum bisa saya pahami.
Semoga, sharing rekan-rekan disini merupakan pembelajaran bersama yang baik dan bermanfaat.
---
Ada hal yang membuat saya penasaran, yaitu "bagaimana cara mengetahui konnversi dari pip (atau point) menjadi deposit currency melalui EA".
Sebagai contoh:
Terdapat broker yang menerapkan cent account.
Lot terkecil yang diijinkan sebesar 0.01.
Dari pengamatan, pada currency pair EURUSD, dengan 0.01 lot, 1 pip = 1 cent = 0.01 dollar.
Saat kita (manusia) melihat, maka dapat diputuskan seperti contoh diatas.
Tapi bagaimana suatu EA bisa melakukan konversi tersebut?
Terima kasih.
======================================================================
Belajar MQ4 #1 - Jenis Program
Sumber: Dokumentasi MetaEditor
Terdapat 4 jenis program pada MQL4, yaitu:
1. Expert Advisor
2. Custom Indicator
3. Script
4. Library
5. Included File
Expert Advisor (EA)
-------------------
Program yang mempunyai kemampuan untuk menganalisa suatu chart dan mengeksekusi transaksi.
EA mempunyai siklus: init - start - deinit.
init
Dieksekusi saat: EA di-compile, EA di-attach ke chart, terjadi perubahan timeframe, terjadi perubahan user, atau MetaTrader di-restart.
start
Dieksekusi setiap kali terjadi perubahan tick pada chart.
start merupakan bagian utama dari EA, bagaimana EA akan bertindak, semuanya terdapat di dalam start.
Terkadang terjadi perbedaan kecepatan antara waktu eksekusi start dengan waktu perubahan tick, terutama pada komputer yang kemampuan komputasinya rendah.
Jika perbedaan ini terjadi, maka eksekusi start akan dilanjutkan sampai selesai walaupun telah terjadi perubahan tick.
Eksekusi start pada perubahan tick berikutnya akan terjadi jika eksekusi yang sebelumnya telah selesai tuntas.
deinit
Dieksekusi saat: EA di-compile, EA di-remove dari chart, terjadi perubahan timeframe, terjadi perubahan user, atau MetaTrader di-restart.
Custom Indicator (CI)
---------------------
Program yang mempunyai kemampuan menganalisa suatu chart tetapi tidak dapat mengeksekusi transaksi.
CI mempunyai siklus: init - start - deinit
Script
------
Berbeda dengan EA, script tidak dieksekusi saat terjadi perubahan tick, tetapi oleh permintaan langsung dari user.
Script hanya memiliki start saja.
Library
-------
Program yang merupakan himpunan dari function-function.
Library tidak dapat bekerja secara otomatis.
Library digunakan dengan cara di-attach-kan ke dalam program lain (EA, CI)
Included File (IF)
------------------
Program yang berisi himpunan function-function, tetapi lebih mengarah pada content berupa text.
Penggunaan IF lebih ringan dibanding Library.
Dapat digunakan oleh EA, CI, Script, dan Library.
=====================================================================
Belajar MQ4 #2 - MQ4 vs C
Sumber: Dokumentasi MetaEditor
Rekan-rekan yang berkecimpung di dunia programming, terutama yang menggunakan Bahasa C/C++, tentunya tidak asing dengan MQ4.
Ya, betul, karena MQ4 merupakan bahasa yang menggunakan dasar Bahasa C.
Tetapi tidak semua reserved word, operator, dan tata cara Bahasa C ada pada MQ4.
Yang tidak ada pada MQ4 adalah:
1. no address arithmetic;
Saya belum tahu persis apa maksudnya point yang satu ini, tapi dugaan saya adalah tidak ada penggunaan pointer pada MQ4.
2. no operator do ... while;
Yang ini saya pernah mengalami, waktu saya menggunakan do ... while dan di-compile langsung dapat error.
Ternyata MQ4 hanya mengenali while, tetapi tidak mengenali do.
do dianggap sebagai variabel yang tidak/belum dideklarasikan.
Sehingga struktur perulangan yang bisa digunakan hanya while dan for saja.
3. no operator goto ...;
Rupanya MQ4 sudah menerapkan "Pemrograman Terstruktur" jadi tidak lagi menggunakan goto.
Semua alur program harus diatur menurut kaidah "Terstruktur".
4. no operation of [condition]?[expression 1]:[expression 2];
Operator kondisi cepat juga tidak lagi ada.
Padahal menyenangkan juga menggunakan operator yang satu ini.
Code:
if (hujan) berenang; else berlari; ... sama dengan ... hujan ? berenang : berlari;
Terkadang tanpa ada structure, pengaturan struktur data menjadi rumit, karena tidak bisa membuat array of structure.
Tetapi masih dapat dipecahkan dengan menggunakan multiple-array.
Code:
struct abc { int a, b, c; }; abc data[10]; ... sama dengan ... int a[10], b[10], c[10];
======================================================================
Belajar MQ4 #3 - Switch
Saya tertarik untuk membahas perintah switch karena pernah mengalami error saat menggunakannya.
Kesalahan yang pernah saya lakukan adalah:
Code:
int _buy = OP_BUY; int sell = OP_SELL; switch(OrderType()) { case _buy: total_buy++; break; case _sell: total_sell++; break; }
Akhirnya diubah seperti ini baru error mau hilang:
Code:
switch(OrderType()) { case OP_BUY: total_buy++; break; case OP_SELL: total_sell++; break; }
Jika menggunakan if, maka tidak akan ada error, seperti berikut:
Code:
int _buy = OP_BUY; int sell = OP_SELL; if(OrderType() == _buy) total_buy++; else if(OrderType() == _sell) total_sell++;
Jelas tidak, masing-masing mempunyai kekuatan dan kecocokan pada suatu masalah.
switch
Sangat membantu saat menghadapi pilihan yang sifatnya seragam.
Misalnya, sebuah hari, jika sudah dinyatakan Senin, pasti tidak bisa dinyatakan hari yang lain.
Sebuah order, jika sudah bertipe OP_BUY, pasti pada saat yang sama bertype yang lain.
Dari sisi estetika, barangkali switch lebih "indah" dibanding if.
if
Sangat leluasa untuk segala jenis kondisi.
Penyusun kondisi tidak harus operand bertype integer seperti pada switch.
Mereka berdua, switch dan if, akan sangat baik bila disinergikan.
Karena, tidak semua switch bisa dilakukan secara mudah dengan if.
Sebaliknya, tidak semua if bisa dilakukan dengan switch.
======================================================================
Setting email di MT4
http://100k2.blogspot.com/2010/04/today-done-mt4-e-mail-setup.html
Today done mt4 e-mail setup
Previously, I thought setup the e-mail setting in mt4 is hard. Well, actually it is very easy. I completed it in less than 3 minutes.
From the forum posts I found using Google search, I found out most of the problems people faced are trying to figure out the correct e-mail setting. Some complained they can't set using gmail ( I read some commented that gmail can't be set to be used in mt4).
As a result, I use my own e-mail where I created using my domain hosting ( http://www.100k2.com/ ). I can create limitless e-mail accounts due to I chose the HostGator package which allows no-limit traffic,disk space,subdomain,domain,e-mail etc.
Here is the mt4 e-mail setup snapshot
Update: Somebody didn't understand the picture very well, explain a bit here
After you finished the setting, click the test button. It will try send an e-mail to your e-mail.
Hope this does help you. If you need e-mail account, you can contact me at support@100k2.com with subject "I need an e-mail account from 100k2 for mt4 usage". I will contact you to give you the e-mail account setup under yourname@100k2.com. This is to appreciate you for visiting my blog.
Due to increasing demand, some who never visit my blog heard from friends and directly send me e-mail to request a new e-mail account to be used on mt4. This is not fair to me. As such, I will only give the e-mail account to those who subscribe to my blog. Those who have already got their e-mail account from me can continue use it. This only apply to new e-mail account.
You can subsribe at the Subscribe to my blog at right column there
P.S: I have just finished wrote a simple EA to send e-mail to myself every 30 minutes ( can be configured xx minutes) to inform me on my account balance, equity,free margin,etc. Will test it on demo account 1st, then on my live account. If works, I might share it here.
Already tested can work, You need put the EA into a chart with time frame larger than or equal xx minutes you set on the EA.
eg : If you set received e-mail every 120 minutes, then you shall put the EA in H4 or D1 chart.
-------------------------------------------------------------------
You can download the EA_Email from here http://public.100k2.com/download/EA_E-mail.mq4
From the forum posts I found using Google search, I found out most of the problems people faced are trying to figure out the correct e-mail setting. Some complained they can't set using gmail ( I read some commented that gmail can't be set to be used in mt4).
As a result, I use my own e-mail where I created using my domain hosting ( http://www.100k2.com/ ). I can create limitless e-mail accounts due to I chose the HostGator package which allows no-limit traffic,disk space,subdomain,domain,e-mail etc.
Here is the mt4 e-mail setup snapshot
Update: Somebody didn't understand the picture very well, explain a bit here
Please put in following format From : xxx , yourname@100k2.com To : xxx , your-personal-mail the xxx you can put any you like Remember the format. The yourname@100k2.com pls replace with the email I gave you
After you finished the setting, click the test button. It will try send an e-mail to your e-mail.
Due to increasing demand, some who never visit my blog heard from friends and directly send me e-mail to request a new e-mail account to be used on mt4. This is not fair to me. As such, I will only give the e-mail account to those who subscribe to my blog. Those who have already got their e-mail account from me can continue use it. This only apply to new e-mail account.
You can subsribe at the Subscribe to my blog at right column there
P.S: I have just finished wrote a simple EA to send e-mail to myself every 30 minutes ( can be configured xx minutes) to inform me on my account balance, equity,free margin,etc.
Already tested can work, You need put the EA into a chart with time frame larger than or equal xx minutes you set on the EA.
eg : If you set received e-mail every 120 minutes, then you shall put the EA in H4 or D1 chart.
-------------------------------------------------------------------
You can download the EA_Email from here http://public.100k2.com/download/EA_E-mail.mq4
EA Online Programmer fxdreema
http://fxdreema.com
Some key features
- fxdreema is web-based, OS independent, no installations required and works with all modern browsers around (if IE, use 9, as lower versions has problems)
- fxdreema is based on the most simple and intuitive way of working with logic - visual blocks system
- fxdreema can create expert advisors for both MetaTrader 4 and MetaTrader 5 trading platforms
- fxdreema doesn't require any special programming skills, just basic understanding of how expert advisors work
- fxdreema has built-in list of many usable libraries and ability to easily create custom ones
- fxdreema is multi-currency and multi-timeframe ready. No matter what is your current chart currency and timeframe
- fxdreema can separate trades in groups and work with every group independently
- fxdreema is ECN/STP brokers ready. Auto-digits-detection available (i.e. 1 pip = 0.0001)
- fxdreema exports source code or compiled version of an expert advisors
- fxdreema supports basic MetaTrader indicators. You can also add and use your custom indicators collection
- fxdreema includes advanced candlestick pattern maker for converting specific candlestick patterns to a signals
- fxdreema has Library Studio where you can produce your own libraries. Yes, programming skills required here
- fxdreema has special betting system libraries group for easily trying the most famous betting strategies, like Martingale, Anti-Martingale, Fibonacci, D'alembert, Labouchère and others
- fxdreema is not yet finished, there are so many new features to be included in future
Condition :
Basic plan | Professional plan (start / continue) | |
Support MetaTrader 4? * | Yes * | Yes |
Support MetaTrader 5? * | Yes * | Yes |
Can export source code? | No | Yes |
Can export compiled file? * | Yes * | Yes |
Can share projects? * | Yes * | Yes |
Can save projects? | Yes | Yes |
Can use Library Studio? | Yes | Yes |
Can upload and use custom indicators? | Yes | Yes |
Can preview source code from block? | Yes | Yes |
* Maximum projects you can create | 10 | Unlimited |
* Maximum connections between blocks in project to be able to export | 8 | Unlimited |
* Maximum "Pattern" blocks in project to be able to export | 2 | Unlimited |
* Maximum shared project per day | 3 | Unlimited |
Free | Fair price starting from $7.9 a month. Register(Login) to see. |
Displaying a News Calendar at Chart MT4
This article contains the description of writing a simple and convenient indicator displaying in a working area the main economic events from external Internet resources. The indicator's operation looks like this:
Please for detail article to :
Please for detail article to :
Here is a list of requirements for the indicator:
- The indicator should independently (without a user's help) download a necessary file of the events calendar for the current week.
- The indicator should display all events (both passed and future) from this file in the form of vertical lines with news headlines.
- The indicator should trace the events' update on the external resource.
Technical Part
Let us use the website http://www.dailyfx.com/calendar/ as an external resource. The convenience of this resource is that it enables to download a calendar with .csv extension, so we avoid difficulties of working with html files. Here is a link of news for the current week: http://www.dailyfx.com/files/Calendar-11-21-2010.csv
Now let us dwell on the process of downloading the file from the Internet. This can be done using a well-known program GetRight. It can be downloaded at:http://www.getright.com/get.html or from the list of attachments to this article.
After you have downloaded the program, set up GetRight for downloading files into a necessary directory. It is the \files\html\ directory in the folder of your trading terminal. To do this, press F8 and change the writing in the field as described below:
Now let us dwell on the process of downloading the file from the Internet. This can be done using a well-known program GetRight. It can be downloaded at:http://www.getright.com/get.html or from the list of attachments to this article.
After you have downloaded the program, set up GetRight for downloading files into a necessary directory. It is the \files\html\ directory in the folder of your trading terminal. To do this, press F8 and change the writing in the field as described below:
Writing the Indicator
Now having answered some questions, we can start writing the indicator.
extern string HtmlAdress = "http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv"; extern string GetrightAdress = "c:\progra~1\getright\getright.exe"; #include <Time.mqh> #import "kernel32.dll" int WinExec(string NameEx, int dwFlags);
There are only two external variables: the address of the external resource (actually, you do not have to change this parameter) and the address of the GetRight program (if you have downloaded the program into another directory, I recommend to change the initial value in the indicator, in order not to change the value of the variable constantly at the indicator start). To start the file GetRight.exe we will have to use the function WinExec that can be imported from the Kernel32.dll library. The library Time.mqh contains functions for working with GMT.
void DownloadCalendar() { Print("Downloading "+HtmlAdress+" to experts\files\html\Calendar.csv"); WinExec(GetrightAdress+" /URL:"+HtmlAdress+" /FILE:Calendar.csv /W /O",0); }
As you can see, due to the usage of the GetRight program the function of downloading the file from the external resource looks like very simple.The parameter /W denotes that the process will not be returned into the program unless the file downloading is completed. The parameter /O denotes that if there is a file with the same name, it will be overwritten. Remember, if you have changed the settings of GetRight correctly, the calendar will be downloaded into \files\html\. And here are two additional functions:
datetime PerviousMonday(datetime d) { datetime res = d - (TimeDayOfWeek(d)-1)*24*60*60; return(res); } datetime ToDate(string stDate,string stTime) { string WeekDay = StringSubstr(stDate,0,3); int WeekPlus = 0; if (WeekDay=="Mon") WeekPlus=0; if (WeekDay=="Tue") WeekPlus=1; if (WeekDay=="Wed") WeekPlus=2; if (WeekDay=="Thu") WeekPlus=3; if (WeekDay=="Fri") WeekPlus=4; if (WeekDay=="Sat") WeekPlus=5; if (WeekDay=="Sun") WeekPlus=-1; datetime Res = PerviousMonday(GetTimeGMT())+WeekPlus*24*60*60; datetime Tm = StrToTime(stTime); Res=Res+TimeHour(Tm )*60*60+TimeMinute(Tm )*60+TimeSeconds(Tm ) -TimeHour(Res)*60*60-TimeMinute(Res)*60-TimeSeconds(Res); if (StringFind(stTime,"PM")>=0) Res+=12*60*60; Res=Res-GetShiftGMT(); return (Res); }
The function PerviousMonday() returns the starting date of the current week. The function ToDate() transfers the date and the time from the calendar format into datatime.
void GrabNews() { int file = FileOpen("\Html\Calendar.csv",FILE_READ|FILE_CSV,','); if (file==-1||FileSize(file)==0) return; int i=0; while (!FileIsEnding(file)) { string stDate=""; while (!FileIsEnding(file)&&stDate=="") stDate = FileReadString(file); string stTime = FileReadString(file); string stTimeZone = FileReadString(file); string stCurrency = FileReadString(file); string stDescription = FileReadString(file); string stImportance = FileReadString(file); string stActual = FileReadString(file); string stForecast = FileReadString(file); string stPrevious = FileReadString(file); datetime Date = ToDate(stDate,stTime); color c=Green; if (stImportance=="Low") c = Yellow; if (stImportance=="Medium") c = Orange; if (stImportance=="High") c = Red; ObjectCreate("CalendarText"+i, OBJ_TEXT, 0, Date, Close[0]); ObjectSet("CalendarText"+i, OBJPROP_COLOR, c); ObjectSetText("CalendarText"+i, stDate + " : "+ stDescription, 8); ObjectSet("CalendarText"+i, OBJPROP_ANGLE, 90); ObjectCreate("CalendarLine"+i, OBJ_VLINE, 0, Date, Close[0]); ObjectSet("CalendarLine"+i, OBJPROP_COLOR, c); ObjectSet("CalendarLine"+i, OBJPROP_STYLE, STYLE_DOT); ObjectSet("CalendarLine"+i, OBJPROP_BACK, true); ObjectSetText("CalendarLine"+i, stDescription, 8); i++; } Max = i; if (file!=-1) FileClose(file); }
The main procedure GrabNews() opens the downloaded file \Html\Calendar. csv, reads all event parameters and creates two objects for each news: a vertical line and a text. The event calendar is updated every 15 minute:
int start() { int counted_bars=IndicatorCounted(); //---- if (TimeCurrent()>LastTimeDownloading+15*60) { DeleteObjects(); DownloadCalendar(); LastTimeDownloading = TimeCurrent(); int file=-1; while (file==-1) file = FileOpen("\Html\Calendar.csv",FILE_READ|FILE_CSV,','); FileClose(file); GrabNews(); } //---- return(0); }
Conclusion
The article explained how to display an event calendar from an external resource onto a working area in the form of vertical lines. The indicator was intentionally written without any excessive parameters like filtering news according to their relevance or the correspondence of an event and the symbol of the current window.
P.S. I would like to point at an error in the calendar operation http://www.dailyfx.com/calendar/. Please note that sometimes events in the file .csv from the address
http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv are not identical with the page http://www.dailyfx.com/calendar/. This may happen to news released from 00:00 till 01:00 (GMT). In the file .csv such news are indicated 12 hours later.
Also please note, that the indicator uses external dll (kernell32.dll), so do not forget to enable the corresponding parameter in the indicator settings.
The file CalendarArticle.mq4 should be stored in the folder \experts\indicators. Time.mq4 should be stored in expers\library, Time.mqh - in experts\include.
Translated from Russian by MetaQuotes Software Corp.
Original article: http://articles.mql4.com/ru/520
Original article: http://articles.mql4.com/ru/520
Attachments:
CalendarArticle.mq4 (4.9 Kb) http://articles.mql4.com/download/3691
getright_setup.zip (4.7 Mb) http://articles.mql4.com/download/3692
CalendarArticle.mq4 (4.9 Kb) http://articles.mql4.com/download/3691
getright_setup.zip (4.7 Mb) http://articles.mql4.com/download/3692
Time.mq4 (2.0 Kb) http://articles.mql4.com/download/3693
Time.mqh (750 bytes) http://articles.mql4.com/download/3694
Time.mqh (750 bytes) http://articles.mql4.com/download/3694
Subscribe to:
Posts (Atom)