This script is designed to provide traders with a clear visual map of significant price levels on a trading chart. By automatically identifying and plotting specific technical boundaries, it helps users understand potential areas of support and resistance based on the daily opening price.
Core Functionality
The logic centers around a "Daily Open" reference point. The script identifies the start of each trading day (based on a user-defined hour) and captures the exact price at which the market opened. From this single starting price, the tool calculates several horizontal levels to project forward:
- Resistance Levels: These are calculated above the daily open price. They represent "ceilings" where price may encounter difficulty moving higher.
- Support Levels: These are calculated below the daily open price. They represent "floors" where price may find buyers and struggle to drop further.
- Opening Price Line: A distinct line marks the baseline from which all other levels are derived.
Mathematical Logic
Instead of using standard arbitrary increments, the script uses specific multipliers to determine the distance of each level from the daily open. It automatically adjusts for different currency decimal places (such as 4-digit vs. 5-digit brokers) to ensure that the lines appear accurately regardless of the asset being traded.
Visual Presentation
The tool is designed for high readability on a live chart:
- Color Coding: It uses contrasting colors (typically Red for Resistance and Lime for Support) to allow traders to distinguish between "selling" and "buying" zones at a glance.
- Dynamic Labeling: The script includes an optional labeling system. This places text directly on the chart next to each line, clearly identifying which level is which (e.g., "R1", "S2", "Daily Open"). These labels update automatically as new price data arrives.
- Automatic Updates: The logic continuously scans the history of the chart to ensure that as a new day begins, the levels reset and recalculate based on the newest daily open price.
Summary for the User
Essentially, this tool acts as an automated "grid" generator. It removes the manual work of calculating mathematical price boundaries, providing you with a visual roadmap of where the market might react during the trading day based on the initial opening price.
//+------------------------------------------------------------------+
//| FIB PIVOT GMT OFFSET|
//| Limstylz |
//+------------------------------------------------------------------+
#property copyright "Limstylz"
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_color5 Lime
#property indicator_color6 Lime
#property indicator_color7 Lime
#property indicator_color8 Lime
#property indicator_style1 4
#property indicator_style2 4
#property indicator_style3 4
#property indicator_style4 0
#property indicator_style5 4
#property indicator_style6 4
#property indicator_style7 4
#property indicator_style8 4
#property indicator_width4 2
//---- input parameters
extern int StartHour=6;
extern color ResColour=Red;
extern color SupColour=Lime;
extern int LineWidth=1;
extern int SRLineStyle=4;
extern color OpenColour=White;
extern int OpenLineWidth=2;
extern int OpenSRLineStyle=0;
extern bool ShowLabel=true;
extern int FontSize=10;
extern color FontColour=DarkGray;
//---- buffers
double ResLevel3[];
double ResLevel2[];
double ResLevel1[];
double OpenPrice[];
double SupLevel1[];
double SupLevel2[];
double SupLevel3[];
double SupLevel4[];
//---- variables
int limit, cur_day, barChangeDay;
double DailyOpen,RL1,RL2,RL3,SL1,SL2,SL3,SL4,point;
datetime LabelShiftTime;
int LabelShift =0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,SRLineStyle,LineWidth,ResColour);
SetIndexBuffer(0,ResLevel3);
SetIndexStyle(1,DRAW_LINE,SRLineStyle,LineWidth,ResColour);
SetIndexBuffer(1,ResLevel2);
SetIndexStyle(2,DRAW_LINE,SRLineStyle,LineWidth,ResColour);
SetIndexBuffer(2,ResLevel1);
SetIndexStyle(3,DRAW_LINE,OpenSRLineStyle,OpenLineWidth,OpenColour);
SetIndexBuffer(3,OpenPrice);
SetIndexStyle(4,DRAW_LINE,SRLineStyle,LineWidth,SupColour);
SetIndexBuffer(4,SupLevel1);
SetIndexStyle(5,DRAW_LINE,SRLineStyle,LineWidth,SupColour);
SetIndexBuffer(5,SupLevel2);
SetIndexStyle(6,DRAW_LINE,SRLineStyle,LineWidth,SupColour);
SetIndexBuffer(6,SupLevel3);
SetIndexStyle(7,DRAW_LINE,SRLineStyle,LineWidth,SupColour);
SetIndexBuffer(7,SupLevel4);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll(0,OBJ_TEXT);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//----
for(int i=limit; i>=0; i--)
{
cur_day = TimeDay(Time[i]);
if (
TimeHour(Time[i]) == StartHour &&
TimeMinute(Time[i]) == 0
)
{
barChangeDay = i;
DailyOpen = Open[i];
if (Digits == 5) point= Point*10;
if (Digits == 4) point= Point;
if (Digits == 3) point= Point*10;
if (Digits == 2) point= Point;
RL1 = DailyOpen+(34*point);
RL2 = DailyOpen+(55*point);
RL3 = DailyOpen+(89*point);
SL1 = DailyOpen-(34*point);
SL2 = DailyOpen-(55*point);
SL3 = DailyOpen-(89*point);
SL4 = DailyOpen-(144*point);
}
ResLevel3[i]=RL3;
ResLevel2[i]=RL2;
ResLevel1[i]=RL1;
OpenPrice[i]=DailyOpen;
SupLevel1[i]=SL1;
SupLevel3[i]=SL3;
SupLevel2[i]=SL2;
SupLevel4[i]=SL4;
if (ShowLabel){
LabelShiftTime = Time[LabelShift]+1200;
ObjectCreate("Daily R3", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily R3", " R3 " +DoubleToStr(RL3,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(0, "Daily R3");
ObjectCreate("Daily R2", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily R2", " R2 " +DoubleToStr(RL2,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(1, "Daily R2");
ObjectCreate("Daily R1", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily R1", " R1 " +DoubleToStr(RL1,Digits),FontSize," ",FontColour);
SetIndexLabel(2, "Daily R1");
ObjectCreate("Daily Open", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily Open", " Open " +DoubleToStr(DailyOpen,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(3, "Daily Open");
ObjectCreate("Daily S1", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily S1", " S1 " +DoubleToStr(SL1,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(4, "Daily S1");
ObjectCreate("Daily S2", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily S2", " S2 " +DoubleToStr(SL2,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(5, "Daily S2");
ObjectCreate("Daily S3", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily S3", " S3 " +DoubleToStr(SL3,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(6, "Daily S3");
ObjectCreate("Daily S4", OBJ_TEXT, 0, LabelShiftTime, 0);
ObjectSetText("Daily S4", " S4 " +DoubleToStr(SL4,Digits),FontSize,"arial ",FontColour);
SetIndexLabel(7, "Daily S4");
ObjectMove("Daily R3", 0, LabelShiftTime,RL3);
ObjectMove("Daily R2", 0, LabelShiftTime,RL2);
ObjectMove("Daily R1", 0, LabelShiftTime,RL1);
ObjectMove("Daily Open", 0, LabelShiftTime,DailyOpen);
ObjectMove("Daily S1", 0, LabelShiftTime,SL1);
ObjectMove("Daily S2", 0, LabelShiftTime,SL2);
ObjectMove("Daily S3", 0, LabelShiftTime,SL3);
ObjectMove("Daily S4", 0, LabelShiftTime,SL4);
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments