arrows&curves lucas1

Download script
Author: Lukas1+Silver+CrazyChart
arrows&curves lucas1

This script is a technical analysis tool designed to identify market trends and provide visual signals for potential trading opportunities. It operates by analyzing price volatility and establishing dynamic boundaries to determine when the market is shifting from one direction to another.

Core Analytical Logic

The script functions through three primary layers of calculation:

1. Dynamic Channel Mapping The tool identifies significant high and low points over a specific period to create a "Sky Channel." This channel acts as a visual representation of the price range. By calculating the difference between the highest highs and lowest lows, it draws upper and lower boundaries. These lines help traders see the immediate "corridor" in which the price is currently moving.

2. Volatility and Risk Assessment To ensure the signals are not triggered by minor market noise, the script calculates the average range of price movements (the distance between highs and lows) over a set number of bars. It then applies a "Risk" factor to these ranges. This allows the tool to adjust its sensitivity; essentially, it determines how much "breathing room" is required before a trend change is considered significant.

3. Trend Detection and Signal Generation The core logic relies on tracking whether the current price has broken out of its established range:

  • Bullish Sentiment: If the closing price moves significantly above the calculated upper boundary, the script identifies an "uptrend." When this transition happens, it places a visual Buy Arrow on the chart.
  • Bearish Sentiment: If the closing price drops significantly below the calculated lower boundary, the script identifies a "downtrend." When this transition occurs, it places a visual Sell Arrow on the chart.

Summary of Visual Outputs

  • Sky Channels: Lines that show the current high and low boundaries based on recent price action.
  • Buy/Sell Arrows: Instant visual markers that appear when the price breaks out of the range in a way that confirms a new trend direction.
  • Global Tracking: The script also records these signals internally as global variables, which can be used by other automated trading systems to execute trades based on these specific signals.
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
arrows&curves lucas1
//+------------------------------------------------------------------+
//|                                       lukas1 arrows & curves.mq4 |
//|            Èäåÿ from Silver, Ramdass  åùå è Lukas1 ðóêó ïðèëîæèë |
//|                                                       ..... v3e  |
//|          Ãëîáàëüûå ïåðåìåííûå åñòü. ïî íèì òîðãóåò ñîâåòíèê Rosa |
//+------------------------------------------------------------------+
#property copyright "Lukas1+Silver+CrazyChart"
#property link      "http://viac.ru/"
//----
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 RoyalBlue
#property indicator_color2 OrangeRed
#property indicator_color3 Green
#property indicator_color4 Green
//---- input parameters
extern int SSP       = 19;    //ïåðèîä ëèíåéíîãî ðàçâîðîòà èíäèêàòîðà
extern int RISK      = 3;
extern int CountBars = 18250; //ðàñ÷åòíûé ïåðèîä - äëÿ 30 ìèí áîëüøå ãîäà
extern double SkyCh = 23.6;
//----
int Shift = 0;
int TSP = 9;
int PrevAlertTime;
double smin, smax;
//---- buffers
double val1[];      // áóôåð äëÿ áàé
double val2[];      // áóôåð äëÿ ñåëë
double Sky_BufferH[];
double Sky_BufferL[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0, 233);        // arrowbuy
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1, 234);        // arrowsell
   SetIndexBuffer(0, val1);      // èíäåêñ áóôåðà äëÿ buy
   SetIndexBuffer(1, val2);      // èíäåêñ áóôåðà äëÿ sell
//----
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, Sky_BufferH);
   SetIndexShift(2, Shift);
   SetIndexLabel(2, "Sky-channel High");
//----
   SetIndexStyle(3, DRAW_LINE);
   SetIndexBuffer(3, Sky_BufferL);
   SetIndexShift(3, Shift);
   SetIndexLabel(3, "Sky-channel Low");
//----
   if(CountBars >= Bars) 
       CountBars=Bars;     // CountBars ðàâíî êîëè÷åñòâó áàðîâ íà ãðàôèêå
// äëÿ êðèâîé "0"- ñàìî ðèñîâàíèå; íå ðàñ÷èòûâàòü ïåðâûå SSP áàðîâ (ñíà÷àëà SSP=9)
   SetIndexDrawBegin(0, Bars - CountBars + SSP);
// äëÿ êðèâîé "1"- ñàìî ðèñîâàíèå; íå ðàñ÷èòûâàòü ïåðâûå SSP áàðîâ (ñíà÷àëà SSP=9)
   SetIndexDrawBegin(1, Bars - CountBars + SSP);
   SetIndexDrawBegin(2, SSP + Shift - 1);
   SetIndexDrawBegin(3, SSP + Shift - 1);      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| SilverTrend_Signal                                               |
//+------------------------------------------------------------------+
int start()
  {   
   int    i;
   int    shift;                             // ðàñ÷åòíîå ñìåùåíèå
   int    counted_bars = IndicatorCounted(); // òåêóùèé áàð äëÿ ðàñ÷åòà èíäèêàòîðà
   int    i1;
   int    i2;
   int    K, k;
   double Range, AvgRange, SsMax, SsMin, price;
   bool   uptrend, old;
   double high, low;
//----
   if(Bars <= SSP + 1) 
       return(0);
//---- initial zero
   if(counted_bars < SSP + 1) 
     {
       for(i = 1; i <= SSP; i++) 
           val1[CountBars-i] = 0.0;   // îáíóëèëè ìàññèâ val1
       //----
       for(i = 1; i <= SSP; i++) 
           val2[CountBars-i]=0.0;     // îáíóëèëè ìàññèâ val2
       //----
       for(i = 1; i <= SSP; i++) 
         {
           Sky_BufferH[Bars-i] = 0; 
           Sky_BufferL[Bars-i] = 0;
         }                 
     }
   GlobalVariableSet("xSELL", 0); // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè xSELL=0
   GlobalVariableSet("xBUY", 0);  // çàäàëè ñóùåñòâîâàíèå è îáíóëèëè xBUY =0
// ñòàíäàðòíûå âû÷èñëåíèÿ äî 0-ãî áàðà
   i = Bars - SSP;
//----
   if(counted_bars > SSP) 
       i = Bars - counted_bars - 1;
//----
   while(i >= 0)
     {
       high = High[i]; 
       low = Low[i]; 
       k = i - 1 + SSP;
       //----
       while(k >= i)
         {
           price = High[k];
           //----
           if(high < price) 
               high = price;
           price = Low[k];
           //----
           if(low > price)  
               low = price;
           k--;
         } // âñå ïîñ÷èòàëè - çàïèñûâàåì çíà÷åíèÿ òî÷êè â ìàññèâ èíäèêàòîðà
       Sky_BufferL[i+Shift] = low + (high - low)*SkyCh / 100;
       Sky_BufferH[i+Shift] = high - (high - low)*SkyCh / 100;
       i--;       // äâèãàåì ñ÷åò÷èê
     } 
   i = Shift - 1; // Ñ÷èòàåì òî÷êè ñäâèãà - ñïðàâà îò íóëåâîãî i=Shift-1;
//----
   while(i >= 0)
     {
       high = High[0]; 
       low = Low[0]; 
       k = SSP - Shift - 1 + i; // êàæäûé ñëåäóþùèé óìåíüøàåò ïåðèîä k=SSP-Shift+i;
       //----
       while(k >= 0)
         {
           price = High[k];
           //----
           if(high < price) 
               high = price;
           price = Low[k];
           //----
           if(low > price)  
               low = price;
           k--;
         } // çàïèñûâàåì çíà÷åíèÿ â ìàññèâ
       Sky_BufferL[i] = low + (high - low)*SkyCh / 100;
       Sky_BufferH[i] = high - (high - low)*SkyCh / 100;
       i--;
     }
   K = 33 - RISK; 
//----
   for(shift = CountBars - SSP; shift >= 0; shift--) // óìåíüø çíà÷åíèå shift íà 1 çà ïðîõîä;
     { 
	      Range = 0;
	      AvgRange = 0;
	      //----
       for(i1 = shift; i1 <= shift + SSP; i1++) // óâåëè÷ "i1" îò shift äî (shift+SSP)
		         // ñðåäíèå êîëåáàíèÿ òåêóùèõ öåí
		         AvgRange = AvgRange + MathAbs(High[i1] - Low[i1]);   
	      Range = AvgRange / (SSP + 1); // äèàïàçîí êîëåáàíèÿ òåêóùèõ öåí
       SsMax = High[shift];          // çàäàòü SsMax
       SsMin = Low[shift];           // çàäàòü SsMin
       //----
       for(i2 = shift; i2 <= shift + SSP - 1; i2++) // óâåëè÷ "i2" îò shift äî (shift+SSP)
         {
           price = High[i2];  // çàäàòü price
           //----
           if(SsMax < price) 
               SsMax = price; // ïîäòÿíóëè SsMax äî óðîâíÿ High[i2]
           price = Low[i2];
           //----
           if(SsMin >= price)  
               SsMin = price; // ïîíèçèëè SsMin äî óðîâíÿ Low[i2]
         }
       smin = SsMin + (SsMax - SsMin)*K / 100; // smin âûøå SsMin ñ ó÷åòîì êîýôô.ðèñêà
       smax = SsMax - (SsMax - SsMin)*K / 100; // smax íèæå SsMax ñ ó÷åòîì êîýôô.ðèñêà
	      val1[shift] = 0;  // áóôåð äëÿ áàé
	      val2[shift] = 0;  // áóôåð äëÿ ñåëë
	      //----
       if(Close[shift] < smin)
		         uptrend = false;
	      //----
       if(Close[shift] > smax)
		         uptrend = true;
       //----
       if(uptrend != old && uptrend == true)
         {
           val1[shift] = Low[shift] - Range*0.5; // åñëè óñëîâèÿ âûïîëíåíû òî âû÷èñëÿåì val1
           //----
           if(shift == 0) 
               GlobalVariableSet("xBUY",1);
         }
       //----
       if(uptrend != old && uptrend == false) 
         {
           val2[shift] = High[shift] + Range*0.5; // åñëè óñëîâèÿ âûïîëíåíû òî âû÷èñëÿåì val2
           //----
           if(shift == 0) 
               GlobalVariableSet("xSELL",1);
         }
       old=uptrend;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments