i-Friday_Sig(1)

Download script
Author: ��� ����� �. aka KimIV
i-Friday_Sig(1)

This script is a specialized trading indicator designed to identify specific entry and exit opportunities based on historical daily price movements. It automates the visual identification of signals by monitoring the relationship between opening and closing prices on a daily timeframe.

Core Logic Overview

The tool operates primarily on a "Friday" logic, specifically looking for conditions that occur at set times during the trading week. Instead of reacting to every small price fluctuation (noise), it filters for significant shifts in sentiment based on the previous day's performance.

Key Functionalities

1. Signal Identification (Entry Points) The script evaluates the price action of the previous trading day to determine the direction for a new position. It specifically looks at whether the previous day's opening price was higher or lower than its closing price:

  • Sell Signals: If the previous day closed lower than it opened (downward trend), the script identifies a potential selling opportunity.
  • Buy Signals: If the previous day closed higher than it opened (upward trend), the script identifies a potential buying opportunity.

2. Time-Based Execution The logic is not "always on." It is programmed to trigger signals only during specific hours of the week:

  • Opening Positions: The script monitors for entry signals at a user-defined hour (defaulting to 07:00).
  • Closing Positions: The script identifies exit points at a different user-defined hour (defaulting to 19:00).

3. Visual Execution on the Chart The script translates these mathematical conditions into visual markers directly on your trading screen:

  • Arrows: It places distinct arrows at the top or bottom of the price candles to show exactly where a "Buy" or "Sell" signal has been triggered.
  • Exit Markers: It also provides specific indicators to signal when it is time to close an existing position based on the pre-set closing hour.

4. Dynamic Scaling The script includes an intelligent scaling mechanism that adjusts the distance of the visual arrows based on the timeframe you are currently viewing (e.g., 1-minute charts vs. 1-hour charts). This ensures that the icons remain clearly visible and do not overlap with the price candles, regardless of the zoom level.

Summary for Traders

In simple terms, this tool looks at yesterday's "success" or "failure" (did it close up or down?) and then provides you with a visual prompt on specific times during the current day to either enter a trade in that same direction or exit your current position to manage risk.

Price Data Components
Series array that contains close prices for each bar
12 Views
0 Downloads
0 Favorites
i-Friday_Sig(1)
//+------------------------------------------------------------------+
//|                                                 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 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