HiLo2DayBefore

HiLo2DayBefore
Price Data Components
Series 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
HiLo2DayBefore
//+------------------------------------------------------------------+
//|                                               HiLo2DayBefore.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//YLow, low of yesterday.
//YHigh, high of yesterday.
//B4YLow, low of before yestersay.
//B4YHigh, high of before yesterday.
//PP, pivot point.
   ObjectDelete("YLow");
   ObjectDelete("B4YLow");
   ObjectDelete("YHigh");
   ObjectDelete("B4YHigh");
   ObjectDelete("PIVOT");
   Comment(" ");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
double yesterday_close,yesterday_high,yesterday_low,before_yesterday_close,before_yesterday_high,before_yesterday_low;

    yesterday_close = iClose(NULL,PERIOD_D1,1);
    yesterday_high = iHigh(NULL,PERIOD_D1,1);
    yesterday_low = iLow(NULL,PERIOD_D1,1);
    before_yesterday_close = iClose(NULL,PERIOD_D1,2);
    before_yesterday_high = iHigh(NULL,PERIOD_D1,2);
    before_yesterday_low = iLow(NULL,PERIOD_D1,2);

//---- Calculate Pivots

//Comment("\nYesterday quotations :\nH ",yesterday_high,"\nL ",yesterday_low, "\nC ",yesterday_close,"\n\nBefore yesterday quotations :\nH ",before_yesterday_high,"\nL ",before_yesterday_low, "\nC ",before_yesterday_close);
double pivot = (yesterday_high + yesterday_low + yesterday_close)/3;// Standard Pivot

drawLine(yesterday_low,"YLow", Plum,0);
drawLabel("Low yesterday",yesterday_low,Plum);
drawLine(before_yesterday_low,"B4YLow", Plum,0);
drawLabel("Low before yesterday",before_yesterday_low,Plum);

drawLine(pivot,"PIVOT",Aqua,1);
drawLabel("Pivot level",pivot,Aqua);

drawLine(yesterday_high,"YHigh",CornflowerBlue,0);
drawLabel("High yesterday",yesterday_high,CornflowerBlue);
drawLine(before_yesterday_high,"B4YHigh",CornflowerBlue,0);
drawLabel("High before yesterday",before_yesterday_high,CornflowerBlue);


//----
   return(0);
  }
//+------------------------------------------------------------------+
void drawLabel(string name,double lvl,color Color)
{
    if(ObjectFind(name) != 0)
    {
        ObjectCreate(name, OBJ_TEXT, 0, Time[10], lvl);
        ObjectSetText(name, name, 8, "Arial", EMPTY);
        ObjectSet(name, OBJPROP_COLOR, Color);
    }
    else
    {
        ObjectMove(name, 0, Time[10], lvl);
    }
}


void drawLine(double lvl,string name, color Col,int type)
{
         if(ObjectFind(name) != 0)
         {
            ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
            
            if(type == 1)
            ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
            else
            ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
            
            ObjectSet(name, OBJPROP_COLOR, Col);
            ObjectSet(name,OBJPROP_WIDTH,1);
            
         }
         else
         {
            ObjectDelete(name);
            ObjectCreate(name, OBJ_HLINE, 0, Time[0], lvl,Time[0],lvl);
            
            if(type == 1)
            ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
            else
            ObjectSet(name, OBJPROP_STYLE, STYLE_DOT);
            
            ObjectSet(name, OBJPROP_COLOR, Col);        
            ObjectSet(name,OBJPROP_WIDTH,1);
          
         }
}

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