4 Hour high_low LA

Download script
Author: Copyright � Terry Nicholls
4 Hour high_low    LA

This script is designed as a visual navigation tool for traders who need to identify key historical price levels on their trading charts. Its primary purpose is to automatically track and display specific high and low price points from previous market sessions, allowing for a clearer view of significant support and resistance areas.

Core Functionality

The logic operates by scanning the historical data of the 4-hour timeframe. It specifically looks back to identify the highest and lowest prices recorded during the previous period. Once these two specific values are identified, the script performs the following actions:

  • Data Tracking: It constantly monitors the market to ensure it is pulling the correct high and low figures based on the most recent completed data blocks.
  • Visual Plotting: The script automatically draws two horizontal dashed lines across your current chart. These lines serve as visual anchors, showing you exactly where the previous highs and lows sit in relation to the current live price action.
  • Dynamic Labeling: To ensure the user knows exactly what they are looking at, the script places text labels directly on the chart. The upper line is labeled to indicate the "Prev 4 Hour High," and the lower line is labeled as the "Prev 4 Hour Low."
  • Visual Differentiation: The tool uses distinct colors (Aqua for the high and HotPink for the low) to make it easy for a trader to distinguish between the two boundaries at a glance.

User Experience

Instead of requiring a trader to manually research past price data or calculate where previous levels were, this script automates that process in real-time. As new data becomes available, the lines and labels automatically move to reflect the most recent historical high and low. This provides a clean, organized workspace that helps traders visualize potential "turning points" in the market more efficiently.

Miscellaneous
It plays sound alerts
6 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