i-Friday_Sig_v1
Download scriptThis indicator is designed to provide visual trading signals specifically centered around the market dynamics of Friday sessions. It identifies potential entry and exit points by analyzing price action relative to the previous day's performance, helping traders navigate the specific volatility often associated with the end of the trading week.
Core Logic and Functionality
The script operates by monitoring the daily candle behavior to determine when to trigger "Buy" or "Sell" signals, as well as corresponding "Exit" cues. Its primary logic is governed by three main components:
1. Time-Based Filtering The tool specifically looks for activity on Fridays. It scans the market timeline to identify two specific windows of time:
- The Opening Window: Triggered at a user-defined hour (defaulting to 07:00) to highlight potential entry points.
- The Closing Window: Triggered at a user-defined hour (defaulting to 19:00) to signal potential exit points for the day's positions.
2. Price Action Analysis To decide which direction a signal should point, the script compares the current price of the Friday session against the previous trading day's "Open" and "Close" prices.
- Bearish Sentiment: If the previous day ended lower than it started (a downward move), the script prepares to generate sell-side signals during the specified Friday windows.
- Bullish Sentiment: If the previous day ended higher than it started (an upward move), the script prepares to generate buy-side signals.
3. Dynamic Visual Positioning To ensure the chart remains clean and readable, the indicator automatically calculates how far away the arrows should appear from the actual candles. This "interval" is not fixed; it scales dynamically based on the timeframe you are currently viewing (e.g., it places arrows further away on higher timeframes like Daily charts compared to shorter intervals like 1-minute charts).
Visual Output
- Entry Signals: Displayed as arrows appearing at the high or low of the price candle during the opening window, indicating whether the script suggests a "Buy" or "Sell" based on the previous day's trend.
- Exit Signals: Displayed as distinct markers during the closing window, providing a visual cue for closing out active positions.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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