All right there you go:
//±-----------------------------------------------------------------+
//| PP_Gica.mq4 |
//| Copyright © 2011, MetaQuotes Software Corp. |
//| MetaTrader 5 Trading Platform / MetaQuotes Software Corp. |
//±-----------------------------------------------------------------+
#property copyright “Copyright © 2011, MetaQuotes Software Corp.”
#property link “http://www.metaquotes.net”
extern int period = 1;
extern bool Daily = true;
extern bool Weekly = false;
extern bool Monthly = false;
extern bool Hourly = false;
extern color clr_Pivot = Black;
extern color clr_R = SteelBlue;
extern color clr_S = Red;
extern color clr_M = Orange;
#property indicator_chart_window
//±-----------------------------------------------------------------+
//| Custom indicator initialization function |
//±-----------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//±-----------------------------------------------------------------+
//| Custom indicator deinitialization function |
//±-----------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll (0,OBJ_HLINE);
return(0);
}
//±-----------------------------------------------------------------+
//| Custom indicator iteration function |
//±-----------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//Base pivot parameters for daily
int normalizer = 5;
/*
double high;
double low;
double close;
*/
//Pivot point parameter data
double d_h = iHigh (Symbol (),PERIOD_D1,period);
double d_l = iLow (Symbol (),PERIOD_D1,period);
double d_c = iClose(Symbol (),PERIOD_D1,period);
double w_h = iHigh (Symbol (),PERIOD_W1,period);
double w_l = iLow (Symbol (),PERIOD_W1,period);
double w_c = iClose(Symbol (),PERIOD_W1,period);
double m_h = iHigh (Symbol (),PERIOD_MN1,period);
double m_l = iLow (Symbol (),PERIOD_MN1,period);
double m_c = iClose(Symbol (),PERIOD_MN1,period);
double h_h = iHigh (Symbol (),PERIOD_H1,period);
double h_l = iLow (Symbol (),PERIOD_H1,period);
double h_c = iClose(Symbol (),PERIOD_H1,period);
if (Daily == true)
{
double pivot = NormalizeDouble((d_h + d_l + d_c)/3,normalizer);
double r1 = NormalizeDouble((2pivot)- d_l,normalizer);
double r2 = NormalizeDouble(pivot + (d_h - d_l),normalizer);
double r3 = NormalizeDouble (d_h + 2(pivot - d_l),normalizer);
double s1 = NormalizeDouble((2pivot)- d_h,normalizer);
double s2 = NormalizeDouble(pivot - (d_h - d_l),normalizer);
double s3 = NormalizeDouble (d_l - 2(d_h - pivot),normalizer);
double m5 = NormalizeDouble (r1 + (r2 - r1)/2,normalizer);
double m4 = NormalizeDouble (pivot + (r1 - pivot)/2,normalizer);
double m3 = NormalizeDouble (s1 + (pivot - s1)/2,normalizer);
double m2 = NormalizeDouble (s2 + (s1-s2)/2,normalizer);
ObjectCreate (“d_pivot”,OBJ_HLINE, 0,0,pivot);
ObjectSet (“d_pivot”, OBJPROP_COLOR,clr_Pivot);
ObjectSet (“d_pivot”, OBJPROP_WIDTH,2);
ObjectCreate (“d_r1”,OBJ_HLINE, 0,0,r1);
ObjectSet (“d_r1”, OBJPROP_COLOR,clr_R);
ObjectCreate (“d_r2”,OBJ_HLINE, 0,0,r2);
ObjectSet (“d_r2”, OBJPROP_COLOR,clr_R);
ObjectCreate (“d_r3”,OBJ_HLINE, 0,0,r3);
ObjectSet (“d_r3”, OBJPROP_COLOR,clr_R);
ObjectCreate (“d_s1”,OBJ_HLINE, 0,0,s1);
ObjectSet (“d_s1”, OBJPROP_COLOR,clr_S);
ObjectCreate (“d_s2”,OBJ_HLINE, 0,0,s2);
ObjectSet (“d_s2”, OBJPROP_COLOR,clr_S);
ObjectCreate (“d_s3”,OBJ_HLINE, 0,0,s3);
ObjectSet (“d_s3”, OBJPROP_COLOR,clr_S);
ObjectCreate (“d_m2”,OBJ_HLINE, 0,0,m2);
ObjectSet (“d_m2”, OBJPROP_COLOR,clr_M);
ObjectCreate (“d_m3”,OBJ_HLINE, 0,0,m3);
ObjectSet (“d_m3”, OBJPROP_COLOR,clr_M);
ObjectCreate (“d_m4”,OBJ_HLINE, 0,0,m4);
ObjectSet (“d_m4”, OBJPROP_COLOR,clr_M);
ObjectCreate (“d_m5”,OBJ_HLINE, 0,0,m5);
ObjectSet (“d_m5”, OBJPROP_COLOR,clr_M);
}
if (Weekly == true)
{
double w_pivot = NormalizeDouble((w_h + w_l + w_c)/3,normalizer);
double w_r1 = NormalizeDouble((2w_pivot)- w_l,normalizer);
double w_r2 = NormalizeDouble(w_pivot + (w_h - w_l),normalizer);
double w_r3 = NormalizeDouble (w_h + 2(w_pivot - w_l),normalizer);
double w_s1 = NormalizeDouble((2w_pivot)- w_h,normalizer);
double w_s2 = NormalizeDouble(w_pivot - (w_h - w_l),normalizer);
double w_s3 = NormalizeDouble (w_l - 2(w_h - w_pivot),normalizer);
double w_m5 = NormalizeDouble (w_r1 + (w_r2 - w_r1)/2,normalizer);
double w_m4 = NormalizeDouble (w_pivot + (w_r1 - w_pivot)/2,normalizer);
double w_m3 = NormalizeDouble (w_s1 + (w_pivot - w_s1)/2,normalizer);
double w_m2 = NormalizeDouble (w_s2 + (w_s1-w_s2)/2,normalizer);
ObjectCreate (“w_pivot”,OBJ_HLINE, 0,0,w_pivot);
ObjectSet (“w_pivot”, OBJPROP_COLOR,clr_Pivot);
ObjectSet (“w_pivot”, OBJPROP_WIDTH,2);
ObjectCreate (“w_r1”,OBJ_HLINE, 0,0,w_r1);
ObjectSet (“w_r1”, OBJPROP_COLOR,clr_R);
ObjectCreate (“w_r2”,OBJ_HLINE, 0,0,w_r2);
ObjectSet (“w_r2”, OBJPROP_COLOR,clr_R);
ObjectCreate (“w_r3”,OBJ_HLINE, 0,0,w_r3);
ObjectSet (“w_r3”, OBJPROP_COLOR,clr_R);
ObjectCreate (“w_s1”,OBJ_HLINE, 0,0,w_s1);
ObjectSet (“w_s1”, OBJPROP_COLOR,clr_S);
ObjectCreate (“w_s2”,OBJ_HLINE, 0,0,w_s2);
ObjectSet (“w_s2”, OBJPROP_COLOR,clr_S);
ObjectCreate (“w_s3”,OBJ_HLINE, 0,0,w_s3);
ObjectSet (“w_s3”, OBJPROP_COLOR,clr_S);
ObjectCreate (“w_m2”,OBJ_HLINE, 0,0,w_m2);
ObjectSet (“w_m2”, OBJPROP_COLOR,clr_M);
ObjectCreate (“w_m3”,OBJ_HLINE, 0,0,w_m3);
ObjectSet (“w_m3”, OBJPROP_COLOR,clr_M);
ObjectCreate (“w_m4”,OBJ_HLINE, 0,0,w_m4);
ObjectSet (“w_m4”, OBJPROP_COLOR,clr_M);
ObjectCreate (“w_m5”,OBJ_HLINE, 0,0,w_m5);
ObjectSet (“w_m5”, OBJPROP_COLOR,clr_M);
}
if (Monthly == true)
{
double m_pivot = NormalizeDouble((m_h + m_l + m_c)/3,normalizer);
double m_r1 = NormalizeDouble((2m_pivot)- m_l,normalizer);
double m_r2 = NormalizeDouble(m_pivot + (m_h - m_l),normalizer);
double m_r3 = NormalizeDouble (m_h + 2(m_pivot - m_l),normalizer);
double m_s1 = NormalizeDouble((2m_pivot)- m_h,normalizer);
double m_s2 = NormalizeDouble(m_pivot - (m_h - m_l),normalizer);
double m_s3 = NormalizeDouble (m_l - 2(m_h - m_pivot),normalizer);
double m_m5 = NormalizeDouble (m_r1 + (m_r2 - m_r1)/2,normalizer);
double m_m4 = NormalizeDouble (m_pivot + (m_r1 - m_pivot)/2,normalizer);
double m_m3 = NormalizeDouble (m_s1 + (m_pivot - m_s1)/2,normalizer);
double m_m2 = NormalizeDouble (m_s2 + (m_s1-m_s2)/2,normalizer);
ObjectCreate (“m_pivot”,OBJ_HLINE, 0,0,m_pivot);
ObjectSet (“m_pivot”, OBJPROP_COLOR,clr_Pivot);
ObjectSet (“m_pivot”, OBJPROP_WIDTH,2);
ObjectCreate (“m_r1”,OBJ_HLINE, 0,0,m_r1);
ObjectSet (“m_r1”, OBJPROP_COLOR,clr_R);
ObjectCreate (“m_r2”,OBJ_HLINE, 0,0,m_r2);
ObjectSet (“m_r2”, OBJPROP_COLOR,clr_R);
ObjectCreate (“m_r3”,OBJ_HLINE, 0,0,m_r3);
ObjectSet (“m_r3”, OBJPROP_COLOR,clr_R);
ObjectCreate (“m_s1”,OBJ_HLINE, 0,0,m_s1);
ObjectSet (“m_s1”, OBJPROP_COLOR,clr_S);
ObjectCreate (“m_s2”,OBJ_HLINE, 0,0,m_s2);
ObjectSet (“m_s2”, OBJPROP_COLOR,clr_S);
ObjectCreate (“m_s3”,OBJ_HLINE, 0,0,m_s3);
ObjectSet (“m_s3”, OBJPROP_COLOR,clr_S);
ObjectCreate (“m_m2”,OBJ_HLINE, 0,0,m_m2);
ObjectSet (“m_m2”, OBJPROP_COLOR,clr_M);
ObjectCreate (“m_m3”,OBJ_HLINE, 0,0,m_m3);
ObjectSet (“m_m3”, OBJPROP_COLOR,clr_M);
ObjectCreate (“m_m4”,OBJ_HLINE, 0,0,m_m4);
ObjectSet (“m_m4”, OBJPROP_COLOR,clr_M);
ObjectCreate (“m_m5”,OBJ_HLINE, 0,0,m_m5);
ObjectSet (“m_m5”, OBJPROP_COLOR,clr_M);
}
if (Hourly == true)
{
double h_pivot = NormalizeDouble((h_h + h_l + h_c)/3,normalizer);
double h_r1 = NormalizeDouble((2h_pivot)- h_l,normalizer);
double h_r2 = NormalizeDouble(h_pivot + (h_h - h_l),normalizer);
double h_r3 = NormalizeDouble (h_h + 2(h_pivot - h_l),normalizer);
double h_s1 = NormalizeDouble((2h_pivot)- h_h,normalizer);
double h_s2 = NormalizeDouble(h_pivot - (h_h - h_l),normalizer);
double h_s3 = NormalizeDouble (h_l - 2(h_h - h_pivot),normalizer);
double h_m5 = NormalizeDouble (h_r1 + (h_r2 - h_r1)/2,normalizer);
double h_m4 = NormalizeDouble (h_pivot + (h_r1 - h_pivot)/2,normalizer);
double h_m3 = NormalizeDouble (h_s1 + (h_pivot - h_s1)/2,normalizer);
double h_m2 = NormalizeDouble (h_s2 + (h_s1-h_s2)/2,normalizer);
ObjectCreate (“h_pivot”,OBJ_HLINE, 0,0,h_pivot);
ObjectSet (“h_pivot”, OBJPROP_COLOR,clr_Pivot);
ObjectSet (“h_pivot”, OBJPROP_WIDTH,2);
ObjectCreate (“h_r1”,OBJ_HLINE, 0,0,h_r1);
ObjectSet (“h_r1”, OBJPROP_COLOR,clr_R);
ObjectCreate (“h_r2”,OBJ_HLINE, 0,0,h_r2);
ObjectSet (“h_r2”, OBJPROP_COLOR,clr_R);
ObjectCreate (“h_r3”,OBJ_HLINE, 0,0,h_r3);
ObjectSet (“h_r3”, OBJPROP_COLOR,clr_R);
ObjectCreate (“h_s1”,OBJ_HLINE, 0,0,h_s1);
ObjectSet (“h_s1”, OBJPROP_COLOR,clr_S);
ObjectCreate (“h_s2”,OBJ_HLINE, 0,0,h_s2);
ObjectSet (“h_s2”, OBJPROP_COLOR,clr_S);
ObjectCreate (“h_s3”,OBJ_HLINE, 0,0,h_s3);
ObjectSet (“h_s3”, OBJPROP_COLOR,clr_S);
ObjectCreate (“h_m2”,OBJ_HLINE, 0,0,h_m2);
ObjectSet (“h_m2”, OBJPROP_COLOR,clr_M);
ObjectCreate (“h_m3”,OBJ_HLINE, 0,0,h_m3);
ObjectSet (“h_m3”, OBJPROP_COLOR,clr_M);
ObjectCreate (“h_m4”,OBJ_HLINE, 0,0,h_m4);
ObjectSet (“h_m4”, OBJPROP_COLOR,clr_M);
ObjectCreate (“h_m5”,OBJ_HLINE, 0,0,h_m5);
ObjectSet (“h_m5”, OBJPROP_COLOR,clr_M);
}
//Difference from open to pivot
/*
double m_range = MathAbs(m_pivot - m_o)*10000;
Comment ("T/P: " + m_range);
*/
return(0);
}
//±-----------------------------------------------------------------+
There you go:
double h_h = iHigh (Symbol (),PERIOD_H1,period);
double h_l = iLow (Symbol (),PERIOD_H1,period);
double h_c = iClose(Symbol (),PERIOD_H1,period);
At this point, you just change PERIOD_H1 to PERIOD_H4 >> save and compile and it’s all done.
I’m uploading the indicator itself just in case you might wanna use it. Just a note though, I haven’t used it for a while, I’m not sure if it perfectly bug free for I’m not much of a programmer.
Pivot Point Gica.zip (12.4 KB)
Good luck.