arrows_&_curves_v14

Download script
Author: Copyright � 2007, lukas1
arrows_&_curves_v14

This custom technical indicator is designed to identify and visualize trend reversals on a price chart by analyzing historical price fluctuations. It operates by calculating dynamic boundaries—essentially "ceiling" and "floor" levels—based on the highest highs and lowest lows of a specific period.

Core Logic and Mechanism

Dynamic Range Calculation The tool looks back at a defined number of candles to identify the peak price (high) and the valley price (low). Using these two points, it calculates a range. It then creates two proportional boundaries:

  • A High Boundary: Located slightly below the peak.
  • A Low Boundary: Located slightly above the valley.

The distance between these boundaries is determined by a sensitivity setting. This allows the tool to react to price movements within a specific "buffer zone," ensuring that minor price fluctuations do not trigger false signals while still remaining responsive to significant shifts.

Trend Identification The indicator monitors whether the closing price of a candle breaks through either of these boundaries:

  • Uptrend Confirmation: If the price closes above the upper boundary, the system recognizes a shift toward an upward trend.
  • Downtrend Confirmation: If the price closes below the lower boundary, the system recognizes a shift toward a downward trend.

Visual Signals and Performance When the logic detects a change in the trend status (e.g., switching from an uptrend to a downtrend), the script generates visual markers:

  • Arrows: These appear on the chart to signal the exact moment a trend reversal has been confirmed based on the boundary breach.
  • Continuous Lines: The indicator also plots continuous "High" and "Low" lines, which help traders visualize the current volatility zone and see how closely the price is hugging the boundaries.

Efficiency and Design

The script is optimized for speed by performing all mathematical calculations within a single processing cycle. Furthermore, it includes specific safeguards to ensure that signals are only generated on completed historical data (excluding the currently forming "live" candle) to prevent "repainting," where signals might appear and then disappear before the market closes.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
arrows_&_curves_v14
//+------------------------------------------------------------------+
//|                      lukas1 arrows & curves.mq4       v.14       |
//|       Èçìåíåíèÿ:
//|       1. Óáðàíû íåíóæíûå (ëèøíèå) êîýôôèöèåíû, íå ó÷àñòâóþùèå
//|          â ðàñ÷åòàõ Kmin, Kmax, RISK
//|       2. Ìàòåìàòèêà èíäèêàòîðà âñå ðàñ÷åòû âûïîëíÿåò 
//|          âíóòðè îäíîãî öèêëà, ýòî óâåëè÷èëî ñêîðîñòü îáñ÷¸òà.
//|       3. Âûêëþ÷åíî ìåðöàíèå ñòðåëîê.
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, lukas1"
#property link      "http://www.alpari-idc.ru/"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Green
//---- input parameters
extern int SSP       = 6;     //ïåðèîä ëèíåéíîãî ðàçâîðîòà èíäèêàòîðà
extern int CountBars = 2250;  //ðàñ÷åòíûé ïåðèîä 
extern int SkyCh     = 13;    //÷óâñòâèòåëüíîñòü ê ïðîáîþ êàíàëà 
//Äîëæíà áûòü â äèàïàçîíå 0-50. 0 - íåò ñòðåëîê. Áîëüøå 50 - ïåðåðåãóëèðîâàíèå
int    i;
double high, low, smin, smax;
double val1[];      // áóôåð äëÿ áàé
double val2[];      // áóôåð äëÿ ñåëë
double Sky_BufferH[];
double Sky_BufferL[];
bool   uptrend, old;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 233);        // ñòðåëêà äëÿ áàé
   SetIndexBuffer(0, val1);      // èíäåêñ áóôåðà äëÿ áàé
   SetIndexDrawBegin(0, 2*SSP);

   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 234);        // ñòðåëêà äëÿ ñåëë
   SetIndexBuffer(1, val2);      // èíäåêñ áóôåðà äëÿ ñåëë
   SetIndexDrawBegin(1, 2*SSP);

   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, Sky_BufferH);
   SetIndexLabel(2, "High");
   SetIndexDrawBegin(2, 2*SSP);

   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, Sky_BufferL);
   SetIndexLabel(3, "Low");
   SetIndexDrawBegin(3, 2*SSP);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Calculation of SilverTrend lines
//+------------------------------------------------------------------+
int start()
  {   
   int counted_bars = IndicatorCounted();
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
   if(counted_bars > 0) counted_bars--;
//----
   if(Bars <= SSP + 1)        return(0);
//---- initial zero
   uptrend       =false;
   old           =false;
   GlobalVariableSet("goSELL", 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goSELL=0
   GlobalVariableSet("goBUY", 0);  // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè goBUY =0
//----
   for(i = CountBars - SSP; i >= 0; i--) // óìåíüø çíà÷åíèå shift íà 1 çà ïðîõîä;
     { 
       high = High[iHighest(Symbol(),0,MODE_HIGH,SSP,i)]; 
       low = Low[iLowest(Symbol(),0,MODE_LOW,SSP,i)]; 
       smax = high - (high - low)*SkyCh / 100; // smax íèæå high ñ ó÷åòîì êîýôô.SkyCh
       smin = low + (high - low)*SkyCh / 100;  // smin âûøå low ñ ó÷åòîì êîýôô.SkyCh
	    val1[i] = 0;  
       val2[i] = 0;
       if(Close[i] < smin && i!=0 )	// âûêëþ÷åíî ìåðöàíèå ñòðåëîê (i!=0)
       {
       uptrend = false;
       }
	    if(Close[i] > smax && i!=0 )	// âûêëþ÷åíî ìåðöàíèå ñòðåëîê (i!=0)	
	    {
	    uptrend = true;       
       }       
       if(uptrend != old && uptrend == false)
         {
           val2[i] = high; // åñëè óñëîâèÿ âûïîëíåíû òî ðèñóåì val1
           if(i == 0)                GlobalVariableSet("goBUY",1);
         }
       if(uptrend != old && uptrend == true ) 
         {
           val1[i] = low; // åñëè óñëîâèÿ âûïîëíåíû òî ðèñóåì val2
           if(i == 0)                GlobalVariableSet("goSELL",1);
         }
       old=uptrend;
       Sky_BufferH[i]=high - (high - low)*SkyCh / 100;
       Sky_BufferL[i]=low +  (high - low)*SkyCh / 100;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments