JPivot Points





//+------------------------------------------------------------------+
//|                                                JPivot Points.mq4 |
//|                                      Copyright © 2006, juanchoc. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, juanchoc."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 9
#property indicator_color1 White
#property indicator_color2 Lime
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Blue
#property indicator_color7 Blue
#property indicator_color8 Blue
#property indicator_color9 Blue

//---- buffers
double P[];
double R1[];
double R2[];
double S1[];
double S2[];
double MR1R2[];
double MR1P[];
double MPS1[];
double MS1S2[];

extern int Loopback = 1;
extern int Timeframe = 7; // 1= 1m, 2= 5m, 3= 15m, 4= 30m, 5= 1h, 6= 4h, 7= 1d, 8= 1w, 9= 1mn, 10= current

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,P);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,R1);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,R2);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,S1);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,S2);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,MR1R2);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,MR1P);
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,MPS1);
   SetIndexStyle(8,DRAW_LINE);
   SetIndexBuffer(8,MS1S2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
   //---- check for possible errors

   if (counted_bars<0) return(-1);

   //---- last counted bar will be recounted

   if (counted_bars>0) counted_bars--;

   int pos=Bars-counted_bars;
   //----
   
      double C;
      double H;
      double L;
      int tf;
      
      switch(Timeframe){
         case 1:
            tf = PERIOD_M1;
            break;
         case 2:
            tf = PERIOD_M5;
            break;
         case 3:
            tf = PERIOD_M15;
            break;
         case 4:
            tf = PERIOD_M30;
            break;
         case 5:
            tf = PERIOD_H1;
            break;
         case 6:
            tf = PERIOD_H4;
            break;
         case 7:
            tf = PERIOD_D1;
            break;
         case 8:
            tf = PERIOD_W1;
            break;
         case 9:
            tf = PERIOD_MN1;
            break;
         case 10:
            tf = 0;
            break;
      }
      
      while(pos>=0)
      {
         C = iClose(NULL, tf, Loopback);
         H = iHigh(NULL, tf, Loopback);
         L = iLow(NULL, tf, Loopback);
         P[pos] = (H + L + C) / 3;
         R1[pos] = (P[pos] * 2) - L;
         R2[pos] = P[pos] + (H - L);
         S1[pos] = (P[pos] * 2) - H;
         S2[pos] = P[pos] - (H - L);
         MR1R2[pos] = (R2[pos] + R1[pos]) / 2;
         MR1P[pos] = (R1[pos] + P[pos]) / 2;
         MPS1[pos] = (P[pos] + S1[pos]) / 2;
         MS1S2[pos] = (S1[pos] + S2[pos]) / 2;
         
         pos--;
      }
      
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: