//+------------------------------------------------------------------+ //|Подшаманил - Батукейру Cloq.mq4 | //| Derk Wehler | //| derkwehler@gmail.com | //+------------------------------------------------------------------+ #property copyright "Derk Wehler" #property link "derkwehler@gmail.com" //============================================================================= // Instructions // CloqCorner - 0 = top left, 1 = top right, 2 = bottom left, 3 = bottom right //============================================================================== #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- extern int CloqCorner =2; extern bool DispGMT =true; extern bool DispLocal =false; extern bool DispLondon =true; extern bool DispTokyo =true; extern bool DispNY =true; extern bool DispChicago =true; extern bool DispBroker =true; extern color LabelColor =Silver; extern color ClockColor =Silver; //---- int Offset=100; //---- buffers double ExtMapBuffer1[]; int LondonTZ = 0; int TokyoTZ = 9; int NewYorkTZ =-5; int ChicagoTZ =12; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- //Print("TimeZoneLocal: ",TimeZoneLocal()); ////Print("TimeZoneServer: ",TimeZoneServer()); datetime brokerTime =TimeCurrent(); datetime GMT =TimeGMT(); datetime local =TimeLocal(); datetime london =GMT + (LondonTZ * 3600); datetime tokyo =GMT + (TokyoTZ * 3600); datetime newyork =GMT + (NewYorkTZ * 3600); datetime chicago =GMT + (ChicagoTZ * 3600); //---- string GMTs =TimeToStr(GMT, TIME_MINUTES); string locals =TimeToStr(TimeLocal(), TIME_MINUTES); string londons =TimeToStr(london, TIME_MINUTES ); string tokyos =TimeToStr(tokyo, TIME_MINUTES); string newyorks=TimeToStr(newyork, TIME_MINUTES); string chicagos=TimeToStr(chicago, TIME_MINUTES); string brokers =TimeToStr(TimeCurrent(), TIME_MINUTES); int m, c; m = Time[0]+Period()*60-CurTime(); m = (m-m%60)/60; c = m/60; if(c < 0) { c = 0; } if(m > 59) { m = m%60; } string clock = TimeToStr(StrToTime(c + ":" + m), TIME_MINUTES); //---- if (DispLocal) { ObjectSetText( "locl", "Местное:", 10, "Arial", LabelColor ); ObjectSetText( "loct", locals, 10, "Arial", ClockColor ); } if (DispGMT) { if(TimeHour(GMT)>=0 && TimeHour(GMT)<=7 ) { ObjectSetText( "gmtl", "Азиатская сессия", 10, "Arial", LabelColor ); ObjectSetText( "gmtt", GMTs, 10, "Arial", ClockColor ); } if(TimeHour(GMT)>=7 && TimeHour(GMT)<=13 ) { ObjectSetText( "gmtl", "Европейская сессия", 10, "Arial", LabelColor ); ObjectSetText( "gmtt", GMTs, 10, "Arial", ClockColor ); } if(TimeHour(GMT)>=13 && TimeHour(GMT)<=16 ) { ObjectSetText( "gmtl", "Евро-Американская сессия", 10, "Arial", LabelColor ); ObjectSetText( "gmtt", GMTs, 10, "Arial", ClockColor ); } if(TimeHour(GMT)>=16 && TimeHour(GMT)<=21 ) { ObjectSetText( "gmtl", "Американская сессия", 10, "Arial", LabelColor ); ObjectSetText( "gmtt", GMTs, 10, "Arial", ClockColor ); } if(TimeHour(GMT)>=21 && TimeHour(GMT)<=24 ) { ObjectSetText( "gmtl", "Тихоокеанская сессия", 10, "Arial", LabelColor ); ObjectSetText( "gmtt", GMTs, 10, "Arial", ClockColor ); } } //-----------------------------------------------------// if (DispNY) { if(TimeHour(GMT) >= 23 && TimeHour(GMT) <= 24) { ObjectSetText( "nyl", "23:00 - начало торговой сессии в Сиднее, торговля ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 0 && TimeHour(GMT) <= 1) { ObjectSetText( "nyl", "24:00 - открытие Токио, торговля приобретает динамику, стоит ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 1 && TimeHour(GMT) <= 3) { ObjectSetText( "nyl", "01:00 - 01:30 - перед китайской сессией чаще всего евро вниз ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 3 && TimeHour(GMT) <= 6) { ObjectSetText( "nyl", "02:30 - 06:00 - сделки могут быть разнонаправленными по EURUSD ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 6 && TimeHour(GMT) <= 7) { ObjectSetText( "nyl", "06:00 - закрывается Токио, если Евро активно опускалось ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 7 && TimeHour(GMT) <= 9) { ObjectSetText( "nyl", "07:00 - открытие Лондона и Европейских бирж ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 9 && TimeHour(GMT) <= 11) { ObjectSetText( "nyl", "09:00 - закрытие Сингапура и конец азиатской сессии - почти ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 11 && TimeHour(GMT) <= 13) { ObjectSetText( "nyl", "11:00 - 13:00 - завершение торговых оборотов на нефтяных ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 13 && TimeHour(GMT) <= 15) { ObjectSetText( "nyl", "13:00-13:30 - время позакрывать все ненадёжные позиции ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 15 && TimeHour(GMT) <= 16) { ObjectSetText( "nyl", "15:30(16:30) - закрывается Европейская сессия ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 16 && TimeHour(GMT) <= 22) { ObjectSetText( "nyl", "19:00-20:00 - последний час работы Американской сессии ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 22 && TimeHour(GMT) <= 23) { ObjectSetText( "nyl", "В первые часы ночи чаще откат EUR/USD вниз до открытия Токио ", 10, "Arial", DodgerBlue ); } } if (DispChicago) { if(TimeHour(GMT) >= 23 && TimeHour(GMT) <= 24) { ObjectSetText( "chil", "потихоньку набирает обороты ввиду открытия через час Токио ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 0 && TimeHour(GMT) <= 1) { ObjectSetText( "chil", "учесть факт наличия корпоративных отношений между азиатскими ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 1 && TimeHour(GMT) <= 3) { ObjectSetText( "chil", "01:30 - 02:30 - открытие Шанхая и Гонконга ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 3 && TimeHour(GMT) <= 6) { ObjectSetText( "chil", "Азиатские экспортёры конвертируют часть своей прибыли ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 6 && TimeHour(GMT) <= 7) { ObjectSetText( "chil", "до этого момента, то после закрытия Токио, ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 7 && TimeHour(GMT) <= 9) { ObjectSetText( "chil", "По наблюдениям чаще продажи Евро преобладают в первые часы ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 9 && TimeHour(GMT) <= 11) { ObjectSetText( "chil", "сразу или в течение часа рывок по евро, смена тренда до 11:30", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 11 && TimeHour(GMT) <= 13) { ObjectSetText( "chil", "торговых площадках, Дубаи, Катар, Эмираты и др. ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 13 && TimeHour(GMT) <= 15) { ObjectSetText( "chil", "Евро чаще опускается перед открытием Америки и Канады в 13:30 ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 15 && TimeHour(GMT) <= 16) { ObjectSetText( "chil", "к моменту закрытия Лондона, Цюриха и Франкфурта ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 16 && TimeHour(GMT) <= 22) { ObjectSetText( "chil", "существовавший тренд часто возобновляется до 21:00 - 21:30 ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 22 && TimeHour(GMT) <= 23) { ObjectSetText( "chil", "как правило в том случае, если цена до 21-22 UTC шла вверх. ", 10, "Arial", DodgerBlue ); } } if (DispLondon) { if(TimeHour(GMT) >= 23 && TimeHour(GMT) <= 24) { ObjectSetText( "lonl", "Перед Токио смело две ставки в разные стороны ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 0 && TimeHour(GMT) <= 1) { ObjectSetText( "lonl", "инвесторами, они действуют слаженно и чётко, ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 1 && TimeHour(GMT) <= 3) { ObjectSetText( "lonl", "евро чаще всего вверх в течение часа ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 3 && TimeHour(GMT) <= 6) { ObjectSetText( "lonl", "как в доллары, так и в евро ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 6 && TimeHour(GMT) <= 7) { ObjectSetText( "lonl", "китайцы гонят Евро вверх ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 7 && TimeHour(GMT) <= 9) { ObjectSetText( "lonl", "09:00 - возможен рывок по евро сразу или чуть с запозданием ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 9 && TimeHour(GMT) <= 11) { ObjectSetText( "lonl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 11 && TimeHour(GMT) <= 13) { ObjectSetText( "lonl", "поскольку торговля нефтью идёт за доллары, чаще всего рост Евро ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 13 && TimeHour(GMT) <= 15) { ObjectSetText( "lonl", "Даже не пытайтесь трактовать новости, сплошная чистая спекуляция ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 15 && TimeHour(GMT) <= 16) { ObjectSetText( "lonl", "сформированный тренд часто меняется на противоположный ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 16 && TimeHour(GMT) <= 23) { ObjectSetText( "lonl", "", 10, "Arial", DodgerBlue ); } } if (DispTokyo) { if(TimeHour(GMT) >= 23 && TimeHour(GMT) <= 24) { ObjectSetText( "tokl", " с профитами по 5 - 10 пунктов ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 0 && TimeHour(GMT) <= 1) { ObjectSetText( "tokl", "если идут в одном направлении - то все сразу ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 1 && TimeHour(GMT) <= 3) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 3 && TimeHour(GMT) <= 6) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 6 && TimeHour(GMT) <= 7) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 7 && TimeHour(GMT) <= 9) { ObjectSetText( "tokl", "европейцам никто не мешает, часто, сбивают азиатские стопы ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 9 && TimeHour(GMT) <= 11) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 11 && TimeHour(GMT) <= 13) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 13 && TimeHour(GMT) <= 15) { ObjectSetText( "tokl", "очень сложно что - либо предсказать ", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 15 && TimeHour(GMT) <= 16) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } if(TimeHour(GMT) >= 16 && TimeHour(GMT) <= 23) { ObjectSetText( "tokl", "", 10, "Arial", DodgerBlue ); } } if (DispBroker) { ObjectSetText( "brol", "Брокер ", 10, "Arial", LabelColor ); ObjectSetText( "brot", brokers, 10, "Arial", ClockColor ); } ObjectSetText( "clockEnd1", "Таймер свечи ", 10, "Arial", LabelColor ); ObjectSetText( "clockEnd2", clock, 10, "Arial", Lime ); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int ObjectMakeLabel(string n, int xoff, int yoff) { ObjectCreate(n, OBJ_LABEL, 0, 0, 0); ObjectSet(n, OBJPROP_CORNER, CloqCorner); ObjectSet(n, OBJPROP_XDISTANCE, xoff); ObjectSet(n, OBJPROP_YDISTANCE, yoff); ObjectSet(n, OBJPROP_BACK, true); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, ExtMapBuffer1); //---- int top=Offset; if (DispLocal) { ObjectMakeLabel("locl", 90, top ); ObjectMakeLabel("loct", 45, top ); top-=15; } if (DispGMT) { ObjectMakeLabel("gmtl", 90, top ); ObjectMakeLabel("gmtt", 45, top ); top-=15; } if (DispNY) { ObjectMakeLabel("nyl", 90, top ); top-=15; } if (DispChicago) { ObjectMakeLabel("chil", 90, top ); top-=15; } if (DispLondon) { ObjectMakeLabel("lonl", 90, top ); top-=15; } if (DispTokyo) { ObjectMakeLabel("tokl", 90, top ); top-=15; } if (DispBroker) { ObjectMakeLabel("brol", 90, top ); ObjectMakeLabel("brot", 45, top ); top-=15; } if (IsDST()) { TokyoTZ+=0; NewYorkTZ += 1; LondonTZ += 1; ChicagoTZ += 1; } ObjectMakeLabel("clockEnd1", 90, top ); ObjectMakeLabel("clockEnd2", 45, top ); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int deinit() { ObjectDelete( "locl" ); ObjectDelete( "loct" ); ObjectDelete( "nyl" ); ObjectDelete( "nyt" ); ObjectDelete( "chil" ); ObjectDelete( "chit" ); ObjectDelete( "gmtl" ); ObjectDelete( "gmtt" ); ObjectDelete( "lonl" ); ObjectDelete( "lont" ); ObjectDelete( "tokl" ); ObjectDelete( "tokt" ); ObjectDelete( "brol" ); ObjectDelete( "brot" ); return(0); } //================================================================================================= //=================================== Timezone Functions ====================================== //================================================================================================= #import "kernel32.dll" int GetTimeZoneInformation(int& TZInfoArray[]); #import //---- #define TIME_ZONE_ID_UNKNOWN 0 #define TIME_ZONE_ID_STANDARD 1 #define TIME_ZONE_ID_DAYLIGHT 2 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsDST() // DST is the one over the winter { int TZInfoArray[43]; switch(GetTimeZoneInformation(TZInfoArray)) { case TIME_ZONE_ID_UNKNOWN: Print("WARNING: TIMEZONE ID UNKNOWN, Cloq may give wrong time! Returning FALSE"); return(false); case TIME_ZONE_ID_STANDARD: Print("TZ ---> STANDARD"); return(false); case TIME_ZONE_ID_DAYLIGHT: Print("TZ ---> DAYLIGHT SAVINGS"); return(true); default: Print("Unkown return value from GetTimeZoneInformation in kernel32.dll. Returning FALSE"); return(false); } } // Local timezone in hours, adjusting for daylight saving //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double TimeZoneLocal() { int TZInfoArray[43]; switch(GetTimeZoneInformation(TZInfoArray)) { case TIME_ZONE_ID_UNKNOWN: //Print("Error obtaining PC timezone from GetTimeZoneInformation in kernel32.dll. Returning 0"); return(0); case TIME_ZONE_ID_STANDARD: // //Print("PC timezone is STANDARD"); return(TZInfoArray[0]/(-60.0)); case TIME_ZONE_ID_DAYLIGHT: // //Print("PC timezone is DAYLIGHT"); return((TZInfoArray[0]+TZInfoArray[42])/(-60.0)); default: //Print("Unkown return value from GetTimeZoneInformation in kernel32.dll. Returning 0"); return(0); } } // Server timezone in hours //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double TimeZoneServer() { int ServerToLocalDiffMinutes=(TimeCurrent()-TimeLocal())/60; // round to nearest 30 minutes to allow for inaccurate PC clock int nHalfHourDiff=MathRound(ServerToLocalDiffMinutes/30.0); ServerToLocalDiffMinutes=nHalfHourDiff*30; return(TimeZoneLocal() + ServerToLocalDiffMinutes/60.0); } // Uses local PC time, local PC timezone, and server time to calculate GMT time at arrival of last tick //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ datetime TimeGMT() { // two ways of calculating // 1. From PC time, which may not be accurate // 2. From server time. Most accurate except when server is down on weekend datetime dtGmtFromLocal=TimeLocal() - TimeZoneLocal()*3600; datetime dtGmtFromServer=TimeCurrent() - TimeZoneServer()*3600; //---- //Print("TimeZoneLocal returned: ", TimeZoneLocal()); // return local-derived value if server value is out by more than 5 minutes, eg during weekend if (dtGmtFromLocal > dtGmtFromServer + 300) { return(dtGmtFromLocal); } else { return(dtGmtFromServer); } } //+------------------------------------------------------------------+