Author: ��� ����� �. aka KimIV
i-3SAR-Sig

This script is designed as a visual trading assistant for MetaTrader, specifically created to identify potential trend reversals by analyzing the Parabolic SAR indicator from three different perspectives simultaneously.

Core Logic and Methodology

The primary goal of this tool is to filter out "market noise" by ensuring that a trade signal is supported by multiple timeframes or cycles. Instead of relying on a single calculation, the script monitors three distinct Parabolic SAR values:

  1. Current Trend Analysis: It calculates a Parabolic SAR based on the immediate price action. This represents what is happening in the market right now.
  2. Historical Context (Long-Term): It tracks two additional Parabolic SAR values calculated over much larger periods. These act as "background filters" to ensure that the current move aligns with the broader trend or a significant shift in momentum.

How Signals are Generated

The script looks for specific "crossover" moments. Rather than showing a signal every time the price moves, it waits for a very specific confirmation:

  • Buy Signal: A visual arrow appears when the current Parabolic SAR flips to indicate an upward trend, provided that both of the older, larger-period indicators have already flipped or are currently aligned with this bullish movement.
  • Sell Signal: Conversely, a downward arrow is triggered when the current Parabolic SAR flips to signal a downtrend, but only if the two historical indicators also confirm that the broader market structure has shifted to the downside.

Key Features for the User

  • Multi-Layered Confirmation: By requiring the "old" parabolas to be flipped before the "current" one triggers a signal, the script helps traders avoid "fake-outs"—situations where the price moves briefly in one direction before returning to its original path.
  • Dynamic Visual Positioning: The script automatically adjusts the distance of the visual arrows from the candles based on the timeframe you are viewing (e.g., it places arrows further away on large timeframes like Daily charts and closer together on small ones like 1-minute charts) to ensure the chart remains clean and easy to read.
  • Automated Back-Scanning: The tool can analyze a specific number of historical bars (defaulting to 1000) to show you where these trend shifts occurred in the past, allowing you to see how the logic would have performed on previous data.
Indicators Used
Parabolic Stop and Reverse system
11 Views
0 Downloads
0 Favorites
i-3SAR-Sig
//+------------------------------------------------------------------+
//|                                                   i-3SAR-Sig.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|   11.06.2005  Èíäèêàòîð ñèãíàëîâ ïî òð¸ì ïàðàáîëèêàì.            |
//| Îäèí ïàðàáîëèê ðàáîòàåò íà òåêóùåì ÒÔ, à äâà äðóãèå - íà ñòàðøèõ.|
//| Ñèãíàë - ýòî ïåðåêëþ÷åíèå òåêóùåãî ïàðàáîëèêîâ. Ïðè ýòîì ñòàðøèå |
//| óæå äîëæíû áûòü ïåðåêëþ÷åííûìè.                                  |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Salmon

//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int    NumberOfBars = 1000;    // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
extern double StepSAR      = 0.02;    // Øàã òåêóùåãî ïàðàáîëèêà
extern double MaxSAR       = 0.2;     // Ìàêñèìóì òåêóùåãî ïàðàáîëèêà
extern int    PeriodSAR1   = 60;      // Ïåðèîä ïåðâîãî ñòàðøåãî ïàðàáîëèêà
extern double StepSAR1     = 0.02;    // Øàã ïåðâîãî ñòàðøåãî ïàðàáîëèêà
extern double MaxSAR1      = 0.2;     // Ìàêñèìóì ïåðâîãî ñòàðøåãî ïàðàáîëèêà
extern int    PeriodSAR2   = 240;     // Ïåðèîä âòîðîãî ñòàðøåãî ïàðàáîëèêà
extern double StepSAR2     = 0.02;    // Øàã âòîðîãî ñòàðøåãî ïàðàáîëèêà
extern double MaxSAR2      = 0.2;     // Ìàêñèìóì âòîðîãî ñòàðøåãî ïàðàáîëèêà

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

//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double SigBuy[];
double SigSell[];

//+------------------------------------------------------------------+
//| 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);

  ArrowInterval=GetArrowInterval();
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start() {
  double ms[2];
  int    LoopBegin, sh;

 	if (NumberOfBars==0) LoopBegin=Bars-1;
  else LoopBegin=NumberOfBars-1;

  for (sh=LoopBegin; sh>=0; sh--) {
    ms[0]=EMPTY_VALUE;
    ms[1]=EMPTY_VALUE;
    GetSignals(sh, ms);
    SigBuy[sh]=ms[0];
    SigSell[sh]=ms[1];
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò ñèãíàëû                                               |
//+------------------------------------------------------------------+
void GetSignals(int nb, double& ms[]) {
  double tsar0=iSAR(NULL, 0, StepSAR, MaxSAR, nb);
  double tsar1=iSAR(NULL, 0, StepSAR, MaxSAR, nb+1);
  int nb1=iBarShift(NULL, PeriodSAR1, Time[nb]);
  double sar1=iSAR(NULL, PeriodSAR1, StepSAR1, MaxSAR1, nb1);
  int nb2=iBarShift(NULL, PeriodSAR2, Time[nb]);
  double sar2=iSAR(NULL, PeriodSAR2, StepSAR2, MaxSAR2, nb2);

  if (tsar1>Close[nb+1] && tsar0<Close[nb] && sar1<Close[nb] && sar2<Close[nb])
    ms[0]=Low[nb]-ArrowInterval*Point;
  if (tsar1<Close[nb+1] && tsar0>Close[nb] && sar1>Close[nb] && sar2>Close[nb])
    ms[1]=High[nb]+ArrowInterval*Point;
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò èíòåðâàë óñòàíîâêè ñèãíàëüíûõ óêàçàòåëåé              |
//+------------------------------------------------------------------+
int GetArrowInterval() {
  int p=Period();

  switch (p) {
    case 1:     return(3);
    case 5:     return(5);
    case 15:    return(8);
    case 30:    return(12);
    case 60:    return(17);
    case 240:   return(25);
    case 1440:  return(50);
    case 10080: return(100);
    case 43200: return(200);
  }
}
//+------------------------------------------------------------------+

Comments