Setka_Final
Download scriptThis tool is designed to enhance your trading charts by automatically plotting visual markers that help identify key time boundaries and price levels. It simplifies chart navigation by highlighting when significant shifts in time occur and providing a structured "grid" of price points.
The logic operates through two primary functions:
1. Time Boundary Markers
The script monitors the flow of time and places vertical markers on your chart to highlight specific transitions. These markers appear automatically depending on the timeframe you are currently viewing:
- Hourly Transitions: Marks the beginning of every new hour.
- Daily Transitions: Highlights the start of each new day.
- Weekly Transitions: Identifies the beginning of a new week.
- Monthly Transitions: Marks the start of a new month (specifically when it coincides with a new week).
These vertical indicators help traders quickly orient themselves within the weekly, daily, or hourly sessions, making it easier to see how price action develops relative to these standard time blocks.
2. Psychological Price Grid
Beyond time markers, the script generates a "psychological" horizontal grid across your current screen. Rather than relying on specific historical data points, it creates a systematic layout of horizontal lines based on the following logic:
- Dynamic Visibility: The grid automatically calculates based on the highest and lowest prices currently visible in your viewing window. If you scroll or zoom the chart, the grid adjusts to stay relevant to your current view.
- Step-Based Intervals: It places horizontal lines at regular intervals (the "Step"). This creates a visual reference for price movement, helping traders see "round" levels or significant zones more clearly.
- Visual Differentiation: To prevent the chart from becoming cluttered, the script alternates the styles and colors of these horizontal lines. It uses different colors (such as DodgerBlue and DimGray) and varying line styles (like dashed/dotted patterns) so that you can distinguish between different levels at a glance.
- Timeframe Optimization: The script is intelligent enough to limit the visibility of these horizontal lines on specific timeframes, ensuring that the chart remains clean and readable whether you are looking at high-frequency movements or broader trends.
Summary for the User
In essence, this script acts as an automated "map" for your charts. It tells you exactly where you are in terms of time (hours, days, weeks, months) and provides a consistent visual structure for price, allowing you to better identify potential support, resistance, or psychological levels without having to draw them manually.
//+----------------------------------------------------------------------------+
//| Setka_Final.mq4 |
//| Àâòîð : Ñåðãåé Ïðèâàëîâ aka Prival, Skype: privalov-sv |
//+----------------------------------------------------------------------------+
//| Âåðñèÿ : 30.04.2010 |
//| Îïèñàíèå: àëüòåðíàòèâíàÿ ñåòêà, ðèñóåò âåðòèêàëüíûå ëèíèè íà÷àëà ÷àñà, äíÿ,|
//| íåäåëè è ìåñÿöà, òàêæå ðèñóåò ïñèõîëîãè÷åñêèå ãîðèçîíòàëüíûå óðîâíè |
//+----------------------------------------------------------------------------+
#property copyright "Ïðèâàëîâ Ñ.Â."
#property link "Skype -> privalov-sv"
#property indicator_chart_window
#property indicator_buffers 8
extern double Øàã=0; // øàã ñåòêè 0 âûáîð àëãðèòìà èíà÷å çàäàâàéòå ñàìè
//---- buffers
double Ind_Buffer_0[],Ind_Buffer_1[];
double Ind_Buffer_2[],Ind_Buffer_3[];
double Ind_Buffer_4[],Ind_Buffer_5[];
double Ind_Buffer_6[],Ind_Buffer_7[];
double max;
color LineColor; // ïåðåìåííàÿ äëÿ öâåòà ãîðèçîíòàëüíîé ëèíèè
int LineStile; // ïåðåìåííàÿ äëÿ ñòèëÿ
int LineWidth; // ïåðåìåííàÿ äëÿ øèðèíû ëèíèè
int Period_Ris; // ïåðèîä ãðàôèêà äëÿ àíàëèçà îòîáðàæåíèÿ
bool flag=true;
double Window_Max=0, old_Window_Max=0;
double Window_Min=0, old_Window_Min=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_DOT, 1, DimGray);
SetIndexStyle(1,DRAW_HISTOGRAM, STYLE_DOT, 1, DimGray);
SetIndexStyle(2,DRAW_HISTOGRAM, STYLE_DOT, 1, RoyalBlue);
SetIndexStyle(3,DRAW_HISTOGRAM, STYLE_DOT, 1, RoyalBlue);
SetIndexStyle(4,DRAW_HISTOGRAM, STYLE_DOT, 1, DeepPink);
SetIndexStyle(5,DRAW_HISTOGRAM, STYLE_DOT, 1, DeepPink);
SetIndexStyle(6,DRAW_HISTOGRAM, STYLE_DOT, 1, Gold);
SetIndexStyle(7,DRAW_HISTOGRAM, STYLE_DOT, 1, Gold);
SetIndexBuffer(0,Ind_Buffer_0);
SetIndexBuffer(1,Ind_Buffer_1);
SetIndexBuffer(2,Ind_Buffer_2);
SetIndexBuffer(3,Ind_Buffer_3);
SetIndexBuffer(4,Ind_Buffer_4);
SetIndexBuffer(5,Ind_Buffer_5);
SetIndexBuffer(6,Ind_Buffer_6);
SetIndexBuffer(7,Ind_Buffer_7);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(0,OBJ_HLINE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, j, limit, counted_bars=IndicatorCounted();
bool new_Hour, new_Day, new_Week, new_Month;
if(counted_bars <0) return(-1);
if(counted_bars==0) limit=Bars-1; // ïîñ÷èòàííûõ áàðîâ åùå íåò, áóäåò ñ÷èòàòü ñ áàðà,
if(counted_bars >0) limit=Bars-counted_bars-1;// âû÷òåì èç ÷èñëà äîñòóïíûõ áàðîâ êîëè÷åñòâî ïîñ÷èòàííûõ
if(counted_bars==0) limit-=2;
if(flag) max=iHigh(0,PERIOD_MN1,iHighest(NULL,PERIOD_MN1,MODE_HIGH,iBars(0,PERIOD_MN1),0));
for(i = limit; i >= 0; i--)
{
new_Hour=TimeHour(Time[i]) != TimeHour(Time[i+1]); // íîâûé ÷àñ
new_Day=TimeDay(Time[i]) != TimeDay(Time[i+1]); // íîâûé äåíü
new_Week=TimeDayOfWeek(Time[i])==1; // íîâàÿ íåäåëÿ
if(TimeMonth(Time[i]) != TimeMonth(Time[i+1])) new_Month=true; // íîâûé ìåñÿö
Ind_Buffer_0[i]=0;
Ind_Buffer_1[i]=0;
Ind_Buffer_2[i]=0;
Ind_Buffer_3[i]=0;
Ind_Buffer_4[i]=0;
Ind_Buffer_5[i]=0;
Ind_Buffer_6[i]=0;
Ind_Buffer_7[i]=0;
if(new_Hour && Period()<15 ) Ind_Buffer_0[i]=max;
if(new_Day && Period()<240) Ind_Buffer_2[i]=max;
if(new_Week && new_Day && Period()<1440) Ind_Buffer_4[i]=max;
if(new_Month && new_Day && new_Week) {Ind_Buffer_6[i]=max; new_Month=false;}
}// end for(i...
Window_Max=WindowPriceMax();
Window_Min=WindowPriceMin();
if((Window_Max!=old_Window_Max) || (Window_Min!=old_Window_Min)) SetGLine(); // îòðèñîâêà ãîðèçîíòàëüíûõ ëèíèé
return(0);
}
// -------------- óñòàíîâêà ãîðèçîíòàëüíûõ ëèíèé ---------------------------
// âûïîëíÿåòñÿ ïðè èçìåíåíèè ðàçìåðîâ îêíà (Window_Max èëè Window_Min)
void SetGLine()
{
double Uroven=0.0; // óðîâåíü óñòàíîâêè ãîðèçîíòàëüíîé ëèíèè
ObjectsDeleteAll(0,OBJ_HLINE); // óäàëÿåì âñå ãîðèçîíòàëüíûå ëèíèè
int i=0;
if(Øàã==0) //
{
Øàã=50;
if(Digits==5) Øàã=500;
if(Digits==1) Øàã=500;
}
old_Window_Min=Window_Min;
old_Window_Max=Window_Max;
while(Uroven<Window_Max) {
i++;
Uroven=i*Øàã*Point;
if(Uroven>=Window_Min) {
if(MathMod(i,2)==0) {
LineColor=DodgerBlue; // ÷åòíàÿ ëèíèÿ
LineStile=STYLE_DASHDOTDOT;
Period_Ris=0x007F; // îòðèñîâêà òîëüêî íà Ì1,Ì5,M15,M30 è H1
}
else {
LineColor=DimGray; // íå÷åòíàÿ ëèíèÿ
LineStile=STYLE_DASHDOTDOT;
Period_Ris=0x001F; // îòðèñîâêà òîëüêî íà Ì1,Ì5,M15,M30 è H1
}
SetHLine(LineColor, "HLine_"+i, Uroven, LineStile,0,Period_Ris);
}// end if(Uroven>Min)
}// end while (Uroven<Max)
flag=false;
}//end óñòàíîâêè ãîðèçîíòàëüíûõ ëèíèé
//+----------------------------------------------------------------------------+
//| Àâòîð : Êèì Èãîðü Â. aka KimIV, http://www.kimiv.ru |
//| ìîäèôèêàöèÿ: Ñ.Ïðèâàëîâ aka Prival |
//+----------------------------------------------------------------------------+
//| Âåðñèÿ : 12.02.2009 |
//| Îïèñàíèå : Óñòàíîâêà îáúåêòà OBJ_HLINE ãîðèçîíòàëüíàÿ ëèíèÿ |
//+----------------------------------------------------------------------------+
//| Ïàðàìåòðû: |
//| cl - öâåò ëèíèè |
//| nm - íàèìåíîâàíèå ("" - âðåìÿ îòêðûòèÿ òåêóùåãî áàðà) |
//| p1 - öåíîâîé óðîâåíü (0 - Bid) |
//| st - ñòèëü ëèíèè (0 - ïðîñòàÿ ëèíèÿ) |
//| wd - øèðèíà ëèíèè (0 - ïî óìîë÷àíèþ) |
//| pr - ïåðèîä îòîáðàæåíèÿ (0 - ïî óìîë÷àíèþ -> íà âñåõ ÒÔ) |
//+----------------------------------------------------------------------------+
void SetHLine(color cl, string nm="", double p1=0, int st=0, int wd=0, int pr=0) {
if (nm=="") nm=DoubleToStr(Time[0], 0);
if (p1<=0) p1=Bid;
if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_HLINE, 0, 0,0); else Print("Îøèáêà");
ObjectSet(nm, OBJPROP_PRICE1, p1);
ObjectSet(nm, OBJPROP_COLOR , cl);
ObjectSet(nm, OBJPROP_STYLE , st);
ObjectSet(nm, OBJPROP_WIDTH , wd);
ObjectSet(nm, OBJPROP_TIMEFRAMES , pr);
}
Comments