iPip_Tom_DeMark_Pivot

Author: Copyright � 2006, ForexRulez
iPip_Tom_DeMark_Pivot
Price Data Components
Series array that contains open time of each barSeries array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
0 Views
0 Downloads
0 Favorites
iPip_Tom_DeMark_Pivot
//+------------------------------------------------------------------+
//|                                      iPip Tom DeMark's Pivot.mq4 |
//|                                     Copyright © 2006, ForexRulez |
//|                                        http://www.forexrulez.com |
//+------------------------------------------------------------------+

#define VSInfo "vs 1.01"

#property copyright "Copyright © 2006, ForexRulez"
#property link      "http://www.forexrulez.com"

#property indicator_chart_window

extern bool ShowMidPivots = True;
extern color clPivot = Navy;
extern color clHigh = YellowGreen;
extern color clLow = DarkOrange;

datetime LastCalcPivot=0;
int u=0,d=0,s=0,uu=0,dd=0,ss=0;
int init(){

   Comment(VSInfo);
   start();

   return(0);
}

int deinit(){

   ClearGraph();
   Comment("");

   return(0);
}

int start(){
   if (LastCalcPivot != Time[0]){
      CalcPivot();
      LastCalcPivot = Time[0];
   }

   return(0);
}

void CalcPivot(){

   int i = 1;

   while (TimeDayOfWeek(iTime(NULL, PERIOD_D1, i))==0) i++;


   double Pivot = 0;
   if (iClose(NULL, PERIOD_D1, i) < iOpen(NULL, PERIOD_D1, i)) 
   Pivot = (iHigh(NULL, PERIOD_D1, i) 
          + iLow(NULL, PERIOD_D1, i) 
          + iClose(NULL, PERIOD_D1, i) 
          + iLow(NULL, PERIOD_D1, i))
          /4;
   else if (iClose(NULL, PERIOD_D1, i) > iOpen(NULL, PERIOD_D1, i)) 
   Pivot = (iHigh(NULL, PERIOD_D1, i) 
          + iLow(NULL, PERIOD_D1, i) 
          + iClose(NULL, PERIOD_D1, i) 
          + iHigh(NULL, PERIOD_D1, i))
          /4;
   else 
   Pivot = (iHigh(NULL, PERIOD_D1, i) 
          + iLow(NULL, PERIOD_D1, i) 
          + iClose(NULL, PERIOD_D1, i) 
          + iClose(NULL, PERIOD_D1, i))
          /4;

   double NewHigh = 2*Pivot - iLow(NULL, PERIOD_D1, i);
   double NewLow = 2*Pivot - iHigh(NULL, PERIOD_D1, i);
   
   ClearGraph();

   CreateLine(NewHigh+5*Point, "", "HL+5", "H+5", LightGray, STYLE_DOT);
   CreateLine(NewHigh, "High", "HLine", "HText", clHigh, STYLE_SOLID);
   CreateLine(NewHigh-5*Point, "", "HL-5", "H-5", LightGray, STYLE_DOT);
   
   CreateLine(Pivot+5*Point, "", "PL+5", "P+5", LightGray, STYLE_DOT);
   CreateLine(Pivot, "Pivot", "PivotLine", "PivotText", clPivot, STYLE_SOLID);
   CreateLine(Pivot-5*Point, "", "PL-5", "P-5", LightGray, STYLE_DOT);
   
   CreateLine(NewLow+5*Point, "", "LL+5", "L+5", LightGray, STYLE_DOT);
   CreateLine(NewLow, "Low", "LLine", "LText", clLow, STYLE_SOLID);
   CreateLine(NewLow-5*Point, "", "LL-5", "L-5", LightGray, STYLE_DOT);
   

}

void ClearGraph(){
   ObjectDelete("HLine"); ObjectDelete("HText"); 
   ObjectDelete("HL+5");  ObjectDelete("H+5");
   ObjectDelete("HL-5");  ObjectDelete("H-5");
   
   ObjectDelete("PivotLine"); ObjectDelete("PivotText");
   ObjectDelete("PL+5");  ObjectDelete("P+5");
   ObjectDelete("PL-5");  ObjectDelete("P-5");

   ObjectDelete("LLine"); ObjectDelete("LText");
   ObjectDelete("LL+5");  ObjectDelete("L+5");
   ObjectDelete("LL-5");  ObjectDelete("L-5");
}

void CreateLine(double aValue, string aText, string aLineName, string aTextName, color aColor, int aStyle){
   ObjectCreate(aTextName, OBJ_TEXT, 0, Time[0], aValue);
   ObjectSetText(aTextName, aText, 8, "Arial", EMPTY);
      
   ObjectCreate(aLineName, OBJ_HLINE, 0, 0, aValue);
   ObjectSet(aLineName, OBJPROP_STYLE, aStyle);
   ObjectSet(aLineName, OBJPROP_COLOR, aColor);
}

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 ---