0
Views
0
Downloads
0
Favorites
Pivots GMTShift
//+------------------------------------------------------------------+
//| Pivot GMTShift.mq4 |
//| Based on AllPivots code by IgorAD - adapted & Modified by cja |
//+------------------------------------------------------------------+
#property copyright "Adapted by cja - 2010"
#property link "Forex-TSD.com"
#property indicator_chart_window
extern int GMTHours = 0;
extern int GMTMinutes = 0;
extern bool Show_Pivots = true;
extern bool Show_M_Levels = true;
extern string dot_types = "3=arrow / 4=shortline / 6=price";
extern int DOT_Type = 6;
extern int Shift_PriceLabels = 5;
extern color Central_PIVOT = Lime;
extern int PIVOT_Size = 1;
extern color R1_R2_R3 = DodgerBlue;
extern color S1_S2_S3 = Red;
extern int S_R_Levels_Size = 1;
extern color M0_M1_M2 = FireBrick;
extern color M3_M4_M5 = RoyalBlue;
extern int MLevelS_Size = 1;
extern bool ShowPivotLables = true;
extern int Shift_TextLabels = 8;
extern int AdjustText_UP_DN = 3;
extern bool Show_StartTime = true;
extern color StartTime_color = Red;
extern int Line_Style = 4;
extern bool Show_LowerTimeLabel = false;
double day_high;
double day_low;
double yesterday_open;
double today_open;
double cur_day;
double prev_day;
double yesterday_high=0;
double yesterday_low=0;
double yesterday_close=0;
datetime time1;
datetime time2;
double open,close,high,low;
double P,R1,R2,R3,S1,S2,S3,M0,M1,M2,M3,M4,M5;
double H1,H2,H3,H4,L1,L2,L3,L4,Range;
int shift, num;
void ObjDel()
{
for (;num<=0;num++)
{
ObjectDelete("PP["+num+"]");
ObjectDelete("R1["+num+"]");
ObjectDelete("R2["+num+"]");
ObjectDelete("R3["+num+"]");
ObjectDelete("S1["+num+"]");
ObjectDelete("S2["+num+"]");
ObjectDelete("S3["+num+"]");
ObjectDelete("M0["+num+"]");
ObjectDelete("M1["+num+"]");
ObjectDelete("M2["+num+"]");
ObjectDelete("M3["+num+"]");
ObjectDelete("M4["+num+"]");
ObjectDelete("M5["+num+"]");
}
day_high=0;
day_low=0;
yesterday_open=0;
today_open=0;
cur_day=0;
prev_day=0;
int cnt=99999;
while (cnt!= 0)
{
if (TimeDayOfWeek(Time[cnt]) == 0)
{
cur_day = prev_day;
}
else
{
cur_day = TimeDay(Time[cnt]-(GMTHours*3600+GMTMinutes*60));
}
if (prev_day != cur_day)
{
yesterday_close = Close[cnt+1];
today_open = Open[cnt];
yesterday_high = day_high;
yesterday_low = day_low;
day_high = High[cnt];
day_low = Low[cnt];
prev_day = cur_day;
}
if (High[cnt]>day_high)
{
day_high = High[cnt];
}
if (Low[cnt]<day_low)
{
day_low = Low[cnt];
}
cnt--;
}
}
void PlotLine(string name,double value,double line_color,double style)
{
ObjectCreate(name,OBJ_ARROW,0,customTime(-Shift_PriceLabels),value,customTime(-Shift_PriceLabels),value);
ObjectSet(name, OBJPROP_ARROWCODE,DOT_Type);
ObjectSet(name, OBJPROP_WIDTH, S_R_Levels_Size);
ObjectSet(name, OBJPROP_STYLE, style);
ObjectSet(name, OBJPROP_COLOR, line_color);
}
void PlotLinemm(string namemm,double value,double line_color,double style)
{
ObjectCreate(namemm,OBJ_ARROW,0,customTime(-Shift_PriceLabels),value,customTime(-Shift_PriceLabels),value);
ObjectSet(namemm, OBJPROP_ARROWCODE,DOT_Type);
ObjectSet(namemm, OBJPROP_WIDTH, MLevelS_Size);
ObjectSet(namemm, OBJPROP_STYLE, style);
ObjectSet(namemm, OBJPROP_COLOR, line_color);
}
void PlotLinep(string namep,double value,double line_color,double style)
{
ObjectCreate(namep,OBJ_ARROW,0,customTime(-Shift_PriceLabels),value,customTime(-Shift_PriceLabels),value);
ObjectSet(namep, OBJPROP_ARROWCODE,DOT_Type);
ObjectSet(namep, OBJPROP_WIDTH, PIVOT_Size);
ObjectSet(namep, OBJPROP_STYLE, style);
ObjectSet(namep, OBJPROP_COLOR, line_color);
}
void StartGMT(string tl, int Window,double w, double s,color clr, datetime Time1, bool delete)
{
if (delete) ObjectDelete(tl);
if(ObjectFind(tl)!=0)
{if(Show_LowerTimeLabel){
ObjectCreate(tl, OBJ_VLINE, 0, iTime(NULL,1440,0)+GMTHours*3600+GMTMinutes*60,0, iTime(NULL,1440,0)+GMTHours*3600+GMTMinutes*60,100);
}else{
ObjectCreate(tl, OBJ_TREND, 0, iTime(NULL,1440,0)+GMTHours*3600+GMTMinutes*60,0, iTime(NULL,1440,0)+GMTHours*3600+GMTMinutes*60,100);
}
ObjectSet(tl, OBJPROP_COLOR, clr);
ObjectSet(tl,OBJPROP_BACK,false);
ObjectSet(tl,OBJPROP_WIDTH,w);
ObjectSet(tl,OBJPROP_STYLE,Line_Style);
}
else
ObjectMove(tl, 0,iTime(NULL,1440,0)+GMTHours*3600+GMTMinutes*60,100);
}
int init()
{
return(0);
}
int deinit()
{
ObjectDelete("Pivot");
ObjectDelete("R1"); ObjectDelete("R2");ObjectDelete("R3");
ObjectDelete("S1");ObjectDelete("S2"); ObjectDelete("S3");
ObjectDelete("M0");ObjectDelete("M1");
ObjectDelete("M2");ObjectDelete("M3");
ObjectDelete("M4");ObjectDelete("M5");
ObjectsDeleteAll(0,OBJ_ARROW);
ObjectDelete("Time");
ObjDel();
Comment("");
return(0);
}
int start()
{
if (Show_StartTime==true)
{
StartGMT("Time",0,0,0,StartTime_color,0,true);
}
int i;
ObjDel();
num=0;
{
time1=iTime(NULL,PERIOD_D1,shift);
i=shift-1;
if (i<0)
time2=Time[0];
else
time2=iTime(NULL,PERIOD_D1,i)-Period()*60;
double P = (yesterday_high + yesterday_low + yesterday_close)/3;//Pivot
//Pivots & M Pivots
double R3 = ( 2 * P ) + ( yesterday_high - ( 2 * yesterday_low ));
double R2 = P + ( yesterday_high - yesterday_low );
double R1 = ( 2 * P ) - yesterday_low;
double S1 = ( 2 * P ) - yesterday_high;
double S2 = P - ( yesterday_high- yesterday_low);
double S3 = ( 2 * P ) - ( ( 2 * yesterday_high ) - yesterday_low );
double M0 = (S2 + S3)/2;
double M1 = (S1 + S2)/2;
double M2 = (P + S1)/2;
double M3 = (P + R1)/2;
double M4 = (R1 + R2)/2;
double M5 = (R2 + R3)/2;
time2=time1+PERIOD_D1*8;
num=shift;
PlotLinep("PP["+num+"]",P,Central_PIVOT,0);
if(Show_Pivots)
{
PlotLine("R1["+num+"]",R1,R1_R2_R3,0);
PlotLine("R2["+num+"]",R2,R1_R2_R3,0);
PlotLine("R3["+num+"]",R3,R1_R2_R3,0);
PlotLine("S1["+num+"]",S1,S1_S2_S3,0);
PlotLine("S2["+num+"]",S2,S1_S2_S3,0);
PlotLine("S3["+num+"]",S3,S1_S2_S3,0);
}
if(Show_M_Levels)
{
PlotLinemm("M0["+num+"]",M0,M0_M1_M2,0);
PlotLinemm("M1["+num+"]",M1,M0_M1_M2,0);
PlotLinemm("M2["+num+"]",M2,M0_M1_M2,0);
PlotLinemm("M3["+num+"]",M3,M3_M4_M5,0);
PlotLinemm("M4["+num+"]",M4,M3_M4_M5,0);
PlotLinemm("M5["+num+"]",M5,M3_M4_M5,0);
}
if(ShowPivotLables){
ObjectCreate("Pivot", OBJ_TEXT, 0, 0,0);
ObjectSetText("Pivot", " Pivot",10,"Arial Bold",Central_PIVOT);
ObjectMove("Pivot", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),P+AdjustText_UP_DN *Point);
if(Show_Pivots){
ObjectCreate("R1", OBJ_TEXT, 0, 0,0);
ObjectSetText("R1", " R1",10,"Arial Bold",R1_R2_R3);
ObjectMove("R1", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),R1+AdjustText_UP_DN*Point);
ObjectCreate("R2", OBJ_TEXT, 0, 0,0);
ObjectSetText("R2", " R2",10,"Arial Bold",R1_R2_R3);
ObjectMove("R2", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),R2+AdjustText_UP_DN*Point);
ObjectCreate("R3", OBJ_TEXT, 0, 0,0);
ObjectSetText("R3", " R3",10,"Arial Bold",R1_R2_R3);
ObjectMove("R3", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),R3+AdjustText_UP_DN*Point);
ObjectCreate("S1", OBJ_TEXT, 0, 0,0);
ObjectSetText("S1", " S1",10,"Arial Bold",S1_S2_S3);
ObjectMove("S1", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),S1+AdjustText_UP_DN*Point);
ObjectCreate("S2", OBJ_TEXT, 0, 0,0);
ObjectSetText("S2", " S2",10,"Arial Bold",S1_S2_S3);
ObjectMove("S2", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),S2+AdjustText_UP_DN*Point);
ObjectCreate("S3", OBJ_TEXT, 0, 0,0);
ObjectSetText("S3", " S3",10,"Arial Bold",S1_S2_S3);
ObjectMove("S3", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),S3+AdjustText_UP_DN*Point);
}if(Show_M_Levels){
ObjectCreate("M0", OBJ_TEXT, 0, 0,0);
ObjectSetText("M0", " M0",10,"Arial Bold",M0_M1_M2);
ObjectMove("M0", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),M0+AdjustText_UP_DN*Point);
ObjectCreate("M1", OBJ_TEXT, 0, 0,0);
ObjectSetText("M1", " M1",10,"Arial Bold",M0_M1_M2);
ObjectMove("M1", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),M1+AdjustText_UP_DN*Point);
ObjectCreate("M2", OBJ_TEXT, 0, 0,0);
ObjectSetText("M2", " M2",10,"Arial Bold",M0_M1_M2);
ObjectMove("M2", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),M2+AdjustText_UP_DN*Point);
ObjectCreate("M3", OBJ_TEXT, 0, 0,0);
ObjectSetText("M3", " M3",10,"Arial Bold",M3_M4_M5);
ObjectMove("M3", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),M3+AdjustText_UP_DN*Point);
ObjectCreate("M4", OBJ_TEXT, 0, 0,0);
ObjectSetText("M4", " M4",10,"Arial Bold",M3_M4_M5);
ObjectMove("M4", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),M4+AdjustText_UP_DN*Point);
ObjectCreate("M5", OBJ_TEXT, 0, 0,0);
ObjectSetText("M5", " M5",10,"Arial Bold",M3_M4_M5);
ObjectMove("M5", 0, customTime(-Shift_PriceLabels-Shift_TextLabels),M5+AdjustText_UP_DN*Point);
}}
}
return(0);
}
int customTime(int a)
{
if(a<0)
return(Time[0]+Period()*60*MathAbs(a));
else return(Time[a]);
}
//+------------------------------------------------------------------+
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
---