weekly_high_low-

Download script
Author: Copyright � Terry Nicholls
weekly_high_low-

This script is designed to act as a visual aid for traders who want to identify key historical price levels on their trading charts. Specifically, it automates the process of identifying and displaying the highest and lowest prices reached during the previous week.

Core Functionality

The primary goal of this tool is to simplify technical analysis by highlighting "Weekly Highs" and "Weekly Lows." Instead of a trader having to manually look back at historical data to find these specific price points, the script calculates them automatically and draws them directly on the current chart.

How the Logic Works

  1. Data Retrieval: The script automatically scans the market history to locate the data from the previous week. It specifically looks for the highest price point reached (the "high") and the lowest price point reached (the "low") during that timeframe.
  2. Dynamic Calculation: Every time the chart updates, the script ensures it is looking at the most relevant completed week. It extracts these two specific values—the peak and the valley of last week's trading activity.
  3. Visual Rendering: Once the script identifies these prices, it performs two main visual actions on your screen:
    • Labels: It places text labels on the chart that clearly state "Last Wks High" and "Last Wks Low." This makes it immediately obvious to the user what the lines represent.
    • Horizontal Lines: It draws dashed horizontal lines across the chart at these exact price levels. These lines serve as permanent visual markers, allowing traders to see where the price is currently trading in relation to last week's boundaries.

User Experience

From a user's perspective, this script acts as an automated "drawing" tool. You don't need to calculate any numbers or hunt through old charts; the script simply places yellow dashed lines on your screen that represent the boundaries of the previous week's price action. This helps in identifying potential support and resistance levels at a glance.

Miscellaneous
It plays sound alerts
6 Views
0 Downloads
0 Favorites
weekly_high_low-
//+------------------------------------------------------------------+
//|                                               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_d1[2][6];
double wklyh;
double wklyl;

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

int init()
  {

// Indicators

wklyh=0; wklyl=0;

   return(0);
  }

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

int deinit()
  {

ObjectDelete("wklyh Label");
ObjectDelete("wklyh Line");
ObjectDelete("wklyl Label");
ObjectDelete("wklyl Line");

   return(0);
  }

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

int start()
  {

// Get new Daily prices

ArrayCopyRates(rates_d1, Symbol(), PERIOD_W1);

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

// Calculate Daily High/Low lines

wklyh = lastweek_high;
wklyl = 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("wklyh label") != 0)
      {
      ObjectCreate("wklyh label", OBJ_TEXT, 0, Time[20], wklyh);
      ObjectSetText("wklyh label", "Last Wks High", 10, "Arial", Yellow);
      }
      else
      {
      ObjectMove("wklyh label", 0, Time[20], wklyh);
      }

      if(ObjectFind("wklyl label") != 0)
      {
      ObjectCreate("wklyl label", OBJ_TEXT, 0, Time[20], wklyl);
      ObjectSetText("wklyl label", "Last Wks Low", 10, "Arial", Yellow);
      }
      else
      {
      ObjectMove("wklyl label", 0, Time[20], wklyl);
      }

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

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

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

   return(0); // End program

  }

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

Comments