PrevDay-HiLo-kelvin

Download script
Author: Copyright � 2005, Fermin Da Costa Gomez
PrevDay-HiLo-kelvin

This tool is designed to help traders visualize and monitor key historical price milestones directly on their trading charts. Specifically, it automatically identifies and plots three critical data points from the previous trading day: the highest price reached, the lowest price reached, and the opening price.

How the Logic Works

The script scans through your market history to identify the transition between different calendar days. Every time the software detects a new day beginning, it performs the following actions:

  • Data Capture: It looks back at the completed trading session to "lock in" the maximum high and minimum low reached during that period.
  • Opening Reference: It captures the exact price at which the market opened on that previous day.
  • Visual Mapping: Once these three values are identified, the script projects them onto your current chart as horizontal levels.

Key Features for the User

  • Automated Tracking: You do not need to manually look up yesterday's highs or lows; the script calculates these automatically as new days form.
  • Visual Clarity: The tool places specific labels on the chart—"Prev. Day High," "Prev. Day Low," and "Prev. Day Open"—so you can see exactly where these boundaries sit in relation to current market movement.
  • Timeframe Compatibility: The logic is designed to work efficiently on shorter timeframes (specifically those under 4 hours), ensuring the daily transitions are captured accurately for your analysis.
  • Dynamic Updates: As the chart progresses, the indicator ensures that these levels remain visible, providing a constant reference point for identifying potential support or resistance zones based on yesterday's price action.
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
PrevDay-HiLo-kelvin
/*+------------------------------------------------------------------+
 | FileName: i_DCG_Camarilla.mq4
 | Author: Copyright © 2005, Fermin Da Costa Gomez
 | Version : 01 (Inital code)
 | 
 +------------------------------------------------------------------+*/
#property copyright "Copyright © 2005, Fermin Da Costa Gomez"
#property link      "http://forex.viahetweb.nl"

#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 Aqua
#property indicator_color2 Aqua
#property indicator_color3 Red

//---- input parameters

//---- buffers

double PrevDayHiBuffer[];
double PrevDayLoBuffer[];
double PrevDayOpenBuffer[];

int fontsize=10;
double PrevDayHi, PrevDayLo, PrevDayOpen;
double LastHigh,LastLow,x;



//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here

   
   ObjectDelete("PrevDayHi");
   ObjectDelete("PrevDayLo"); 
   ObjectDelete("PrevDayOpen");    
//
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;


//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   
  
   SetIndexBuffer(0, PrevDayHiBuffer);
   SetIndexBuffer(1, PrevDayLoBuffer);
   SetIndexBuffer(2, PrevDayOpenBuffer);
   


//---- name for DataWindow and indicator subwindow label
   short_name="Prev Hi-Lo levels";
   IndicatorShortName(short_name);
   SetIndexLabel(0, short_name);

//----
   SetIndexDrawBegin(0,1);
//----
 

//----
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()

  {
   int    counted_bars=IndicatorCounted();

   int limit, i;
//---- indicator calculation
if (counted_bars==0)
{
   x=Period();
   if (x>240) return(-1);
   ObjectCreate("PrevDayHi", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("PrevDayHi", "                Prev. Day High",fontsize,"Arial", Aqua);
   ObjectCreate("PrevDayLo", OBJ_TEXT, 0, 0, 0);   
   ObjectSetText("PrevDayLo", "                Prev. Day Low",fontsize,"Arial", Aqua); 
ObjectCreate("PrevDayOpen", OBJ_TEXT, 0, 0, 0);
   ObjectSetText("PrevDayOpen", "                Prev. Day Open",fontsize,"Arial", Red);
   //---- last counted bar will be recounted
//   if(counted_bars>0) counted_bars--;
} 
  limit=(Bars-counted_bars)-1;



for (i=limit; i>=0;i--)
{ 

if (High[i+1]>LastHigh) LastHigh=High[i+1];
if (Low[i+1]<LastLow) LastLow=Low[i+1];
//Print("TimeDay(Time[i]=",TimeDay(Time[i]),"TimeDay(Time[i+1])",TimeDay(Time[i+1]));
if (TimeDay(Time[i])!=TimeDay(Time[i+1]))
   { 
   PrevDayHi=LastHigh;
PrevDayLo=LastLow;
PrevDayOpen=Open[i];
   LastLow=Open[i];
   LastHigh=Open[i];

  
   ObjectMove("PrevDayHi", 0, Time[i], PrevDayHi);
   ObjectMove("PrevDayLo", 0, Time[i], PrevDayLo);
    ObjectMove("PrevDayOpen", 0, Time[i], PrevDayOpen);

   }
   
    PrevDayHiBuffer[i]=PrevDayHi;
    PrevDayLoBuffer[i]=PrevDayLo;
    PrevDayOpenBuffer[i]=PrevDayOpen;
}

//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments