Parabolic_4cNK

Download script
Author: Copyright � 2006, Nikolay Kositsin
Parabolic_4cNK

This script is a specialized trading tool designed to analyze market trends by calculating and visualizing "Parabolic SAR" (Stop and Reverse) values. Its primary purpose is to help traders identify potential trend reversals and determine the strength of current price movements.

Core Logic and Behavior

1. Trend Identification and Tracking The script monitors the relationship between current market prices (highs and lows) and a calculated Parabolic SAR value. The SAR value acts as a dynamic trailing stop. The logic constantly checks if the price has "broken through" the previous SAR level:

  • If the price moves above the SAR, it suggests an upward trend.
  • If the price moves below the SAR, it suggests a downward trend.

2. Dynamic Price Adjustments The script includes specific logic to ensure the indicator remains responsive to sudden market shifts. If a reversal occurs—such as the SAR moving from above the price to below it (or vice versa)—the script automatically "re-sets" the SAR value to a position just outside the current price range. This prevents the indicator from lagging behind and ensures it stays on the correct side of the market action.

3. Trend Strength Filtering One of the unique features of this script is its ability to distinguish between a "weak" trend and a "strong" trend using a minimum velocity threshold (defined by the Trend_Minimum parameter).

  • Weak Trends: If the change in the SAR value between two consecutive candles is small (less than the set minimum), the script categorizes this as a minor movement.
  • Strong Trends: If the change in the SAR value exceeds the minimum threshold, it signals a more significant, high-momentum trend.

4. Visual Output and Signals The script organizes these calculations into four distinct visual buffers on the chart, represented by different colored arrows:

  • Lower/Primary Buffers: These highlight the standard SAR values for both upward and downward movements.
  • Secondary/Trend Buffers: These specifically isolate the "Strong" trends identified by the velocity check.

By separating these values, the tool allows a user to see not just where the trend might reverse, but also how aggressively the market is moving in that direction.

Indicators Used
Parabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
Parabolic_4cNK
//Version  October 1 , 2006     
//+------------------------------------------------------------------+
//|                                                 4c_Parabolic.mq4 |
//|                               Copyright © 2006, Nikolay Kositsin | 
//|                                Khabarovsk, farria@mail.redcom.ru | 
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Nikolay Kositsin"
#property link      "farria@mail.redcom.ru"
//---- îòðèñîâêà èíäèêàòîðà â ãëàâíîì îêíå
#property indicator_chart_window 
//---- êîëè÷åñòâî èíäèêàòîðíûõ áóôôåðîâ
#property indicator_buffers 4
//---- öâåòà èíäèêàòîðà
#property indicator_color1 Lime  
#property indicator_color2 Red
#property indicator_color3 DarkGreen
#property indicator_color4 Maroon
//---- òîëùèíà èíäèêàòîðíûõ ëèíèé
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2 
#property indicator_width4 2
//---- ÂÕÎÄÍÛÅ ÏÀÐÀÌÅÒÐÛ ÈÍÄÈÊÀÒÎÐÀ þþþþþþææ+ 
extern double       Step = 0.02;
extern double    Maximum = 0.2;
extern int Trend_Minimum = 5; // ìèíèìàëüíàÿ ñêîðîñòü òðåíäà â ïóíêòàõ
//---- æææææææææææææææææææææææææææææææææææææ+
//---- èíäèêàòîðíûå áóôôåðû
double UpBuffer1[];
double DnBuffer1[];
double UpBuffer2[];
double DnBuffer2[];
double SarBuffer[];
//----+ Ââåäåíèå öåëûõ ãëîáàëüíûõ ïåðåìåííûõ 
int bar;
//---- Ââåäåíèå êîíñòàíò è ãëîáàëüíûõ ïåðåìåííûõ ñ ïëàâàþùåé òî÷êîé
double dT_min,low,low1,high,high1,SAR,ABS_trend,SAR1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() 
{  
//---- 5 èíäèêàòîðíûõ áóôôåðîâ èñïîëüçîâàíû äëÿ ñ÷¸òà 
IndicatorBuffers(5);
SetIndexBuffer(0,UpBuffer1); 
SetIndexBuffer(1,DnBuffer1); 
SetIndexBuffer(2,UpBuffer2);
SetIndexBuffer(3,DnBuffer2); 
SetIndexBuffer(4,SarBuffer);
//---- Ñòèëü èñïîëíåíèÿ ãðàôèêà â âèäå òî÷å÷íûõ îáúåêòîâ
SetIndexStyle(0,DRAW_ARROW); 
SetIndexStyle(1,DRAW_ARROW); 
SetIndexStyle(2,DRAW_ARROW); 
SetIndexStyle(3,DRAW_ARROW); 
SetIndexArrow(0,158); 
SetIndexArrow(1,158); 
SetIndexArrow(2,158); 
SetIndexArrow(3,158); 
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
SetIndexEmptyValue(3,0.0);
//---- èìÿ äëÿ îêîí äàííûõ è ëýéáà äëÿ ñóáúîêîí 
IndicatorShortName ("Parabolic( Step="+Step+", Maximum="+Maximum+")"); 
SetIndexLabel (0, "lower_Up_Trend");
SetIndexLabel (1, "lower_Down_Trend"); 
SetIndexLabel (2, "Up_Trend");
SetIndexLabel (3, "Down_Trend"); 
//---- Óñòàíîâêà ôîðìàòà òî÷íîñòè îòîáðàæåíèÿ èíäèêàòîðà
IndicatorDigits(Digits);
//---- èíèöèàëèçàöèÿ êîíñòàíòû 
dT_min=Trend_Minimum*Point;
//---- çàâåðøåíèå èíèöèàëèçàöèè
return(0); 
} 
//+------------------------------------------------------------------+
//| 4c_Parabolic                                                     |
//+------------------------------------------------------------------+
int start()
{
if(Bars-1<2) return(0);
//----+ Ââåäåíèå öåëûõ ïåðåìåííûõ è ïîëó÷åíèå óæå ïîäñ÷èòàííûõ áàðîâ
int MaxBar,limit,counted_bars=IndicatorCounted();
//---- ïðîâåðêà íà âîçìîæíûå îøèáêè
if (counted_bars<0)return(-1);
//---- ïîñëåäíèé ïîäñ÷èòàííûé áàð äîëæåí áûòü ïåðåñ÷èòàí
if (counted_bars>0) counted_bars--;
//---- îïðåäåëåíèå íîìåðà ñàìîãî ñòàðîãî áàðà, íà÷èíàÿ ñ êîòîðîãî áóäåò ïðîèçåä¸í ïåðåñ÷¸ò íîâûõ áàðîâ
MaxBar=Bars-1;
limit=MaxBar-counted_bars;
if (limit>MaxBar-1){limit=MaxBar-1; SarBuffer[MaxBar]=0; }
//----
for (bar=limit;bar>=0;bar--)
   {
     SarBuffer[bar]=iSAR(NULL,0,Step,Maximum,bar);
     //----  
     SAR=SarBuffer[bar];
     SAR1=SarBuffer[bar+1];
     //----
     low=Low[bar];
     high=High[bar];
     low1=Low[bar+1];
     high1=High[bar+1];
     //----
     Ind_SAR();
     //----
     if((SAR1>=high1)&&(SAR<high)&&(SAR>low )){SAR=low-Point ;SarBuffer[bar]=SAR;Ind_SAR();}
     if((SAR1<=low1 )&&(SAR>low )&&(SAR<high)){SAR=high+Point;SarBuffer[bar]=SAR;Ind_SAR();}
   }
//----
return(0);
}
//+--------------------------------------------------------------------+
void Ind_SAR()
  {
     //----
     UpBuffer1[bar]=0.0;
     DnBuffer1[bar]=0.0;
     UpBuffer2[bar]=0.0;
     DnBuffer2[bar]=0.0; 
     //----  
     if(((SAR>=high)&&(SAR1>=high1))||((SAR<=low)&&(SAR1<=low1)))
     ABS_trend=MathAbs(SAR-SAR1);else ABS_trend=0.0;
     //----
     if(SAR>=high)if(ABS_trend<dT_min)DnBuffer1[bar]=SAR;else DnBuffer2[bar]=SAR;                
     if(SAR<=low )if(ABS_trend<dT_min)UpBuffer1[bar]=SAR;else UpBuffer2[bar]=SAR;
  }

Comments