grid yens3

This script is designed to act as a visual navigation tool for traders, automatically calculating and drawing key price levels on a trading chart. It focuses on identifying potential support and resistance zones based on historical price action across three different timeframes: Daily, Weekly, and Monthly.

Core Functionality

The script identifies significant price boundaries by analyzing the highest highs, lowest lows, and closing prices of previous periods. It then applies specific mathematical formulas to project these levels onto your current chart, helping you visualize where the market might encounter "walls" (resistance) or "floors" (support).

Key Components

1. Daily Pivot Analysis When enabled, the script looks at the price action of the previous day to calculate:

  • Pivot Point: The central equilibrium price for the current day.
  • Resistance Levels (R1, R2, R3): Price ceilings where the market might struggle to move higher.
  • Support Levels (S1, S2, S3): Price floors where the market might find a base to bounce back up from.

2. Weekly Dynamic Grid The script creates an extensive grid based on the opening price of the current week. It generates 16 distinct levels (labeled WR21 through WS28). These act as specific markers, providing a dense map of potential price reactions throughout the week's trading cycle. These are visually distinguished to help you see both upside and downside targets simultaneously.

3. Monthly Pivot Analysis Similar to the daily logic, the script analyzes the previous month's data to project:

  • Monthly Pivot: The central price point for the current month.
  • Monthly Resistance (MR1, MR2, MR3): Major long-term ceilings.
  • Monthly Support (MS1, MS2, MS3): Major long-term floors.

User Experience and Visuals

  • Automated Drawing: You do not need to calculate these numbers manually. The script automatically draws horizontal lines on your chart at the correct prices.
  • Clear Labeling: Each line is accompanied by a text label (e.g., "Daily R1" or "+900") so you can immediately identify what each level represents without looking back at the settings.
  • Color Coding: The script uses distinct colors for different types of levels (such as Magenta, Red, Lime Green, and Blue) to help you differentiate between support, resistance, and neutral pivot points at a glance.
  • Clean Workspace: The script includes a "cleanup" routine. When you remove the indicator from your chart, it automatically deletes all the lines and labels it created, leaving your workspace clean.
8 Views
0 Downloads
0 Favorites
grid yens3
//+------------------------------------------------------------------+
//|        KlPivot_Weekly_yen.mq4              by Habeeb             |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window

   extern bool Daily   = False;
   extern bool Weekly  = True;
   extern bool Monthly = False;

   double YesterdayHigh;
   double YesterdayLow;
   double YesterdayClose;
   double Day_Price[][6];
   double Pivot,S1,S2,S3,R1,R2,R3;
   
   double WeekOpen;
   double WeekLow;
   double WeekClose;
   double Weekly_Price[][6];
   double WeekPivot,WS21,WS22,WS23,WS24,WS25,WS26,WS27,WS28,WR21,WR22,WR23,WR24,WR25,WR26,WR27,WR28;
   
   double MonthHigh;
   double MonthLow;
   double MonthClose;
   double Month_Price[][6];
   double MonthPivot,MS1,MS2,MS3,MR1,MR2,MR3;

int init()
  {
   return(0);
  }
  
//-------------------------------------------------------- 
  
int deinit()
  {
ObjectDelete("PivotLine");

ObjectDelete("R1_Line");
ObjectDelete("R2_Line");
ObjectDelete("R3_Line");

ObjectDelete("S1_Line");
ObjectDelete("S2_Line");
ObjectDelete("S3_Line");  

//--------------------------------

ObjectDelete("PivotLabel");

ObjectDelete("R1_Label");
ObjectDelete("R2_Label");
ObjectDelete("R3_Label");

ObjectDelete("S1_Label");
ObjectDelete("S2_Label");
ObjectDelete("S3_Label"); 

//--------------------------------------------------------

ObjectDelete("WR21_Line");
ObjectDelete("WR22_Line");
ObjectDelete("WR23_Line");
ObjectDelete("WR24_Line");
ObjectDelete("WR25_Line");
ObjectDelete("WR26_Line");
ObjectDelete("WR27_Line");
ObjectDelete("WR28_Line");

ObjectDelete("WS21_Line");
ObjectDelete("WS22_Line");
ObjectDelete("WS23_Line");
ObjectDelete("WS24_Line");
ObjectDelete("WS25_Line");
ObjectDelete("WS26_Line");
ObjectDelete("WS27_Line");
ObjectDelete("WS28_Line"); 

//--------------------------------

ObjectDelete("WR21_Label");
ObjectDelete("WR22_Label");
ObjectDelete("WR23_Label");
ObjectDelete("WR24_Label");
ObjectDelete("WR25_Label");
ObjectDelete("WR26_Label");
ObjectDelete("WR27_Label");
ObjectDelete("WR28_Label");


ObjectDelete("WS21_Label");
ObjectDelete("WS22_Label");
ObjectDelete("WS23_Label");
ObjectDelete("WS24_Label");
ObjectDelete("WS25_Label");
ObjectDelete("WS26_Label");
ObjectDelete("WS27_Label");
ObjectDelete("WS28_Label");

 

//--------------------------------------------------------

ObjectDelete("MonthPivotLine");

ObjectDelete("MR1_Line");
ObjectDelete("MR2_Line");
ObjectDelete("MR3_Line");

ObjectDelete("MS1_Line");
ObjectDelete("MS2_Line");
ObjectDelete("MS3_Line");  

//--------------------------------

ObjectDelete("MonthPivotLabel");

ObjectDelete("MR1_Label");
ObjectDelete("MR2_Label");
ObjectDelete("MR3_Label");

ObjectDelete("MS1_Label");
ObjectDelete("MS2_Label");
ObjectDelete("MS3_Label");

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

int start()
{

ArrayInitialize(Day_Price,0);
ArrayCopyRates(Day_Price,(Symbol()), 1440);


YesterdayHigh  = Day_Price[1][3];
YesterdayLow   = Day_Price[1][2];
YesterdayClose = Day_Price[1][4];

Pivot = ((YesterdayHigh + YesterdayLow + YesterdayClose)/3);

   R1 = (2*Pivot)-YesterdayLow;
   S1 = (2*Pivot)-YesterdayHigh;

   R2 = Pivot+(R1-S1);
   S2 = Pivot-(R1-S1);

   S3 = (YesterdayLow - (2*(YesterdayHigh-Pivot)));
   R3 = (YesterdayHigh + (2*(Pivot-YesterdayLow)));

//--------------------------------------------------------
//--------------------------------------------------------

ArrayInitialize(Weekly_Price, 0);
ArrayCopyRates(Weekly_Price, Symbol(), 10080);

WeekOpen  = Weekly_Price[0][1];
//WeekLow   = Weekly_Price[1][2];
//WeekClose = Weekly_Price[1][4];

WeekPivot = WeekOpen;

      WR21 = WeekPivot + 8.5;
      WS21 = WeekPivot - 8.5;

      WR22 = WeekPivot + 9.0;
      WS22 = WeekPivot - 9.0;

      WS23 = WeekPivot - 9.5;
      WR23 = WeekPivot + 9.5;
      
      WS24 = WeekPivot - 10.0;
      WR24 = WeekPivot + 10.0;
      
      WS25 = WeekPivot - 10.50;
      WR25 = WeekPivot + 10.5;
      
      WS26 = WeekPivot - 11.0;
      WR26 = WeekPivot + 11.0;
      
      WS27 = WeekPivot - 11.50;
      WR27 = WeekPivot + 11.50;
      
      WS28 = WeekPivot - 12.00;
      WR28 = WeekPivot + 12.00;          

//--------------------------------------------------------
//--------------------------------------------------------

ArrayInitialize(Month_Price, 0);
ArrayCopyRates(Month_Price, Symbol(), 43200);

MonthHigh  = Month_Price[1][3];
MonthLow   = Month_Price[1][2];
MonthClose = Month_Price[1][4];

MonthPivot = ((MonthHigh + MonthLow + MonthClose)/3);

      MR1 = (2*MonthPivot)-MonthLow;
      MS1 = (2*MonthPivot)-MonthHigh;

      MR2 = MonthPivot+(MR1-MS1);
      MS2 = MonthPivot-(MR1-MS1);

      MS3 = (MonthLow - (2*(MonthHigh-MonthPivot)));
      MR3 = (MonthHigh + (2*(MonthPivot-MonthLow)));

//--------------------------------------------------------

if (Daily==true)
{

ObjectCreate("PivotLine", OBJ_HLINE,0, CurTime(),Pivot);
ObjectSet("PivotLine", OBJPROP_COLOR, Magenta);
ObjectSet("PivotLine", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("PivotLabel") != 0)
{
ObjectCreate("PivotLabel", OBJ_TEXT, 0, Time[20], Pivot);
ObjectSetText("PivotLabel", "Daily Pivot", 8, "Arial", Magenta);
}
else
{
ObjectMove("PivotLabel", 0, Time[20], Pivot);
}

//--------------------------------------------------------

ObjectCreate("R1_Line", OBJ_HLINE,0, CurTime(),R1);
ObjectSet("R1_Line", OBJPROP_COLOR, Maroon);
ObjectSet("R1_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("R1_Label") != 0)
{
ObjectCreate("R1_Label", OBJ_TEXT, 0, Time[20], R1);
ObjectSetText("R1_Label", "Daily R1", 8, "Arial", Red);
}
else
{
ObjectMove("R1_Label", 0, Time[20], R1);
}

//--------------------------------------------------------

ObjectCreate("R2_Line", OBJ_HLINE,0, CurTime(),R2);
ObjectSet("R2_Line", OBJPROP_COLOR, Red);
ObjectSet("R2_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("R2_Label") != 0)
{
ObjectCreate("R2_Label", OBJ_TEXT, 0, Time[20], R2);
ObjectSetText("R2_Label", "Daily R2", 8, "Arial", Red);
}
else
{
ObjectMove("R2_Label", 0, Time[20], R2);
}

//---------------------------------------------------------

ObjectCreate("R3_Line", OBJ_HLINE,0, CurTime(),R3);
ObjectSet("R3_Line", OBJPROP_COLOR, Red);
ObjectSet("R3_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("R3_Label") != 0)
{
ObjectCreate("R3_Label", OBJ_TEXT, 0, Time[20], R3);
ObjectSetText("R3_Label", "Daily R3", 8, "Arial", Red);
}
else
{
ObjectMove("R3_Label", 0, Time[20], R3);
}

//---------------------------------------------------------

ObjectCreate("S1_Line", OBJ_HLINE,0, CurTime(),S1);
ObjectSet("S1_Line", OBJPROP_COLOR, LimeGreen);
ObjectSet("S1_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("S1_Label") != 0)
{
ObjectCreate("S1_Label", OBJ_TEXT, 0, Time[20], S1);
ObjectSetText("S1_Label", "Daily S1", 8, "Arial", LimeGreen);
}
else
{
ObjectMove("S1_Label", 0, Time[20], S1);
}

//---------------------------------------------------------

ObjectCreate("S2_Line", OBJ_HLINE,0, CurTime(),S2);
ObjectSet("S2_Line", OBJPROP_COLOR, LimeGreen);
ObjectSet("S2_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("S2_Label") != 0)
{
ObjectCreate("S2_Label", OBJ_TEXT, 0, Time[20], S2);
ObjectSetText("S2_Label", "Daily S2", 8, "Arial", LimeGreen);
}
else
{
ObjectMove("S2_Label", 0, Time[20], S2);
}
//---------------------------------------------------------

ObjectCreate("S3_Line", OBJ_HLINE,0, CurTime(),S3);
ObjectSet("S3_Line", OBJPROP_COLOR, LimeGreen);
ObjectSet("S3_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("S3_Label") != 0)
{
ObjectCreate("S3_Label", OBJ_TEXT, 0, Time[20], S3);
ObjectSetText("S3_Label", "Daily S3", 8, "Arial", LimeGreen);
}
else
{
ObjectMove("S3_Label", 0, Time[20], S3);
}
}
ObjectsRedraw();

//---------------------------------------------------------
//---------------------------------------------------------
//---------------------------------------------------------



//--------------------------------------------------------

ObjectCreate("WR22_Line", OBJ_HLINE,0, CurTime(),WR22);
ObjectSet("WR22_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR22_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR22_Label") != 0)
{
ObjectCreate("WR22_Label", OBJ_TEXT, 0, Time[30], WR22);
ObjectSetText("WR22_Label", " +900", 8, "Arial", White);
}
else
{
ObjectMove("WR12_Label", 0, Time[30], WR22);
}

//---------------------------------------------------------

ObjectCreate("WR23_Line", OBJ_HLINE,0, CurTime(),WR23);
ObjectSet("WR23_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR23_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR23_Label") != 0)
{
ObjectCreate("WR23_Label", OBJ_TEXT, 0, Time[30], WR23);
ObjectSetText("WR23_Label", " +950", 8, "Arial", White);
}
else
{
ObjectMove("WR23_Label", 0, Time[30], WR23);
}

//---------------------------------------------------------

ObjectCreate("WR24_Line", OBJ_HLINE,0, CurTime(),WR24);
ObjectSet("WR24_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR24_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR24_Label") != 0)
{
ObjectCreate("WR24_Label", OBJ_TEXT, 0, Time[30], WR24);
ObjectSetText("WR24_Label", " +1000", 8, "Arial", White);
}
else
{
ObjectMove("WR24_Label", 0, Time[30], WR24);
}
//---------------------------------------------------------

ObjectCreate("WR25_Line", OBJ_HLINE,0, CurTime(),WR25);
ObjectSet("WR25_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR25_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR25_Label") != 0)
{
ObjectCreate("WR25_Label", OBJ_TEXT, 0, Time[30], WR25);
ObjectSetText("WR25_Label", " +1050", 8, "Arial", White);
}
else
{
ObjectMove("WR25_Label", 0, Time[30], WR25);
}

//---------------------------------------------------------

ObjectCreate("WR26_Line", OBJ_HLINE,0, CurTime(),WR26);
ObjectSet("WR26_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR26_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR26_Label") != 0)
{
ObjectCreate("WR26_Label", OBJ_TEXT, 0, Time[30], WR26);
ObjectSetText("WR26_Label", " +1100", 8, "Arial", White);
}
else
{
ObjectMove("WR26_Label", 0, Time[30], WR26);
}

//---------------------------------------------------------

ObjectCreate("WR27_Line", OBJ_HLINE,0, CurTime(),WR27);
ObjectSet("WR27_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR27_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR27_Label") != 0)
{
ObjectCreate("WR27_Label", OBJ_TEXT, 0, Time[30], WR27);
ObjectSetText("WR27_Label", " +1150", 8, "Arial", White);
}
else
{
ObjectMove("WR27_Label", 0, Time[30], WR27);
}


//---------------------------------------------------------

ObjectCreate("WR28_Line", OBJ_HLINE,0, CurTime(),WR28);
ObjectSet("WR28_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WR28_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WR28_Label") != 0)
{
ObjectCreate("WR28_Label", OBJ_TEXT, 0, Time[30], WR28);
ObjectSetText("WR28_Label", " ", +1200, "Arial", White);
}
else
{
ObjectMove("WR28_Label", 0, Time[30], WR28);
}


//--------------------------------------------------------

ObjectCreate("WS21_Line", OBJ_HLINE,0, CurTime(),WS21);
ObjectSet("WS21_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS21_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS21_Label") != 0)
{
ObjectCreate("WS21_Label", OBJ_TEXT, 0, Time[30], WS21);
ObjectSetText("WS21_Label", "-850", 8, "Arial", White);
}
else
{
ObjectMove("WS21_Label", 0, Time[30], WS21);
}

//---------------------------------------------------------

ObjectCreate("WS22_Line", OBJ_HLINE,0, CurTime(),WS22);
ObjectSet("WS22_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS22_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS22_Label") != 0)
{
ObjectCreate("WS22_Label", OBJ_TEXT, 0, Time[30], WS22);
ObjectSetText("WS22_Label", " -900", 8, "Arial", White);
}
else
{
ObjectMove("WS22_Label", 0, Time[30], WS22);
}

//---------------------------------------------------------

ObjectCreate("WS23_Line", OBJ_HLINE,0, CurTime(),WS23);
ObjectSet("WS23_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS23_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS23_Label") != 0)
{
ObjectCreate("WS23_Label", OBJ_TEXT, 0, Time[30], WS23);
ObjectSetText("WS23_Label", "-950", 8, "Arial", White);
}
else
{
ObjectMove("WS23_Label", 0, Time[30], WS23);
}

//---------------------------------------------------------
ObjectCreate("WS24_Line", OBJ_HLINE,0, CurTime(),WS24);
ObjectSet("WS24_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS24_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS24_Label") != 0)
{
ObjectCreate("WS24_Label", OBJ_TEXT, 0, Time[30], WS24);
ObjectSetText("WS24_Label", "-1000", 8, "Arial", White);
}
else
{
ObjectMove("WS24_Label", 0, Time[30], WS24);
}


//---------------------------------------------------------
//---------------------------------------------------------
ObjectCreate("WS25_Line", OBJ_HLINE,0, CurTime(),WS25);
ObjectSet("WS25_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS25_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS25_Label") != 0)
{
ObjectCreate("WS25_Label", OBJ_TEXT, 0, Time[30], WS25);
ObjectSetText("WS25_Label", "-1050", 8, "Arial", White);
}
else
{
ObjectMove("WS25_Label", 0, Time[30], WS25);
}
//---------------------------------------------------------
ObjectCreate("WS26_Line", OBJ_HLINE,0, CurTime(),WS26);
ObjectSet("WS26_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS26_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS26_Label") != 0)
{
ObjectCreate("WS26_Label", OBJ_TEXT, 0, Time[30], WS26);
ObjectSetText("WS26_Label", "-1100", 8, "Arial", White);
}
else
{
ObjectMove("WS26_Label", 0, Time[30], WS26);
}
//---------------------------------------------------------
ObjectCreate("WS27_Line", OBJ_HLINE,0, CurTime(),WS27);
ObjectSet("WS27_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS27_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS27_Label") != 0)
{
ObjectCreate("WS27_Label", OBJ_TEXT, 0, Time[30], WS27);
ObjectSetText("WS27_Label", " -1150", 8, "Arial", White);
}
else
{
ObjectMove("WS27_Label", 0, Time[30], WS27);
}
//---------------------------------------------------------
ObjectCreate("WS28_Line", OBJ_HLINE,0, CurTime(),WS28);
ObjectSet("WS28_Line", OBJPROP_COLOR, MediumBlue);
ObjectSet("WS28_Line", OBJPROP_STYLE, STYLE_SOLID);

if(ObjectFind("WS28_Label") != 0)
{
ObjectCreate("WS28_Label", OBJ_TEXT, 0, Time[30], WS28);
ObjectSetText("WS28_Label", " -1200", 8, "Arial", White);
}
else
{
ObjectMove("WS28_Label", 0, Time[30], WS28);

}
}

//---------------------------------------------------------


Comments