Pivot_only_M15

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

This script is designed to automatically identify and display specific price levels known as "Pivot Points" on a trading chart. It specifically focuses on the 15-minute timeframe to help traders visualize historical and current market structure.

Core Functionality

The primary purpose of this tool is to calculate a central balance point for each 15-minute interval based on previous price action. Instead of looking at where the price is moving now, it looks back at the data from the preceding period to determine where the "center" of that price movement was.

How the Logic Works

To determine the position of each line on your chart, the script follows a three-step process for every 15-minute block:

  • Data Collection: For every time slot, the script retrieves three key pieces of information from the previous candle: the highest price reached (High), the lowest price reached (Low), and the final price at which that period ended (Close).
  • The Calculation: It takes these three values—High, Low, and Close—adds them together, and divides by three. This provides a mathematical average of the previous price action, creating a single "Pivot" value.
  • Visual Mapping: Once this value is calculated, the script draws a horizontal line on your chart at that specific price level. It repeats this process for a large number of past intervals (up to 1,000 days' worth of data, depending on your settings), creating a historical map of these pivot levels.

Key Features

  • Automated Cleanup: Every time the chart updates or the script is reloaded, it automatically clears out old lines and redraws them to ensure the information remains accurate and doesn't clutter the screen with redundant data.
  • Visual Clarity: The lines are styled to appear in the background of the chart in yellow, allowing you to see the price levels clearly without obstructing your view of the current candles.
  • Historical Depth: Because it processes a large number of previous periods, it allows you to see how these pivot points have behaved over a long period of time, helping you identify potential areas of support or resistance based on past market behavior.
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
11 Views
0 Downloads
0 Favorites
Pivot_only_M15
//+------------------------------------------------------------------+
//|                                                   Pivot_only_M15.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 M15["+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_M15,shift);
  i=shift-1;
  if (i<0) 
  time2=Time[0];
  else
  time2=iTime(NULL,PERIOD_M15,i)-Period()*60;
         
  high  = iHigh(NULL,PERIOD_M15,shift+1);
  low   = iLow(NULL,PERIOD_M15,shift+1);
  close = iClose(NULL,PERIOD_M15,shift+1);
       
  P  = (high+low+close)/3.0;
        

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

Comments