Modified from i-ParamonWorkTime.mq4 script in which FOREX trading hours of two sessions are drawn in background of the MT4 screen, the MT4 script ALN_WorkTime.mq4 (Asian - London - New York - Work Time) can draw three sessions of FOREX trading.It has been set to cover Asian Session (0:00 - 7:00), opening of London Session (8:30-10:30), and opening of New York Session (14:00-17:00) by default.
//+------------------------------------------------------------------+
//| i-ParamonWorkTime.mq4 |
//| ส่์ ศใ๎๐ ย. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 23.11.2005 ศํไ่๊เ๒๎๐ ๐เแ๎๗ๅใ๎ โ๐ๅ์ๅํ่ ฯเ๐เ์๎ํเ. |
//+------------------------------------------------------------------+
#property copyright "ส่์ ศใ๎๐ ย. aka KimIV"
#property link "http://www.kimiv.ru"
#property indicator_chart_window
//------- ยํๅ๘ํ่ๅ ๏เ๐เ์ๅ๒๐๛ ่ํไ่๊เ๒๎๐เ -------------------------------
extern int NumberOfDays = 50; // ส๎๋่๗ๅ๑๒โ๎ ไํๅ้
extern string Begin_1 = "0:00"; // Asian
extern string End_1 = "7:00";
extern color Color_1 = SaddleBrown;
extern color Color_1_Text = White;
extern string Begin_2 = "8:30"; // London
extern string End_2 = "10:30";
extern color Color_2 = SaddleBrown;
extern color Color_2_Text = White;
extern string Begin_3 = "14:00"; // New York
extern string End_3 = "17:00";
extern color Color_3 = SaddleBrown;
extern color Color_3_Text = White;
extern bool HighRange = true;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
DeleteObjects();
for (int i=0; i<NumberOfDays; i++) {
CreateObjects("PWT1"+i, Color_1);
CreateObjects("PWT2"+i, Color_2);
CreateObjects("PWT3"+i, Color_3);
CreateObjectsText("PWTT1"+i, Color_1_Text);
CreateObjectsText("PWTT2"+i, Color_2_Text);
CreateObjectsText("PWTT3"+i, Color_3_Text);
}
Comment("");
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
void deinit() {
DeleteObjects();
Comment("");
}
//+------------------------------------------------------------------+
//| ั๎็ไเํ่ๅ ๎แ๚ๅ๊๒๎โ ่ํไ่๊เ๒๎๐เ |
//| ฯเ๐เ์ๅ๒๐๛: |
//| no - ํเ่์ๅํ๎โเํ่ๅ ๎แ๚ๅ๊๒เ |
//| cl - ๖โๅ๒ ๎แ๚ๅ๊๒เ |
//+------------------------------------------------------------------+
void CreateObjects(string no, color cl) {
ObjectCreate(no, OBJ_RECTANGLE, 0, 0,0, 0,0);
ObjectSet(no, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(no, OBJPROP_COLOR, cl);
ObjectSet(no, OBJPROP_BACK, True);
}
void CreateObjectsText(string notext, color cltext) {
ObjectCreate(notext, OBJ_TEXT, 0, 0, 0);
ObjectSet(notext, OBJPROP_COLOR, cltext);
ObjectSet(notext, OBJPROP_BACK, True);
}
//+------------------------------------------------------------------+
//| ำไเ๋ๅํ่ๅ ๎แ๚ๅ๊๒๎โ ่ํไ่๊เ๒๎๐เ |
//+------------------------------------------------------------------+
void DeleteObjects() {
for (int i=0; i<NumberOfDays; i++) {
ObjectDelete("PWT1"+i);
ObjectDelete("PWT2"+i);
ObjectDelete("PWT3"+i);
ObjectDelete("PWTT1"+i);
ObjectDelete("PWTT2"+i);
ObjectDelete("PWTT3"+i);
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start() {
datetime dt=CurTime();
double factor = 0.0001;
int power = 4;
int round = 0;
// If yen pair
if (StringFind(Symbol(), "JPY", 0) > 0)
{
factor = 0.01;
power = 2;
}
if (Digits != 2 && Digits != 4) round = 1;
for (int i=0; i<NumberOfDays; i++) {
DrawObjects(dt, "PWT1"+i, Begin_1, End_1, "PWTT1"+i, Color_1_Text, factor, power, round);
DrawObjects(dt, "PWT2"+i, Begin_2, End_2, "PWTT2"+i, Color_2_Text, factor, power, round);
DrawObjects(dt, "PWT3"+i, Begin_3, End_3, "PWTT3"+i, Color_3_Text, factor, power, round);
dt=decDateTradeDay(dt);
while (TimeDayOfWeek(dt)>5) dt=decDateTradeDay(dt);
}
}
//+------------------------------------------------------------------+
//| ฯ๐๎๐่๑๎โ๊เ ๎แ๚ๅ๊๒๎โ ํเ ใ๐เ๔่๊ๅ |
//| ฯเ๐เ์ๅ๒๐๛: |
//| dt - ไเ๒เ ๒๎๐ใ๎โ๎ใ๎ ไํ |
//| no - ํเ่์ๅํ๎โเํ่ๅ ๎แ๚ๅ๊๒เ |
//| tb - โ๐ๅ์ ํเ๗เ๋เ ๑ๅ๑๑่่ |
//| te - โ๐ๅ์ ๎๊๎ํ๗เํ่ ๑ๅ๑๑่่ |
//+------------------------------------------------------------------+
void DrawObjects(datetime dt, string no, string tb, string te, string notext, color cltext, double factor, int power, int round) {
datetime t1, t2;
double p1, p2;
int b1, b2;
t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb);
t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te);
b1=iBarShift(NULL, 0, t1);
b2=iBarShift(NULL, 0, t2);
p1=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)];
p2=Low [Lowest (NULL, 0, MODE_LOW , b1-b2, b2)];
if (!HighRange) {p1=0; p2=2*p2;}
ObjectSet(no, OBJPROP_TIME1 , t1);
ObjectSet(no, OBJPROP_PRICE1, p1);
ObjectSet(no, OBJPROP_TIME2 , t2);
ObjectSet(no, OBJPROP_PRICE2, p2);
b1 = iBarShift(NULL, 0, t1, true);
if (b1 > 0)
{
if (b1 > 2) t1 = Time[b1 - 3];
p1 = High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)];
p2 = Low [Lowest (NULL, 0, MODE_LOW , b1-b2, b2)];
ObjectSet(notext, OBJPROP_TIME1 , t1);
ObjectSet(notext, OBJPROP_PRICE1, (p2 - (1 * factor)));
ObjectSetText(notext, "" + DoubleToStr(((p1 - p2) * MathPow(10, power)), round), 10, "Arial", cltext); // Changed "wt = " to ""
}
}
//+------------------------------------------------------------------+
//| ำ์ๅํ๘ๅํ่ๅ ไเ๒๛ ํเ ๎ไ่ํ ๒๎๐ใ๎โ๛้ ไๅํ |
//| ฯเ๐เ์ๅ๒๐๛: |
//| dt - ไเ๒เ ๒๎๐ใ๎โ๎ใ๎ ไํ |
//+------------------------------------------------------------------+
datetime decDateTradeDay (datetime dt) {
int ty=TimeYear(dt);
int tm=TimeMonth(dt);
int td=TimeDay(dt);
int th=TimeHour(dt);
int ti=TimeMinute(dt);
td--;
if (td==0) {
tm--;
if (tm==0) {
ty--;
tm=12;
}
if (tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12) td=31;
if (tm==2) if (MathMod(ty, 4)==0) td=29; else td=28;
if (tm==4 || tm==6 || tm==9 || tm==11) td=30;
}
return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti));
}
//+------------------------------------------------------------------+
Download the files here [ ALN_WorkTime.ex4 ] [ ALN_WorkTime.mq4 ]
ลงทุนเหมือนขุนหมู ดู [ pb6.readstockgraph.com ]