i-Friday_Sig_v3
Download scriptThis technical script is designed to identify specific entry and exit points for traders based on daily price action movements, specifically targeting Friday market activity. Rather than using complex mathematical formulas or moving averages, it relies on a systematic approach to recognize "Friday" signals by comparing current prices against the previous day's performance.
Core Logic Overview
The script functions by scanning historical data and identifying two specific types of events: Entry Signals (Buy/Sell) and Exit Signals. It determines these based on the time of day, the specific day of the week, and the relationship between the previous day’s opening and closing prices.
Key Components of the Logic
1. Temporal Filtering (The "When") The script is highly specific about timing. It only looks for signals on Fridays. Within that day, it distinguishes between two specific hours:
- An Opening Window: Where it seeks to identify opportunities to enter a trade.
- A Closing Window: Where it identifies points to exit an existing position.
2. Price Action Analysis (The "Why") To decide whether to signal a Buy or a Sell, the script looks back at the previous completed day (Daily Period). It compares the opening price of that day to its closing price:
- Bearish Logic: If the previous day closed lower than it opened, the script identifies a downward trend. In this scenario, it will provide a "Sell" signal during the opening window and an "Exit" signal during the closing window.
- Bullish Logic: If the previous day closed higher than it opened, the script identifies an upward trend. It will then provide a "Buy" signal during the opening window and an "Exit" signal during the closing window.
3. Visual Output The script translates these logical conclusions into visual markers on your chart:
- Buy/Sell Arrows: These appear at specific price levels (slightly above or below the candle) to show where a trade might be initiated.
- Exit Markers: These appear specifically at the closing price of the preceding candle to signal when a position should be liquidated.
User Customization
The script allows for user input regarding the specific hours for openings and closings, making it adaptable to different market sessions. It also includes an automatic "Arrow Interval" logic that adjusts how far the visual markers are placed from the candles depending on the timeframe you are currently viewing (e.g., a 1-minute chart will have tighter spacing than a 4-hour chart).
//+------------------------------------------------------------------+
//| i-Friday_Sig.mq4 |
//| Êèì Èãîðü Â. aka KimIV |
//| http://www.kimiv.ru |
//| |
//| 09.10.2005 Ñèãíàëû âõîäîâ è âûõîäîâ ïî ñèñòåìå Ýôôåêò ïÿòíèöû |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link "http://www.kimiv.ru"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Salmon
#property indicator_color3 Blue
#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