4 Hour high_low LA

Author: Copyright � Terry Nicholls
4 Hour high_low    LA
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
4 Hour high_low LA
//+------------------------------------------------------------------+
//|                                               Daily_High_Low.mq4 |
//|                                       Copyright © Terry Nicholls |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|Updated code to reflect Weekly high/low  - Steve Fleming          |
//|Free e-course teaching you how to write your own EA. No previous  |
//|programming skills needed.                                        |
//|http://www.automatedtradingsoftware.com                           |
//+------------------------------------------------------------------+
#property copyright "Copyright © Terry Nicholls"

// Parameters

#property indicator_chart_window

extern int TimeZoneOfData = 0; // GMT

double lastweek_high=0;
double lastweek_low=0;

double rates_H4[2][6];
double FourHourlyh;
double FourHourlyl;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
  {

// Indicators

FourHourlyh=0; FourHourlyl=0;

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+

int deinit()
  {

ObjectDelete("FourHourly Label");
ObjectDelete("FourHourly Line");
ObjectDelete("FourHourlyl Label");
ObjectDelete("FourHourlyl Line");

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {

// Get new Daily prices

ArrayCopyRates(rates_H4, Symbol(), PERIOD_H4);

lastweek_high = rates_H4[1][3];
lastweek_low = rates_H4[1][2];

// Calculate Daily High/Low lines

FourHourlyh = lastweek_high;
FourHourlyl = lastweek_low;

// Uncomment the line below to display the data at the top of your chart

// Comment ("Yesterday's High = ",lastweek_high,"  Yesterday's Low = ",lastweek_low);

// Set Daily High/Low line labels on chart window

      if(ObjectFind("FourHourlyh label") != 0)
      {
      ObjectCreate("FourHourlyh label", OBJ_TEXT, 0, Time[20], FourHourlyh);
      ObjectSetText("FourHourlyh label", "Prev 4 Hour High", 10, "Arial", Aqua);
      }
      else
      {
      ObjectMove("FourHourlyh label", 0, Time[20], FourHourlyh);
      }

      if(ObjectFind("FourHourlyl label") != 0)
      {
      ObjectCreate("FourHourlyl label", OBJ_TEXT, 0, Time[20], FourHourlyl);
      ObjectSetText("FourHourlyl label", "Prev 4 Hour Low", 10, "Arial", HotPink);
      }
      else
      {
      ObjectMove("FourHourlyl label", 0, Time[20], FourHourlyl);
      }

// Draw Yesterday's High/Low lines on chart

      if(ObjectFind("FourHourlyh line") != 0)
      {
      ObjectCreate("FourHourlyh line", OBJ_HLINE, 0, Time[40], FourHourlyh);
      ObjectSet("FourHourlyh line", OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("FourHourlyh line", OBJPROP_WIDTH,0 );
      ObjectSet("FourHourlyh line", OBJPROP_COLOR, Aqua);
      //Alert("Weekly Low" ,Symbol()," ",Period()," @ ",Bid);PlaySound("Boat_horn.wav");
      }
      else
      {
      ObjectMove("FourHourlyh line", 0, Time[40], FourHourlyh);
      }

      if(ObjectFind("FourHourlyl line") != 0)
      {
      ObjectCreate("FourHourlyl line", OBJ_HLINE, 0, Time[40], FourHourlyl);
      ObjectSet("FourHourlyl line", OBJPROP_STYLE, STYLE_DASH);
      ObjectSet("FourHourlyl line", OBJPROP_WIDTH, 0);
      ObjectSet("FourHourlyl line", OBJPROP_COLOR, HotPink);
      //Alert("Weekly High" ,Symbol()," ",Period()," @ ",Bid);PlaySound("Boat_horn.wav");
      }
      else
      {
      ObjectMove("FourHourlyl line", 0, Time[40], FourHourlyl);
      }

   return(0); // End program

  }

//+------------------------------------------------------------------+

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