Author: Yuriy Tokman (YTG)
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 bar
0 Views
0 Downloads
0 Favorites
Pivot_BOX
//+------------------------------------------------------------------+
//|                                                    Pivot_BOX.mq4 |
//|                                               Yuriy Tokman (YTG) |
//|                                               http://ytg.com.ua/ |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link      "http://ytg.com.ua/"
#property version   "1.00"
#property description "yuriytokman@gmail.com"
#property description " "
#property description "http://ytg.com.ua/"
#property strict

#property indicator_chart_window

input color colir_LUP = clrLime;
input color colir_LDN = clrRed;
input color colir_LCE = clrBlack;
input color colir_BUP = clrKhaki;
input color colir_BDN = clrPink;
input bool PriceClose = false;

string tx = "ytg_";
double H2,H4,H5,L2,L4,L5,close;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   GetDellName ();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  { 
//----
   int limit;
   int counted_bars=IndicatorCounted();   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
   {
    double high = iHigh(Symbol(),1440,i+1);
    double low = iLow(Symbol(),1440,i+1);
    close = iClose(Symbol(),1440,i+1);
    datetime t_1 = iTime(Symbol(),1440,i);
    datetime t_2 = t_1+1440*60-360;        
    string txt = tx + TimeToStr(t_1,TIME_DATE);
        
    H2= close + (high-low)*1.1 /6;
    H4= close + (high-low)*1.1 /2;
    if(low==0)continue;
    H5 = (high/low)*close;

    L2= close - (high-low)*1.1 /6;
    L4= close - (high-low)*1.1 /2;
    L5 = close - (H5 - close);
    
    TrendLineGraff(txt+" close",t_1,close,t_2,close,colir_LCE,2);
    
    TrendLineGraff(txt+" H2",t_1,H2,t_2,H2,colir_LUP,0);
    TrendLineGraff(txt+" H4",t_1,H4,t_2,H4,colir_LUP,0);    
    TrendLineGraff(txt+" H5",t_1,H5,t_2,H5,colir_LUP,0);
    
    TrendLineGraff(txt+" L2",t_1,L2,t_2,L2,colir_LDN,0);
    TrendLineGraff(txt+" L4",t_1,L4,t_2,L4,colir_LDN,0);    
    TrendLineGraff(txt+" L5",t_1,L5,t_2,L5,colir_LDN,0);
    
    GetRECTANGLE(txt+" TB",t_1,H2,t_2,H5,colir_BUP);
    GetRECTANGLE(txt+" TS",t_1,L2,t_2,L5,colir_BDN);
    
    if(PriceClose)RICE_ARROW(txt+"C1",t_2,close,colir_LCE,1);                                                
   }
   
   
       
//----
   return(0);
  }
//+----
 void TrendLineGraff(string labebe,datetime time1,double price1,datetime time2,double price2,color c,int s)
  {
   if (ObjectFind(labebe)!=-1) ObjectDelete(labebe);
   ObjectCreate(labebe, OBJ_TREND, 0,time1,price1,time2,price2);
   ObjectSet(labebe, OBJPROP_COLOR,c);
   ObjectSet(labebe, OBJPROP_STYLE,s);
   ObjectSet(labebe, OBJPROP_RAY,0);
   ObjectSet(labebe, OBJPROP_BACK, true);
  }
//+----
 void GetDellName (string name_n = "ytg_")
  {
   string vName;
   for(int i=ObjectsTotal()-1; i>=0;i--)
    {
     vName = ObjectName(i);
     if (StringFind(vName,name_n) !=-1) ObjectDelete(vName);
    }  
  }
//----
 void GetRECTANGLE(string name,datetime t_1,double p_1,datetime t_2, double p_2,color c)
  {
   if (ObjectFind(name)==-1) 
   ObjectCreate(name,OBJ_RECTANGLE,0,t_1,p_1,t_2,p_2);
   ObjectSet(name,OBJPROP_STYLE,0);
   ObjectSet(name,OBJPROP_COLOR,c);
   ObjectSet(name,OBJPROP_BACK,true);
  }
//+----
 void RICE_ARROW(string label,datetime time1,double price1,color colir,int WIDTH )
  {
   if (ObjectFind(label)!=-1) ObjectDelete(label);
   ObjectCreate(label,OBJ_ARROW, 0,time1,price1);
   ObjectSet(label,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
   ObjectSet(label, OBJPROP_COLOR, colir);
   ObjectSet(label, OBJPROP_WIDTH,WIDTH);
   ObjectSet(label, OBJPROP_BACK, false);
  }

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