Axel-Pivot
Download scriptThis script is a specialized financial tool designed to identify and display specific price levels known as Pivot Points across three major global markets: Asia, Europe, and the USA. Instead of providing a single general market average, it breaks down these levels based on the unique trading sessions of these geographic regions.
Core Functionality
The logic operates by automatically calculating "Pivot" prices, which are essential reference points used by traders to determine potential support and resistance levels. The script calculates these values based on three primary pieces of data from previous market activity:
- The Highest Price: The peak reached during the session.
- The Lowest Price: The bottom reached during the session.
- The Closing Price: The final price at which the session ended.
By averaging these three values, the tool provides a "Pivot" level that represents the equilibrium point for each specific region.
Regional Logic & Time Management
One of the primary features of this script is its ability to distinguish between different global time zones. It handles the following complexities automatically:
- Session Specificity: It calculates distinct pivots for Asia, Europe, and the USA separately, recognizing that a "Pivot" in Tokyo may be very different from one in New York.
- Time Zone Offsets: The script accounts for your specific broker's server time versus Greenwich Mean Time (GMT).
- Daylight Savings: It includes a toggle to adjust calculations based on whether the current season is Summer or Winter time, ensuring the accuracy of the data regardless of the time of year.
- Historical Data Processing: The tool scans back through historical price data (configurable by the user) to ensure that the lines displayed on your chart are consistent with past market movements.
Visual Display and User Experience
The script is designed to be informative without cluttering your workspace. It provides the following visual outputs:
- Dynamic Chart Lines: It draws horizontal dashed lines on your chart representing the Pivot levels for all three regions.
- On-Screen Dashboard: If enabled, the script displays a text dashboard on your screen. This allows you to see the exact numerical values for the Pivot, High, Low, and Close prices for each region simultaneously without having to hover over the lines.
- Customizable Layout: Users can choose where the text information appears on the screen (corners), move it using X and Y coordinates, and customize the colors to match their preferred trading layout.
Summary of Workflow
- Data Collection: The script looks at the high, low, and close prices for specific time windows in Asia, Europe, and the USA.
- Calculation: It applies a mathematical formula to find the mean Pivot point for each of those three regions.
- Mapping: It identifies exactly which bars on your chart correspond to those sessions.
- Rendering: It draws the result as clear lines on your chart and updates the on-screen text labels in real-time as new data becomes available.
//+-------------------------------------------------------------------+
//| MF_Pivot AXEL 0-2254.mq4 |
//| Copyright © YuraZ-VAF-Zhunko-Nestor|
//| MF YURAZ yzh@mail.ru |
//| MF VAF vazh-af@inbox.ru |
//| MF ZHUNKO zhunko@mail.ru |
//| MF NESTOR a_nesterchuk@mail.ru |
//+-------------------------------------------------------------------+
//| Èäèêàòîð ðàçðàáîòàí ïî ìàòåðèàëàì ÀÊÀÄÅÌÈÈ ÌÔ. |
//| ÈÑÏÐÀÂËÅÍÍÀß ÂÅÐÑÈß. |
//| Ñîâïàäàåò ñ òî÷íîñòüþ 5ï ñ óðîâíÿìè DJ îò Axel Rudolph ! |
//| Áåðåò äàííûå ñ M1. |
//| ÂÍÈÌÀÅÍÈÅ! |
//| Åñëè âàøå ÄÖ äà¸ò íå òî÷íûå êîòèðîâêè - PIVOT íå áóäåò ñîâïàäàòü. |
//+-------------------------------------------------------------------+
//| ÈÇÌÅÍÅÍÈß è ÄÎÏÎËÍÅÍÈß. |
//| 1.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-101 îò 06.09.2006 . |
//| 1.1.Âîçìîæíî ïåðåìåùåíèå âñåé íàäïèñè ïî ýêðàíó êîîðäèíàòàìè XY |
//| 1.2.Ââåäåíû íàñòðîéêè ïî óìîë÷àíèþ. |
//| 1.3.Ââåäåíà íàñòðîéêà öâåòà òåêñòà. |
//| 2.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-102 îò 08.09.2006 . |
//| 2.1.Èñïðàâëåíà îøèáêà îòðèñîâêè ëèíèè â íåêîòîðûõ òåðìèíàëàõ. |
//| 3.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-103 îò 09.09.2006 . |
//| 3.1.Èçìåí¸í ïåðåêëþ÷àòåëü âûâîäà òåêñòà íà ëîãè÷åñêèé. |
//| 3.2.Èçìåíåíû íàçâàíèÿ âíåøíèõ ïåðåìåííûõ. |
//| 3.3.Ââåäåíû îòñóòñòâóþùèå êîìåíòàðèè â èñõîäíèê. |
//| 3.4.Èçìåíåíà íàñòðîéêà ðàçíèöû âðåìåíè ìåæäó ÌÒ4 è GMT. |
//| 4.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-113 îò 14.09.2006 . |
//| 4.1.Ââåäíà íå÷óâñòâèòåëåííîñòü ê ïðîïóùåííûì áàðàì. |
//| 5.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-114 îò 17.09.2006 . |
//| 5.1.Óïðîùåíû íàñòðîéêè âðåìåíè êîíöà ïåðèîäà ðàñ÷¸òà è âðåìåíè |
//| íà÷àëà îòðèñîâêè ëèíèè. |
//| 5.2.Íà âàëþòíûõ ïàðàõ, ñîäåðæàùèõ JPY, â òåêñòîâîé ñòðîêå öèôðîâîå|
//| çíà÷åíèå ïîñëå çàïÿòîé ñîäåðæèò äâà çíàêà. Íà îñòàëüíûõ |
//| âàëþòíûõ ïàðàõ - ÷åòûðå. |
//| 6.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-214 îò 18.09.2006 . |
//| 6.1 Äîðàáîòêà âûâîäà êîëè÷åñòâà çíàêîâ äëÿ âàëþòíûõ ïàð â |
//| òåêñòîâîì îòîáðàæåíèè. |
//| 7.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-224 îò 19.09.2006 . |
//| 7.1.Óñòðàíåíà îøèáêà íà÷àëà ðàñ÷¸òà â ïîíåäåëüíèê. |
//| 8.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-225 îò 24.09.2006 . |
//| 8.1.Óñòðàíåíà îøèáêà íà÷àëà ðàñ÷¸òà â àçèàòñêóþ ñåññèþ. |
//| 8.2.Ïðè îòñóòñòâèè äàííûõ äëÿ ðàñ÷¸òà âìåñòî "99999999,0000" |
//| âûâîäèòñÿ "0,0000". |
//| 9.Äîïîëíåíèÿ â âåðñèè MF_Pivot AXEL 0-2254 îò 06.10.2006 . |
//| 9.1.Êîððåêòíîå îòîáðàæåíèå ïîêàçàíèé â çàâèñèìîñòè îò èçìåíåíèÿ |
//| ïàðàìåòðîâ ñòàðòà ðàñ÷¸òà. |
//| 9.2.Îïòèìèçàöèÿ êîäà ïðåîáðàçîâàíèé. |
//| 9.3.Èçìåíåíèå àëãîðèòìà ðàñ÷¸òà ìèíèìóìîâ è ìàêñèìóìîâ ñåññèé. |
//+-------------------------------------------------------------------+
#property copyright "Copyright © 2006 YuraZ-VAF-Zhunko-Nestor"
#property link "yzh@mail.ru ; vazh-af@inbox.ru ; zhunko@mail.ru ; a_nesterchuk@mail.ru"
#property indicator_chart_window
#property indicator_buffers 1
//Öâåò ïî óìîë÷àíèþ.
#property indicator_color1 Lavender
//Ñòèëü ïî óìîë÷àíèþ.
#property indicator_style1 STYLE_DASH
//Òîëùèíà ëèíèè ïî óìîë÷àíèþ.
#property indicator_width1 1
//----Ëîêàëèçàöèÿ---------------------------------------------------------------------------------------------------------------------------------
extern int Äíåé = 7; // Êîëè÷åñòâî ðàñ÷èòûâàåìûõ äíåé.
extern double Âðåìÿ_ÄÖ = 2; // Ðàçíèöà âî âðåìåíè ìåæäó ÌÒ4 è GMT.
extern bool Time_Summer = false; // true - ëåòíåå âðåìÿ / false - çèìíåå âðåìÿ.
//----Íàñòðîéêà äëèíû ïåðèîäà ðàñ÷¸òà-------------------------------------------------------------------------------------------------------------
extern double Asia_ïåðèîä_ðàñ÷¸òà_÷àñ = 12 ; // Ïåðèîä ðàñ÷¸òà â ÷àñàõ äëÿ Àçèè.
extern double Europe_ïåðèîä_ðàñ÷¸òà_÷àñ = 9 ; // Ïåðèîä ðàñ÷¸òà â ÷àñàõ äëÿ Åâðîïû.
extern double USA_ïåðèîä_ðàñ÷¸òà_÷àñ = 6 ; // Ïåðèîä ðàñ÷¸òà â ÷àñàõ äëÿ Àìåðèêè.
//----Íàñòðîéêà âðåìåíè êîíöà ïåðèîäà ðàñ÷¸òà è âðåìåíè íà÷àëà îòðèñîâêè ëèíèè--------------------------------------------------------------------
extern string Start_ASIA = "00:15" ; // Âðåìÿ êîíöà ïåðèîäà ðàñ÷¸òà äëÿ Àçèè ïî GMT.
// Âðåìÿ íà÷àëà îòðèñîâêè ëèíèè "PIVOT DJ ASIA" (ó÷èòûâàþòñÿ òîëüêî ÷àñû, ìèíóòû îòáðàñûâàþòñÿ).
extern string Start_EUROPE_Winter = "06:15" ; // Âðåìÿ êîíöà ïåðèîäà ðàñ÷¸òà äëÿ Åâðîïû ïî GMT.
// Âðåìÿ íà÷àëà îòðèñîâêè ëèíèè "PIVOT DJ EUROPE" (ó÷èòûâàþòñÿ òîëüêî ÷àñû, ìèíóòû îòáðàñûâàþòñÿ).
extern string Start_USA_Winter = "12:00" ; // Âðåìÿ êîíöà ïåðèîäà ðàñ÷¸òà äëÿ Àìåðèêè ïî GMT.
// Âðåìÿ íà÷àëà îòðèñîâêè ëèíèè "PIVOT DJ USA" (ó÷èòûâàþòñÿ òîëüêî ÷àñû, ìèíóòû îòáðàñûâàþòñÿ).
//----Íàñòðîéêà îòîáðàæåíèÿ-----------------------------------------------------------------------------------------------------------------------
extern int Óãîë = 0 ; // Ðàñïîëîæåíèå èíäèêàòîðà : 0 = ñâåðõó ñëåâà, 1 = ñâåðõó ñïðàâà, 2 = ñíèçó ñëåâà, 3 = ñíèçó ñïðàâà.
extern int XD = 250 ; // Ñìåùåíèå îò óãëà ïî X.
extern int YD = 0 ; // Ñìåùåíèå îò óãëà ïî Y.
extern bool TEXT_Visible = true ; // true - îòîáðàæàòü òåêñò; false - íå îòîáðàæàòü òåêñò.
extern color TextColor = Lavender ; // Öâåò òåêñòà.
//================================================================================================================================================
double nClose = 0 ;
double nPivot = 0 ;
double nMaxHigh = 0 ;
double nMinLow = 0 ;
//---------------------------------------------------------------
double PBuffer[];
//---------------------------------------------------------------
static string ss1 = "Asia DJ Pivot" ;
static string ss2 = "Europe DJ Pivot" ;
static string ss3 = "Usa DJ Pivot" ;
static string ss4 = "Downloads" ;
//===============================================================
int init()
{
if ( TEXT_Visible == true )
{
ObjectCreate(ss4, OBJ_LABEL, 0, 0, 0);
ObjectSet(ss4, OBJPROP_XDISTANCE, XD);
ObjectSet(ss4, OBJPROP_YDISTANCE, YD);
ObjectSet(ss4, OBJPROP_CORNER, Óãîë);
ObjectCreate(ss1, OBJ_LABEL, 0, 0, 0);
ObjectSet(ss1, OBJPROP_XDISTANCE, XD);
ObjectSet(ss1, OBJPROP_YDISTANCE, 10+YD);
ObjectSet(ss1, OBJPROP_CORNER, Óãîë);
ObjectCreate(ss2, OBJ_LABEL, 0, 0, 0);
ObjectSet(ss2, OBJPROP_XDISTANCE, XD);
ObjectSet(ss2, OBJPROP_YDISTANCE, 20+YD);
ObjectSet(ss2, OBJPROP_CORNER, Óãîë);
ObjectCreate(ss3, OBJ_LABEL, 0, 0, 0);
ObjectSet(ss3, OBJPROP_XDISTANCE, XD);
ObjectSet(ss3, OBJPROP_YDISTANCE, 30+YD);
ObjectSet(ss3, OBJPROP_CORNER, Óãîë);
}
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,PBuffer);
return(0);
}
//===============================================================
int deinit()
{
if ( TEXT_Visible == true )
{
ObjectDelete(ss4);
ObjectDelete(ss1);
ObjectDelete(ss2);
ObjectDelete(ss3);
}
return(0);
}
//===============================================================
void funPivot(int pDay, int pMonth, int pYear, double PeriodHour, double hourMT4, double minuteMT4)
{
datetime dTimeMT4end;
datetime dTimeMT4begin;
string sTimeMT4 = StringConcatenate(DoubleToStr( pYear, 0),".",DoubleToStr( pMonth , 0),".",DoubleToStr( pDay , 0)," ",
DoubleToStr( hourMT4, 0),":",DoubleToStr( minuteMT4, 0) ) ;
dTimeMT4end = StrToTime(sTimeMT4);
dTimeMT4begin = dTimeMT4end - PeriodHour*3600+60 ;
if (TimeDayOfWeek (dTimeMT4begin) ==0)
dTimeMT4begin = dTimeMT4begin - 172800;
int shiftend=iBarShift(NULL,PERIOD_M1,dTimeMT4end);
int shiftbegin=iBarShift(NULL,PERIOD_M1,dTimeMT4begin);
nMinLow =iLow(NULL,PERIOD_M1,Lowest ( NULL, PERIOD_M1, MODE_LOW, shiftbegin-shiftend, shiftend));
nMaxHigh= iHigh(NULL,PERIOD_M1,Highest( NULL, PERIOD_M1, MODE_HIGH, shiftbegin-shiftend, shiftend));
nClose=iClose(NULL,PERIOD_M1,shiftend);
nPivot = (nMaxHigh+nMinLow+nClose)/3;
return;
}
//================================================================
int start()
{
int mDay;
int mMonth ;
int mYear ;
string mYearMonthDay;
//----------------------------------------------------------------
static double PeriodHour_ ; // = Asia_ïåðèîä_ðàñ÷¸òà_÷àñ;
static double hourMT4_ ; // = Asia_êîíåö_ïåðèîäà_MT4_÷àñ;
static double minuteMT4_ ; // = Asia_êîíåö_ïåðèîäà_MT4_ìèí;
static double nPivotEurope; // = nPivot;
static double nMaxHighE ; // = nMaxHigh;
static double nMinLowE ; // = nMinLow;
static double nCloseE ; // = nClose;
static double nPivotUSA ; // = nPivot;
static double nMaxHighU ; // = nMaxHigh;
static double nMinLowU ; // = nMinLow;
static double nCloseU ; // = nClose;
static double nPivotASIA ; // = nPivot;
static double nMaxHighA ; // = nMaxHigh;
static double nMinLowA ; // = nMinLow;
static double nCloseA ; // = nClose;
//-----------------------------------------------------------------
datetime mDatBegin;
if (Bars != IndicatorCounted())
{
if (Äíåé == 0 )
{
deinit();
return(0);
}
else
{
mDatBegin = StrToTime(StringConcatenate(TimeToStr(CurTime(),TIME_DATE)," 00:00")) - ((Äíåé-1) * 86400);
}
//==================================================================
for ( int i =0; mDatBegin < CurTime(); mDatBegin += 86400 )
{
mYear = TimeYear( mDatBegin);
mMonth = TimeMonth( mDatBegin);
mDay = TimeDay( mDatBegin);
mYearMonthDay = StringConcatenate(DoubleToStr (mYear,0) , "." , DoubleToStr (mMonth, 0) , "." , DoubleToStr (mDay , 0));
//----------------------------------------------------------------------------------------------------------------------------------------------------------------
Start_ASIA=StringTrimRight(StringTrimLeft(Start_ASIA));
Start_EUROPE_Winter=StringTrimRight(StringTrimLeft(Start_EUROPE_Winter));
Start_USA_Winter=StringTrimRight(StringTrimLeft(Start_USA_Winter));
if (Time_Summer==true) int TWS =1;
else TWS=0;
int Asia_end_MT4_hour = StrToDouble(StringSubstr(Start_ASIA, 0, 2)) + Âðåìÿ_ÄÖ;
int Asia_end_MT4_min = StrToDouble(StringSubstr(Start_ASIA, 3, 2)) ;
int Europe_end_MT4_hour_pivot = StrToDouble (StringSubstr(Start_EUROPE_Winter, 0, 2)) + Âðåìÿ_ÄÖ;
int Europe_end_MT4_hour_session = StrToDouble (StringSubstr(Start_EUROPE_Winter, 0, 2)) + Âðåìÿ_ÄÖ - TWS;
int Europe_end_MT4_min = StrToDouble (StringSubstr(Start_EUROPE_Winter, 3, 2)) ;
int USA_end_MT4_hour_pivot = StrToDouble (StringSubstr(Start_USA_Winter, 0, 2)) + Âðåìÿ_ÄÖ - TWS;
int USA_end_MT4_hour_session = StrToDouble (StringSubstr(Start_USA_Winter, 0, 2)) + Âðåìÿ_ÄÖ - TWS;
int USA_end_MT4_min = StrToDouble (StringSubstr(Start_USA_Winter, 3, 2)) ;
//----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
PeriodHour_ = Asia_ïåðèîä_ðàñ÷¸òà_÷àñ;
hourMT4_ = Asia_end_MT4_hour;
minuteMT4_ = Asia_end_MT4_min;
funPivot( mDay, mMonth ,mYear ,PeriodHour_, hourMT4_, minuteMT4_);
nPivotASIA = nPivot;
nMaxHighA = nMaxHigh;
nMinLowA = nMinLow;
nCloseA = nClose;
//----------------------------------------------
PeriodHour_ = Europe_ïåðèîä_ðàñ÷¸òà_÷àñ;
hourMT4_ = Europe_end_MT4_hour_pivot;
minuteMT4_ = Europe_end_MT4_min;
funPivot(mDay, mMonth,mYear,PeriodHour_, hourMT4_, minuteMT4_);
nPivotEurope = nPivot;
nMaxHighE = nMaxHigh;
nMinLowE = nMinLow;
nCloseE = nClose;
//----------------------------------------------
PeriodHour_ = USA_ïåðèîä_ðàñ÷¸òà_÷àñ;
hourMT4_ = USA_end_MT4_hour_pivot;
minuteMT4_ = USA_end_MT4_min;
funPivot(mDay, mMonth,mYear,PeriodHour_, hourMT4_, minuteMT4_);
nPivotUSA = nPivot;
nMaxHighU = nMaxHigh;
nMinLowU = nMinLow;
nCloseU = nClose;
//----------------------------------------------
string DC_ASIA = StringConcatenate(mYearMonthDay , " " , Asia_end_MT4_hour, ":00");
string DC_EUROPE = StringConcatenate(mYearMonthDay , " " , Europe_end_MT4_hour_session, ":00");
string DC_USA = StringConcatenate(mYearMonthDay , " " , USA_end_MT4_hour_session, ":00");
int pPivotBARA = iBarShift (NULL,0,StrToTime (DC_ASIA));
int pPivotBARE = iBarShift (NULL,0,StrToTime (DC_EUROPE));
int pPivotBARU = iBarShift (NULL,0,StrToTime (DC_USA));
int j;
if ( nPivotASIA !=0 )
{
for (j =0 ; j < pPivotBARA; j++)
PBuffer[j] = nPivotASIA ;
}
if ( nPivotEurope !=0)
{
for (j = 0 ; j < pPivotBARE; j++)
PBuffer[j] = nPivotEurope ;
}
if (nPivotUSA !=0 )
{
for (j = 0 ; j < pPivotBARU; j++)
PBuffer[j] = nPivotUSA ;
}
}
if (TEXT_Visible == true )
{
string sPivotASIA = StringConcatenate("PivotAsia =",DoubleToStr(nPivotASIA ,Digits)," High="+DoubleToStr(nMaxHighA,Digits)," Low=",DoubleToStr(nMinLowA,Digits)," Close=",DoubleToStr(nCloseA,Digits)) ;
string sPivotEUROPE = StringConcatenate("PivotEurope=" ,DoubleToStr(nPivotEurope,Digits)," High="+DoubleToStr(nMaxHighE,Digits)," Low=",DoubleToStr(nMinLowE,Digits)," Close=",DoubleToStr(nCloseE,Digits)) ;
string sPivotUSA = StringConcatenate("PivotUSA =" ,DoubleToStr(nPivotUSA ,Digits)," High="+DoubleToStr(nMaxHighU,Digits)," Low=",DoubleToStr(nMinLowU,Digits)," Close="+DoubleToStr(nCloseU,Digits)) ;
ObjectSetText(ss1, sPivotASIA , 8, "Tahoma", TextColor);
ObjectSetText(ss2, sPivotEUROPE , 8, "Tahoma", TextColor);
ObjectSetText(ss3, sPivotUSA , 8, "Tahoma", TextColor);
ObjectSetText(ss4, "Download from www.usd.ucoz.ru", 8, "Tahoma", White);
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments