Pivot_only_H4

Download script
Author: Copyright � 2006, Forex-TSD.com
Pivot_only_H4

This script is designed as a specialized visual tool for traders who use the MetaTrader platform to analyze market price movements. Its primary purpose is to automatically identify and display "Pivot Points" on a chart, specifically calculated based on the 4-hour (H4) timeframe.

Core Functionality

The tool functions by scanning historical data to pinpoint key price levels where the market might experience a shift in direction or significant interest. Instead of cluttering the screen with every possible price point, this script focuses exclusively on the 4-hour interval, making it ideal for swing traders or those who prefer a "bigger picture" view of the currency or asset markets.

How the Logic Works

To determine where to place these visual markers, the script follows a specific mathematical process:

  • Data Gathering: The script looks back at the previous 4-hour candle to collect three essential pieces of information: the highest price reached (High), the lowest price reached (Low), and the price at which the candle finished (Close).
  • The Calculation: It takes these three values and calculates their average. By adding the High, Low, and Close together and dividing by three, it identifies a "central" price point for that specific time block.
  • Visual Mapping: Once the script calculates this average value (the Pivot), it draws a horizontal line on your chart. These lines are styled to be clearly visible but secondary to the price action (placed in the background), allowing you to see exactly where these historical support or resistance levels sit.
  • Scope: The tool is configured to look back through a large history of data (up to 1,000 days), ensuring that as you scroll back through your charts, the historical pivots remain visible to help you identify recurring patterns.

Summary for the User

In simple terms, this script automates the "math" of technical analysis. Instead of you having to manually calculate the average price of every 4-hour session, the script does it for you instantly. It paints a map of historical pivots across your chart, helping you visualize key levels where the market has historically balanced itself, which can assist in identifying potential entry or exit zones.

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
10 Views
0 Downloads
0 Favorites
Pivot_only_H4
//+------------------------------------------------------------------+
//|                                                   Pivot_only_H4.mq4 |
//|                                                   upgrade by Darkkiller |  
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                 AllPivots_v1.mq4 |
//|                                  Copyright © 2006, Forex-TSD.com |
//|                         Written by IgorAD,igorad2003@yahoo.co.uk |   
//|            http://finance.groups.yahoo.com/group/TrendLaboratory |                                      
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"

#property indicator_chart_window

extern int  CountDays=1000;



   datetime time1;
   datetime time2;
   double open,close,high,low;
   double P;
   
   int shift, num;
     
   void ObjDel()
   {
      for (;num<=CountDays;num++)
      {
      ObjectDelete("Pivot H4["+num+"]");
      
      }
   }

   void PlotLine(string name,double value,double line_color,double style)
   {
   ObjectCreate(name,OBJ_TREND,0,time1,value,time2,value);
   ObjectSet(name, OBJPROP_WIDTH, 2);
   ObjectSet(name, OBJPROP_STYLE, style);
   ObjectSet(name, OBJPROP_RAY, false);
   ObjectSet(name, OBJPROP_BACK, true);
   ObjectSet(name, OBJPROP_COLOR, line_color);
    }        
int init()
  {

  return(0);
  }
   
   
int deinit()
  {
   ObjDel();
   Comment("");
   return(0);
  }

int start()
  {
  int i;
     
  ObjDel();
  num=0;
  
  for (shift=CountDays-1;shift>=0;shift--)
  {
  time1=iTime(NULL,PERIOD_H4,shift);
  i=shift-1;
  if (i<0) 
  time2=Time[0];
  else
  time2=iTime(NULL,PERIOD_H4,i)-Period()*60;
         
  high  = iHigh(NULL,PERIOD_H4,shift+1);
  low   = iLow(NULL,PERIOD_H4,shift+1);
  close = iClose(NULL,PERIOD_H4,shift+1);
       
  P  = (high+low+close)/3.0;
        

  time2=time1+PERIOD_H4*60;
         
 
  num=shift;
       
  PlotLine("Pivot H4["+num+"]",P,Yellow,0);
  
  }
   return(0);
  }
//+------------------------------------------------------------------+

Comments