i-Friday_Sig_v2

Download script
Author: ��� ����� �. aka KimIV
i-Friday_Sig_v2

This script is a specialized trading indicator designed for the MetaTrader platform to identify specific entry and exit opportunities based on price action from the previous trading day. Instead of using complex mathematical formulas, it relies on a systematic "Friday Signal" logic that looks at the relationship between the opening and closing prices of daily candles.

Core Logic and Functionality

The primary goal of this tool is to provide visual markers (arrows) on your chart to indicate when to consider a purchase (Buy) or a sale (Sell), as well as when to exit those positions. It operates based on several key parameters:

1. Time-Based Filtering The script is specifically programmed to monitor the market on Fridays. It checks for specific hours of the day to determine whether it should display a signal. Users can customize these hours in the settings to align with their preferred trading sessions.

2. Price Action Analysis To generate a signal, the script analyzes the "Daily" timeframe data. It compares the price at which the previous day started (Open) against the price at which it ended (Close).

  • Buy Signals: These are triggered if the previous day's opening price was higher than its closing price (indicating a downward movement), provided the current time matches the user-defined "Buy" hour.
  • Sell Signals: These are triggered if the previous day's opening price was lower than its closing price (indicating an upward movement), provided the current time matches the user-defined "Sell" hour.

3. Automated Exit Markers In addition to telling you when to enter a trade, the script also provides exit signals. It identifies specific times during the day when the conditions for a trade have met their intended duration or logical conclusion based on the previous day's price trend. This helps traders manage their risk by providing a clear visual cue of when to close a position.

4. Adaptive Visual Scaling The script includes a "Smart Interval" feature. Depending on which timeframe you are viewing (e.g., 1-minute charts versus 4-hour charts), the script automatically adjusts how far away from the price candles the arrows are placed. This ensures that the visual markers remain clear and do not clutter the screen, regardless of the zoom level or timeframe used.

Summary for the User

Essentially, this tool acts as a "Friday Strategy Assistant." It looks at what happened yesterday to tell you what might happen today, placing markers on your chart to suggest the best moments to enter or exit trades based on pre-defined time windows and historical price trends.

Price Data Components
Series array that contains close prices for each bar
8 Views
0 Downloads
0 Favorites
i-Friday_Sig_v2
//+------------------------------------------------------------------+
//|                                                 i-Friday_Sig.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 09.10.2005  Ñèãíàëû âõîäîâ è âûõîäîâ ïî ñèñòåìå Ýôôåêò ïÿòíèöû   |
//| 20.10.2005  Ðàçäåëèë ñèãíàëû íà ïîêóïêó è ïðîäàæó                |
//+------------------------------------------------------------------+
#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 HourOpenBuy   = 1;      // Âðåìÿ îòêðûòèÿ ïîêóïêè
extern int HourCloseBuy  = 23;     // Âðåìÿ çàêðûòèÿ ïîêóïêè
extern int HourOpenSell  = 7;      // Âðåìÿ îòêðûòèÿ ïðîäàæè
extern int HourCloseSell = 19;     // Âðåìÿ çàêðûòèÿ ïðîäàæè
extern int NumberOfBars  = 10000;  // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)

//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
int ArrowInterval, prevDay;

//------- Ïîêëþ÷åíèå âíåøíèõ ìîäóëåé ---------------------------------

//------- Áóôåðû èíäèêàòîðà ------------------------------------------
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;

 	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];
    prevDay=TimeDay(Time[shift]);
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé              |
//+------------------------------------------------------------------+
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])==HourOpenBuy && Op1>Cl1) ms[0]=Low[nb]-ArrowInterval*Point;
    if (TimeHour(Time[nb])==HourOpenSell && Op1<Cl1) ms[1]=High[nb]+ArrowInterval*Point;
    if (TimeHour(Time[nb])==HourCloseBuy && Op1>Cl1) ms[2]=Close[nb+1];
    if (TimeHour(Time[nb])==HourCloseSell && Op1<Cl1) ms[3]=Close[nb+1];
  }
}
//+------------------------------------------------------------------+

Comments