sila

This technical indicator is designed to help traders visualize market trends and identify potential entry points by calculating dynamic "Stop Loss" levels based on price volatility. By analyzing historical price movements, it provides a clear visual representation of where the market’s momentum currently sits.

Core Logic Overview

The script operates by calculating multiple moving averages simultaneously across different timeframes (controlled by the "Period Step"). Instead of looking at just one average, it samples several layers of data to identify the high and low boundaries of current price action.

How the Analysis Works

  1. Boundary Detection: The tool identifies a "ceiling" and a "floor" for the current price. It does this by comparing several moving averages to find the highest and lowest points within a specific range. These points represent the outer limits of the market's recent behavior.
  2. Trend Directional Analysis: The script constantly monitors the relationship between the actual market price (the highs and lows of the current candle) and these identified boundaries:
    • Bullish Signal: If the market price breaks above the upper boundary, the script recognizes a positive trend.
    • Bearish Signal: If the market price drops below the lower boundary, it recognizes a negative trend.
    • Neutral State: If the price is hovering between both boundaries or reacting to both simultaneously, the script considers the market direction uncertain.
  3. Visual Output: The indicator plots three distinct visual elements on your chart:
    • Upper/Lower Lines: These represent the calculated resistance and support levels based on the trend detection.
    • Median Line: A dotted line that shows the exact midpoint between the high and low boundaries, providing a "fair value" reference for the current price action.

Practical Application

The tool simplifies market reading by automatically translating complex data into specific actions. When a trend is clearly established, the script provides an on-screen text notification indicating either a BUY or SELL signal, along with a suggested "Stop Loss" price. This allows traders to see at a glance where the trend is heading and where they should place their protection if the market turns against them.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
sila
// Ñèëà òðåíäà (ñòîï ëîññ).mq4
// Èíäèêàòîð

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Silver

extern int PeriodStep=10;     // Øàã ïåðèîäà ñêîëüçÿùèõ
extern int CountBars=10000;   // Êîëè÷åñòâî îòîáðàæàåìûõ áàðîâ

double buffer0[];
double buffer1[];
double buffer2[];

void init()
   {
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,buffer0);
   SetIndexLabel(0,"Âåðõíÿÿ ãðàíèöà");
   SetIndexDrawBegin(0,0);

   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(1,buffer1);
   SetIndexLabel(1,"Íèæíÿÿ ãðàíèöà");
   SetIndexDrawBegin(1,0);

   SetIndexStyle(2,DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(2,buffer2);
   SetIndexLabel(2,"Ìåäèàíà");
   SetIndexDrawBegin(2,0);

   IndicatorShortName("Ñèëà òðåíäà (ñòîï ëîññ) ("+PeriodStep+")");
   }

void deinit()
   {
   Comment("");
   }

void start()
   {
   int dir=0;
   int step=1; if (PeriodStep>1) step=PeriodStep;
   double h, l, x1, x2, x3, x4, x5, x6;
   for (int i=CountBars-1; i>=0; i--)
      {
      x1=iMA(NULL,0,1*step,0,MODE_SMA,PRICE_CLOSE,i);
      x2=iMA(NULL,0,2*step,0,MODE_SMA,PRICE_CLOSE,i);
      x3=iMA(NULL,0,3*step,0,MODE_SMA,PRICE_CLOSE,i);
      x4=iMA(NULL,0,4*step,0,MODE_SMA,PRICE_CLOSE,i);
      x5=iMA(NULL,0,5*step,0,MODE_SMA,PRICE_CLOSE,i);
      x6=iMA(NULL,0,6*step,0,MODE_SMA,PRICE_CLOSE,i);
      h=x1;
      l=x1;
      if (h<x2) h=x2;
      if (h<x3) h=x3;
      if (h<x4) h=x4;
      if (h<x5) h=x5;
      if (h<x6) h=x6;
      if (l>x2) l=x2;
      if (l>x3) l=x3;
      if (l>x4) l=x4;
      if (l>x5) l=x5;
      if (l>x6) l=x6;
      if (High[i]>h) dir= 1;
      if (Low [i]<l) dir=-1;
      if (High[i]>h && Low[i]<l) dir=0;
      buffer0[i]=EMPTY_VALUE;
      buffer1[i]=EMPTY_VALUE;
      if (dir<0) buffer0[i]=h;
      if (dir>0) buffer1[i]=l;
      buffer2[i]=(h+l)/2;
      }
   if (buffer0[0]!=EMPTY_VALUE) Comment("SELL; ñòîï ëîññ: "+DoubleToStr(buffer0[0],Digits));
   if (buffer1[0]!=EMPTY_VALUE) Comment("BUY; ñòîï ëîññ: "+DoubleToStr(buffer1[0],Digits));
   }

Comments