AllPivotPoint

Author: Copyright � 2010, LeMan.
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each barSeries array that contains open prices of each bar
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
AllPivotPoint
//+------------------------------------------------------------------+
//|                                                AllPivotPoint.mq4 |
//|                                         Copyright © 2010, LeMan. |
//|                                                 b-market@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, LeMan."
#property link      "b-market@mail.ru"
//----
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Green
#property indicator_color3 Green
#property indicator_color4 Green
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
//----
extern bool weekend = false;
extern int TypePivot = 0;
extern string tp = "-- Âîçìîæíûå çíà÷åíèÿ TypePivot ---";
extern string tp0 = "-- 0 - Classic ---";
extern string tp1 = "-- 1 - Fibonacci ---";
extern string tp2 = "-- 2 - Camarilla ---";
extern string tp3 = "-- 3 - Woodie ---";
extern string tp4 = "-- 4 - DeMark ---";
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
   IndicatorBuffers(8);
   IndicatorDigits(Digits);
//---- indicators
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexBuffer(7,ExtMapBuffer8);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexStyle(7,DRAW_LINE); 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit() {
//----
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
//----   
   if (Period() > 1439) {
      Alert("ÒÔ äîëæåí áûòü ìåíüøå äíåâíîãî!");
      return(-1);
   }
   if (TypePivot > 4 || TypePivot < 0) {
      Alert("Òèï Pivot " + TypePivot + " íå ñóùåñòâóåò!");
      return(-1);   
   } 
//----
   int i;
   double hhv, llv, cl, p, tr, x, op;
//----   
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars > 0)   counted_bars--;
   int limit = Bars - counted_bars;
   if(counted_bars==0) limit--;
      
//----
  for (i = limit; i >= 0; i--)
    { 
   int PrevDay = iBarShift(Symbol(), PERIOD_D1, Time[i])+1;
      if (!weekend) {
         if (TimeDayOfWeek(Time[i]) == 1) PrevDay = iBarShift(Symbol(), PERIOD_D1, Time[i])+2;
      }
      hhv = iHigh(NULL, PERIOD_D1, PrevDay);
      llv = iLow(NULL, PERIOD_D1, PrevDay);
      cl = iClose(NULL, PERIOD_D1, PrevDay);
      op = iOpen(NULL, PERIOD_D1, PrevDay);
      tr = hhv-llv;
      p = (hhv+llv+cl)/3;
      if (TypePivot == 0) { // Classic
         ExtMapBuffer1[i] = 2*p-llv;
         ExtMapBuffer2[i] = p+hhv-llv;
         ExtMapBuffer3[i] = 2*p+hhv-2*llv;
         ExtMapBuffer4[i] = EMPTY_VALUE;
         ExtMapBuffer5[i] = 2*p-hhv;
         ExtMapBuffer6[i] = p+llv-hhv;
         ExtMapBuffer7[i] = 2*p+llv-2*hhv;
         ExtMapBuffer8[i] = EMPTY_VALUE;
      }
      if (TypePivot == 1) { // Fibo
         ExtMapBuffer1[i] = p+tr*0.382;
         ExtMapBuffer2[i] = p+tr*0.618;
         ExtMapBuffer3[i] = p+tr;
         ExtMapBuffer4[i] = p+tr*1.382;
         ExtMapBuffer5[i] = p-tr*0.382;
         ExtMapBuffer6[i] = p-tr*0.618;
         ExtMapBuffer7[i] = p-tr;
         ExtMapBuffer8[i] = p-tr*1.382;
      }
      if (TypePivot == 2) { // Camarilla
         ExtMapBuffer1[i] = tr*(1.1/6)+cl;
         ExtMapBuffer2[i] = tr*(1.1/4)+cl;
         ExtMapBuffer3[i] = tr*(1.1/2)+cl;
         if (llv > 0.0)
            ExtMapBuffer4[i] = (hhv/llv)*cl;
         ExtMapBuffer5[i] = cl-tr*(1.1/6);
         ExtMapBuffer6[i] = cl-tr*(1.1/4);
         ExtMapBuffer7[i] = cl-tr*(1.1/2);
         if (llv > 0.0)
            ExtMapBuffer8[i] = cl-((hhv/llv)*cl-cl);
      }
      if (TypePivot == 3) { // Woodie
         x = (hhv + llv + 2*cl)/4;
         ExtMapBuffer1[i] = 2*x-llv;
         ExtMapBuffer2[i] = x + hhv - llv;
         ExtMapBuffer3[i] = EMPTY_VALUE;
         ExtMapBuffer4[i] = EMPTY_VALUE;
         ExtMapBuffer5[i] = 2*x-hhv;
         ExtMapBuffer6[i] = x - hhv + llv;
         ExtMapBuffer7[i] = EMPTY_VALUE;
         ExtMapBuffer8[i] = EMPTY_VALUE;
      }      
      if (TypePivot == 4) { // DeMark         
         if (cl < op) {
            x = (hhv + 2*llv + cl)/2;
         }
         if (cl > op) {
            x = (2*hhv + llv + cl)/2;
         }
         if (cl == op) {
            x = (hhv + llv + 2*cl)/2;
         }         
         ExtMapBuffer1[i] = x-llv;
         ExtMapBuffer2[i] = EMPTY_VALUE;
         ExtMapBuffer3[i] = EMPTY_VALUE;
         ExtMapBuffer4[i] = EMPTY_VALUE;
         ExtMapBuffer5[i] = x-hhv;
         ExtMapBuffer6[i] = EMPTY_VALUE;
         ExtMapBuffer7[i] = EMPTY_VALUE;
         ExtMapBuffer8[i] = EMPTY_VALUE;
      }      
    }
//----
   return(0);
}
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---