Price Data Components
Miscellaneous
0
Views
0
Downloads
0
Favorites
CloqS
//+------------------------------------------------------------------+
//|Ïîäøàìàíèë - Áàòóêåéðó 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);
}
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---