This script is a specialized trading indicator designed to identify specific entry and exit opportunities based on the market behavior of Fridays. It focuses on capturing price movements associated with the end of the weekly trading cycle, specifically by analyzing daily price data.
Core Logic Overview
The tool operates by monitoring historical and real-time price data to pinpoint two distinct types of events: Entry Signals and Exit Signals. Unlike standard indicators that might react to every minor price fluctuation, this script is highly selective, only triggering signals when specific time-based conditions are met on a Friday.
How the Logic Works
1. Time and Day Filtering The script constantly checks the current market time. It ignores all trading days except for Fridays. Even on Fridays, it only looks for signals at two specific times of the day, which can be customized by the user (the default settings are set to a morning "Open" hour and an evening "Close" hour).
2. Entry Signal Detection When the script identifies the designated opening hour on a Friday, it looks back at the previous day's price action (Daily candles) to determine the trend:
- Bearish Sentiment: If the previous day closed lower than it opened, the script identifies a potential downward move and places a "Sell" signal on the chart.
- Bullish Sentiment: If the previous day closed higher than it opened, the script identifies a potential upward move and places a "Buy" signal on the chart.
3. Exit Signal Detection The script also monitors the designated closing hour on Friday. At this point, it evaluates whether the position should be closed based on that same previous-day trend:
- It places an "Exit" signal to indicate when a trade initiated during the morning should be concluded, ensuring the trader follows the logic of the daily price flow.
4. Dynamic Visual Spacing To ensure the visual interface remains clean and readable across different trading timeframes (such as 1-minute charts versus 4-hour charts), the script automatically calculates a specific "buffer" distance. This prevents the arrows from overlapping with the candles, ensuring they remain clearly visible regardless of whether you are viewing small, fast-moving price changes or larger daily trends.
Summary of Behavior
In simple terms, this script acts as a Friday filter. It looks at what happened yesterday to predict the mood of today's Friday session. If the market was strong yesterday, it signals opportunities to follow that strength in the morning and provides a clear cue on when to step out of the market by the evening.
//+------------------------------------------------------------------+
//| i-Friday_Sig.mq4 |
//| Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 09.10.2005 Enter and exit signals on Friday effect |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link "http://www.kimiv.ru"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 LightBlue
#property indicator_color2 Salmon
#property indicator_color3 LightBlue
#property indicator_color4 Salmon
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int HourOpenPos = 7; // Âðåìÿ îòêðûòèÿ ïîçèöèè
extern int HourClosePos = 19; // Âðåìÿ çàêðûòèÿ ïîçèöèè
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
int ArrowInterval;
//------- Ïîêëþ÷åíèå âíåøíèõ ìîäóëåé ---------------------------------
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int NumberOfBars = 10000; // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double SigBuy[];
double SigSell[];
double SigExitBuy[];
double SigExitSell[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
SetIndexBuffer(0, SigBuy);
SetIndexStyle (0, DRAW_ARROW);
SetIndexArrow (0, 233);
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexBuffer(1, SigSell);
SetIndexStyle (1, DRAW_ARROW);
SetIndexArrow (1, 234);
SetIndexEmptyValue(1, EMPTY_VALUE);
SetIndexBuffer(2, SigExitBuy);
SetIndexStyle (2, DRAW_ARROW);
SetIndexArrow (2, 251);
SetIndexEmptyValue(2, EMPTY_VALUE);
SetIndexBuffer(3, SigExitSell);
SetIndexStyle (3, DRAW_ARROW);
SetIndexArrow (3, 251);
SetIndexEmptyValue(3, EMPTY_VALUE);
ArrowInterval = GetArrowInterval();
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start() {
double ms[4];
int loopbegin, shift, ids;
if (NumberOfBars==0) loopbegin = Bars - 1;
else loopbegin = NumberOfBars - 1;
for (shift=loopbegin; shift>=0; shift--) {
ms[0] = EMPTY_VALUE;
ms[1] = EMPTY_VALUE;
ms[2] = EMPTY_VALUE;
ms[3] = EMPTY_VALUE;
GetSignals(shift, ms);
SigBuy[shift] = ms[0];
SigSell[shift] = ms[1];
SigExitBuy[shift+1] = ms[2];
SigExitSell[shift+1] = ms[3];
}
}
//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé |
//+------------------------------------------------------------------+
int GetArrowInterval() {
int p = Period();
switch (p) {
case 1: return(5);
case 5: return(7);
case 15: return(10);
case 30: return(15);
case 60: return(20);
case 240: return(30);
case 1440: return(80);
case 10080: return(150);
case 43200: return(250);
}
}
//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé |
//+------------------------------------------------------------------+
void GetSignals(int nb, double& ms[]) {
int nsb=iBarShift(NULL, PERIOD_D1, Time[nb]);
double Op1=iOpen (NULL, PERIOD_D1, nsb+1);
double Cl1=iClose(NULL, PERIOD_D1, nsb+1);
if (TimeDayOfWeek(Time[nb])==5 && TimeMinute(Time[nb])==0) {
if (TimeHour(Time[nb])==HourOpenPos) {
if (Op1>Cl1) ms[0]=Low[nb]-ArrowInterval*Point;
if (Op1<Cl1) ms[1]=High[nb]+ArrowInterval*Point;
}
if (TimeHour(Time[nb])==HourClosePos) {
if (Op1>Cl1) ms[2]=Close[nb+1];
if (Op1<Cl1) ms[3]=Close[nb+1];
}
}
}
//+------------------------------------------------------------------+
Comments