Pivot_ESAZ_Day

Author: DimDimych
Pivot_ESAZ_Day
Price Data Components
Series array that contains close prices for each bar
0 Views
0 Downloads
0 Favorites
Pivot_ESAZ_Day
//+------------------------------------------------------------------+
//|                                               Pivot_ESAZ_Day.mq4 |
//|                                                        DimDimych |                                                                  
//|                            http://goodservice.su/forum/25-3550-1 |
//+------------------------------------------------------------------+
#property copyright "DimDimych"
#property link      "http://goodservice.su/forum/25-3550-1"

#property indicator_chart_window
//---- input parameters
extern int   CountDays     =5;
extern int   GMT           =0;
extern color pivot         =Gold;
extern color level_up      =DodgerBlue;
extern color level_dn      =Tomato;
extern color setka         =Lime;
extern color metka         =MidnightBlue;

//---- indicator buffers
double range[];
double ny_close[];
double low[];
double high[];
datetime time1;
datetime time2;
datetime ny_time[];

int shift, num;
int ny_shift[];
datetime prevDay=0;
bool fTime;
// ----
void ObjDel()
{
   if (ObjectsTotal() > 0)
   for (num=0;num<=CountDays;num++)
   {
   ObjectDelete("PP["+num+"]");
   ObjectDelete("R1["+num+"]");
   ObjectDelete("R2["+num+"]");
   ObjectDelete("R3["+num+"]");
   ObjectDelete("R4["+num+"]");
   ObjectDelete("S1["+num+"]");
   ObjectDelete("S2["+num+"]");
   ObjectDelete("S3["+num+"]");
   ObjectDelete("S4["+num+"]");
   
   ObjectDelete("GL1["+num+"]");
   ObjectDelete("GL2["+num+"]");
   ObjectDelete("GL3["+num+"]");
   ObjectDelete("GL4["+num+"]");
   ObjectDelete("GL5["+num+"]");
   ObjectDelete("GL6["+num+"]");
   ObjectDelete("GL7["+num+"]");
   ObjectDelete("GL8["+num+"]");
   ObjectDelete("GL9["+num+"]");
   ObjectDelete("GL10["+num+"]");
   ObjectDelete("GL11["+num+"]");
   ObjectDelete("GL12["+num+"]");
   ObjectDelete("GL13["+num+"]");
   ObjectDelete("GL14["+num+"]");
   ObjectDelete("GL15["+num+"]");
   ObjectDelete("GL16["+num+"]");
              
   }
   ObjectDelete("mP");
   ObjectDelete("mR1");
   ObjectDelete("mR2");
   ObjectDelete("mR3");
   ObjectDelete("mR4");
   ObjectDelete("mS1"); 
   ObjectDelete("mS2");
   ObjectDelete("mS3");
   ObjectDelete("mS4");             
}
// ----
void PlotLine(string name,double value,double value1,double line_color,double style)
{
   double valueN=NormalizeDouble(value,Digits);
   double valueN1=NormalizeDouble(value1,Digits);
   bool res = ObjectCreate(name,OBJ_TREND,0,time1,valueN,time2,valueN1);
   ObjectSet(name, OBJPROP_WIDTH, 1);
   ObjectSet(name, OBJPROP_STYLE, style);
   ObjectSet(name, OBJPROP_RAY, false);
   ObjectSet(name, OBJPROP_BACK, true);
   ObjectSet(name, OBJPROP_COLOR, line_color);
} 
//***********
void PlotPrice(string name, double value, double line_color)
{
    double valueN=NormalizeDouble(value,Digits);
    bool res = ObjectCreate(name, OBJ_ARROW, 0, time2,valueN);
    ObjectSet(name, OBJPROP_COLOR, line_color);
    ObjectSet(name, OBJPROP_WIDTH, 1);
    ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE);
}       
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   fTime = true;
   IndicatorBuffers(2);
   SetIndexBuffer(0,range);
   SetIndexBuffer(1,ny_close);
   return(0);
}

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+   
int deinit()
{
   ObjDel();
   Comment("");
   return(0);
}
//+------------------------------------------------------------------+
//| LNX_Pivots_v3.1                                                    |
//+------------------------------------------------------------------+
int start()
{
   int i;
   double P,R1,R2,R3,R4,S1,S2,S3,S4;
  
   datetime cDay = iTime(NULL,PERIOD_D1,0) + (GMT-Period()/60.0)*3600;
   if (cDay != prevDay || fTime)  
   {
   ObjDel();
   ArrayResize(ny_time,CountDays+1);
   ArrayResize(ny_shift,CountDays+1);
   ArrayResize(high,CountDays+1);
   ArrayResize(low,CountDays+1); 
   ArrayResize(range,CountDays+1);    
      for (shift=0;shift<=CountDays;shift++)
      {
      ny_time[shift]  = iTime(NULL,PERIOD_D1,shift) + (GMT-Period()/60.0)*3600;
      ny_shift[shift] = iBarShift(NULL,0,ny_time[shift]);
      ny_close[shift] = iClose(NULL,0,ny_shift[shift]);        
      }
     
      for (shift=0;shift<=CountDays-1;shift++)
      {
      int length = ny_shift[shift+1]-ny_shift[shift];
   
      high[shift] = High[iHighest(NULL,0,MODE_HIGH,length,ny_shift[shift])];
      low[shift]  = Low[iLowest(NULL,0,MODE_LOW,length,ny_shift[shift])];
      range[shift] = high[shift] - low[shift]; 
      }
  
      for (shift=0;shift<=CountDays-1;shift++)
      {
  
           
      P  = (ny_close[shift]+high[shift]+low[shift])/3;

      time1 = ny_time[shift]+Period()*60;    
         
         if (shift==0) 
         {
         time2 = ny_time[shift] + 24*3600+Period()*60 ;
         PlotPrice("mP",P,metka);
         PlotPrice("mR1",P+range[shift]/2,metka);
         PlotPrice("mR2",P+range[shift],metka);
         PlotPrice("mS1",P-range[shift]/2,metka);
         PlotPrice("mS2",P-range[shift],metka);
         PlotPrice("mR3",P+range[shift]+range[shift]/2,metka);
         PlotPrice("mR4",P+range[shift]*2,metka);
         PlotPrice("mS3",P-range[shift]-range[shift]/2,metka);
         PlotPrice("mS4",P-range[shift]*2,metka);         
         }
         else
         time2 = ny_time[shift-1]+Period()*60;
   
      int pstyle=0;
   PlotLine("PP["+shift+"]",P,P,pivot,pstyle);
   
   PlotLine("R1["+shift+"]",P+range[shift]/2,              P+range[shift]/2,level_up,pstyle);
   PlotLine("R2["+shift+"]",P+range[shift],                P+range[shift],level_up,pstyle);
   PlotLine("R3["+shift+"]",P+range[shift]+range[shift]/2, P+range[shift]+range[shift]/2,level_up,pstyle);
   PlotLine("R4["+shift+"]",P+range[shift]*2,              P+range[shift]*2,level_up,pstyle);
   PlotLine("S1["+shift+"]",P-range[shift]/2,              P-range[shift]/2,level_dn,pstyle);
   PlotLine("S2["+shift+"]",P-range[shift],                P-range[shift],level_dn,pstyle);
   PlotLine("S3["+shift+"]",P-range[shift]-range[shift]/2, P-range[shift]-range[shift]/2,level_dn,pstyle);
   PlotLine("S4["+shift+"]",P-range[shift]*2,              P-range[shift]*2,level_dn,pstyle);
               
   PlotLine("GL1["+shift+"]",P,                            P+range[shift]/2,setka,pstyle);     
   PlotLine("GL2["+shift+"]",P+range[shift]/2,             P+range[shift],setka,pstyle);   
   PlotLine("GL3["+shift+"]",P+range[shift],               P+range[shift]+range[shift]/2,setka,pstyle);     
   PlotLine("GL4["+shift+"]",P+range[shift]+range[shift]/2,P+range[shift]*2,setka,pstyle);
   
   PlotLine("GL5["+shift+"]",P+range[shift]/2,             P,setka,pstyle);     
   PlotLine("GL6["+shift+"]",P+range[shift],               P+range[shift]/2,setka,pstyle);
   PlotLine("GL7["+shift+"]",P+range[shift]+range[shift]/2,P+range[shift],setka,pstyle);     
   PlotLine("GL8["+shift+"]",P+range[shift]*2,             P+range[shift]+range[shift]/2,setka,pstyle);              

   PlotLine("GL9["+shift+"]",P,                            P-range[shift]/2,setka,pstyle);     
   PlotLine("GL10["+shift+"]",P-range[shift]/2,             P-range[shift],setka,pstyle);   
   PlotLine("GL11["+shift+"]",P-range[shift],               P-range[shift]-range[shift]/2,setka,pstyle);     
   PlotLine("GL12["+shift+"]",P-range[shift]-range[shift]/2,P-range[shift]*2,setka,pstyle);
   
   PlotLine("GL13["+shift+"]",P-range[shift]/2,             P,setka,pstyle);     
   PlotLine("GL14["+shift+"]",P-range[shift],               P-range[shift]/2,setka,pstyle);
   PlotLine("GL15["+shift+"]",P-range[shift]-range[shift]/2,P-range[shift],setka,pstyle);     
   PlotLine("GL16["+shift+"]",P-range[shift]*2,             P-range[shift]-range[shift]/2,setka,pstyle); 
}
   fTime = false;
   prevDay = cDay;
   }      
        
   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 ---