Hi My Dear Friends,
Refer to my early posts on Pivot indicator setting acquired, so for not respond has acted.
Again, I'm posted the following code taken from the existing MT4 file hope someone who able to help to modify and add in the the followings:
1. LocalTimeZone.
2. Vertical line show on Today, yesterday & Beforeyesterday.
3. Pivot Resistance & Support 1, 2 & 3.
Your kind assistant is appreciated.
//+------------------------------------------------------------------+
//| HiLo2DayBefore.mq4 |
//+------------------------------------------------------------------+
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//YLow, low of yesterday.
//YHigh, high of yesterday.
//B4YLow, low of before yestersay.
//B4YHigh, high of before yesterday.
//PP, pivot point.
ObjectDelete("YLow");
ObjectDelete("B4YLow");
ObjectDelete("YHigh");
ObjectDelete("B4YHigh");
ObjectDelete("PIVOT");
Comment(" ");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
double yesterday_close,yesterday_high,yesterday_low,befor e_yesterday_close,before_yesterday_high,before_yes terday_low;
yesterday_close = iClose(NULL,PERIOD_D1,1);
yesterday_high = iHigh(NULL,PERIOD_D1,1);
yesterday_low = iLow(NULL,PERIOD_D1,1);
before_yesterday_close = iClose(NULL,PERIOD_D1,2);
before_yesterday_high = iHigh(NULL,PERIOD_D1,2);
before_yesterday_low = iLow(NULL,PERIOD_D1,2);
//---- Calculate Pivots
//Comment("\nYesterday quotations :\nH ",yesterday_high,"\nL ",yesterday_low, "\nC ",yesterday_close,"\n\nBefore yesterday quotations :\nH ",before_yesterday_high,"\nL ",before_yesterday_low, "\nC ",before_yesterday_close);
double pivot = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot
drawLine(yesterday_low,"YLow", Plum,0);
drawLabel("Low yesterday",yesterday_low,Plum);
drawLine(before_yesterday_low,"B4YLow", Plum,0);
drawLabel("Low before yesterday",before_yesterday_low,Plum);
drawLine(pivot,"PIVOT",Aqua,1);
drawLabel("Pivot level",pivot,Aqua);
drawLine(yesterday_high,"YHigh",CornflowerBlue,0);
drawLabel("High yesterday",yesterday_high,CornflowerBlue);
drawLine(before_yesterday_high,"B4YHigh",Cornflowe rBlue,0);
drawLabel("High before yesterday",before_yesterday_high,CornflowerBlue);
//----
return(0);
}
//+------------------------------------------------------------------+
void drawLabel(string name,double lvl,color Color)
{
if(ObjectFind(name) != 0)
{
ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);
ObjectSetText(name, name, 8, "Arial", EMPTY);
ObjectSet(name, OBJPROP_COLOR, Color);
}
else
{
ObjectMove(name, 0, Time[10], lvl);
}
}
void drawLine(double lvl,string name, color Col,int type)
{
if(ObjectFind(name) != 0)
{
ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
if(type == 1)
ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
else
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}
else
{
ObjectDelete(name);
ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
if(type == 1)
ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
else
ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
ObjectSet(name, OBJPROP_COLOR, Col);
ObjectSet(name,OBJPROP_WIDTH,1);
}
}