00ATR_Levels_custom[1]1test

Download script
Author: Mike Ischenko
00ATR_Levels_custom[1]1test

This script is designed to provide traders with dynamic price level markers based on volatility. Instead of simply looking at the current price, it calculates significant support and resistance boundaries by analyzing daily price history and a specific volatility metric known as the Average True Range (ATR).

Core Logic and Functionality

Volatility-Based Calculations The script uses the ATR—a common tool for measuring market "noise" or movement range—to determine how far above or below a price point a potential reversal might occur. It specifically pulls data from the Daily timeframe to ensure that the levels it identifies are based on broader market trends rather than just small, momentary fluctuations.

Dynamic Support and Resistance Levels The tool calculates several key boundaries:

  • Primary Levels: It establishes high and low boundaries based on the previous day's price action combined with the daily volatility (ATR).
  • Secondary Projections: Based on these primary levels, the script creates a series of secondary "sub-levels." It calculates these by adding or subtracting specific multipliers of the ATR (such as 0.5x, 1.0x, and 1.5x) from the core high and low points.
  • Real-Time Adjustments: The logic distinguishes between the "yesterday" levels and "today’s" projected levels, allowing traders to see where price may find resistance or support in the current session.

Visual Representation on Charts To make this data actionable for a trader, the script performs several visual tasks:

  • Horizontal Lines: It draws distinct horizontal lines on the chart representing the most critical high and low resistance/support points. These are color-coded (typically Lime for resistance and Orange for support) to provide immediate visual clarity.
  • Dynamic Labeling: The script places text labels at these specific price points. These labels display the exact price value, allowing the trader to see exactly where the "alpha" (yesterday's) and "beta" (today's) levels are located.
  • Auto-Scaling: The tool automatically detects the timeframe you are currently viewing (from 1-minute charts up to daily charts) and adjusts its internal calculations so that the data remains consistent regardless of your zoom level.

Summary for the User

In essence, this script takes complex daily volatility data and "flattens" it into visible horizontal boundaries on your active chart. It tells you where the market is likely to struggle or react based on how much the price has been swinging over the last several days, helping you identify potential "walls" for entry or exit points.

Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Indicators Used
Indicator of the average true range
11 Views
0 Downloads
0 Favorites
00ATR_Levels_custom[1]1test
//+------------------------------------------------------------------+
//|                                                   ATR Levels.mq4 |
//|                                                    Mike Ischenko |
//|                                            mishanya_fx@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Mike Ischenko"
#property link      "mishanya_fx@yahoo.com"

#property indicator_chart_window

#property indicator_buffers    4
#property indicator_color1     Blue
#property indicator_color2     Red
#property indicator_color3     Blue
#property indicator_color4     Red


extern int ATRPeriod = 10;

double rates_d1[][6];
double H1, H2, H3, H4, H4t, H5, L5, L4, L4t, L3, L2, L1, halfatr, fullatr;
int timeshift=0, timeshifts=0, beginner=0;
int periods;

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer2);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer4);


   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
 
   
   ObjectDelete("H4atr line");
   ObjectDelete("L4atr line");
   ObjectDelete("L4atr label");
   ObjectDelete("H4atr label");
   ObjectDelete("H4tatr line");
   ObjectDelete("L4tatr line");
   ObjectDelete("L4tatr label");
   ObjectDelete("H4tatr label");   
   
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   //if (counted_bars<1) return(0);
   int limit,i,y;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
           limit = MathMax(limit,PERIOD_D1/Period());
   for(i=limit; i>=0; i--)   

   {
   

   switch (Period())
   {
      case PERIOD_M1:  {timeshifts=60; beginner=Hour()*60;} break;
      case PERIOD_M5:  {timeshifts=300; beginner=Hour()*12;} break;
      case PERIOD_M15: {timeshifts=900; beginner=Hour()*4;} break;
      case PERIOD_M30: {timeshifts=1800; beginner=Hour()*2;} break;
      case PERIOD_H1:  {timeshifts=3600; beginner=Hour()*1;} break;
      case PERIOD_H4:  {timeshifts=14400; beginner=Hour()*0.25;} break;
      case PERIOD_D1:  {timeshifts=86400; beginner=Hour()*0;} break;
    }   

   timeshift=timeshifts*24;
   
   if(Period() > 86400)
      {
         Print("Error - Chart period is greater than 1 day.");
         return(-1); // then exit
      }   


   
   ArrayCopyRates(rates_d1, Symbol(), PERIOD_D1);



   //beginner=Hour();
   y=iBarShift(Symbol(),PERIOD_D1,Time[i]);
            fullatr = iATR(Symbol(), 0, ATRPeriod, y);

            
            L4 = rates_d1[i+1][3] - fullatr;   
            H4 = rates_d1[i+1][2] + fullatr;
            L4t = rates_d1[i+0][3] - fullatr;   
            H4t = rates_d1[i+0][2] + fullatr;
            halfatr = fullatr * 0.5;   
         
            H1 = H4+1.5*fullatr;
            H2 = H4+fullatr;
            H3 = H4+halfatr;
            L3 = L4-halfatr;
            L2 = L4-fullatr;
            L1 = L4-1.5*fullatr;
         
   buffer1[i]  = iLow(NULL,PERIOD_D1,y+1)+ fullatr;
   buffer2[i]  = iHigh(NULL,PERIOD_D1,y+1) - fullatr;
   buffer3[i]  = iLow(NULL,PERIOD_D1,y)+ fullatr;
   buffer4[i]  = iHigh(NULL,PERIOD_D1,y) - fullatr;
   
   if (ObjectFind("H4atr Line") != 0) 
     {
      ObjectCreate("H4atr line",OBJ_HLINE,0,Time[0],H4);
      ObjectSet("H4atr line",OBJPROP_COLOR,Lime);
      ObjectSet("H4atr line",OBJPROP_WIDTH,2);
     }
     else
     {
     ObjectMove("H4atr line", 0,Time[0],H4);
     }


   if (ObjectFind("L4atr Line") != 0) 
     {
      ObjectCreate("L4atr line",OBJ_HLINE,0,Time[0],L4);
      ObjectSet("L4atr line",OBJPROP_COLOR,Orange);
      ObjectSet("L4atr line",OBJPROP_WIDTH,2);
     }
     else
     {
     ObjectMove("L4atr line", 0,Time[0],L4);
     }

   if (ObjectFind("H4tatr Line") != 0) 
     {
      ObjectCreate("H4tatr line",OBJ_HLINE,0,Time[0],H4t);
      ObjectSet("H4tatr line",OBJPROP_COLOR,Lime);
      ObjectSet("H4tatr line",OBJPROP_WIDTH,2);
     }
     else
     {
     ObjectMove("H4tatr line", 0,Time[0],H4t);
     }


   if (ObjectFind("L4tatr Line") != 0) 
     {
      ObjectCreate("L4tatr line",OBJ_HLINE,0,Time[0],L4t);
      ObjectSet("L4tatr line",OBJPROP_COLOR,Orange);
      ObjectSet("L4tatr line",OBJPROP_WIDTH,2);
     }
     else
     {
     ObjectMove("L4tatr line", 0,Time[0],L4t);
     }

if(ObjectFind("H4atr label") != 0)
      {
      ObjectCreate("H4atr label", OBJ_TEXT, 0, Time[0]+timeshift, H4);
      ObjectSetText("H4atr label", "ATR(y)H alpha res: " + DoubleToStr(H4,4), 8, "Verdana", Lime);
      }
      else
      {
      ObjectMove("H4atr label", 0, Time[0]+timeshift, H4);
      } 

if(ObjectFind("L4atr label") != 0)
      {
      ObjectCreate("L4atr label", OBJ_TEXT, 0, Time[0]+timeshift, L4);
      ObjectSetText("L4atr label", "ATR(y)L alpha sup: " + DoubleToStr(L4,4), 8, "Verdana", Orange);
      }
      else
      {
      ObjectMove("L4atr label", 0, Time[0]+timeshift, L4);
      } 

if(ObjectFind("H4tatr label") != 0)
      {
      ObjectCreate("H4tatr label", OBJ_TEXT, 0, Time[0]+timeshift, H4t);
      ObjectSetText("H4tatr label", "ATR(t)H beta res: " + DoubleToStr(H4t,4), 8, "Verdana", Lime);
      }
      else
      {
      ObjectMove("H4tatr label", 0, Time[0]+timeshift, H4t);
      } 

if(ObjectFind("L4tatr label") != 0)
      {
      ObjectCreate("L4tatr label", OBJ_TEXT, 0, Time[0]+timeshift, L4t);
      ObjectSetText("L4tatr label", "ATR(t)L beta sup: " + DoubleToStr(L4t,4), 8, "Verdana", Orange);
      }
      else
      {
      ObjectMove("L4tatr label", 0, Time[0]+timeshift, L4t);
      } 
   }
   return(0);
  }
//+------------------------------------------------------------------+

Comments