Author: Andrei Andreev
Igrok

This script is designed to provide traders with a visual summary of key price levels and historical volatility directly on their trading charts. Instead of overwhelming the user with complex data, it distills significant market movements into three primary horizontal indicators: Support, Resistance (Minimum), and Resistance (Maximum).

Core Functionality

The logic operates by analyzing daily price action to identify specific "pivot" points. Here is how the tool processes information:

  • Data Gathering: The script automatically pulls historical data from the Daily timeframe. It looks back over a user-defined number of days (defaulting to 10) to calculate the average price range. This helps the user understand how much the market typically moves in a standard period.
  • Dynamic Level Identification:
    • Support (S1): The script identifies the opening price of the current period.
    • Minimum Resistance (R1): It identifies the lowest price point reached during the analyzed period.
    • Maximum Resistance (R2): It identifies the highest price point reached during the analyzed period.
  • Real-Time Visual Updates: The script constantly monitors the market. As new price data arrives, it automatically moves and updates the labels and dashed lines on your chart. This ensures that the "Min," "Max," and "Open" levels stay synchronized with the most recent market activity.

User Interface Features

The tool provides a clean, professional visual experience through several key elements:

  • Visual Indicators: It draws three distinct dashed lines across the chart. These provide a "horizon" for the trader to see where significant price boundaries are currently sitting.
  • On-Chart Labels: Clear text labels appear on the right side of the chart, explicitly stating the price values for the Max, Min, and Open levels so they can be read at a glance without hovering over the lines.
  • Data Dashboard: In the corner of the chart, the script generates a live text comment that displays a quick statistical summary:
    • The current range of the period.
    • The range of the previous period.
    • The calculated average range based on the look-back period.

Summary for the Trader

Essentially, this script automates the "scouting" process. Rather than you having to manually scan through dozens of daily candles to find where the price bottomed out or peaked recently, the tool calculates these extremes automatically and plots them as clear visual boundaries, allowing you to focus on your trading strategy.

Price Data Components
Series array that contains close prices for each bar
13 Views
0 Downloads
0 Favorites
Igrok
//+------------------------------------------------------------------+
//|                                                        Igrok.mq4 |
//|                                                   Andrei Andreev |
//|                                             http://www.andand.ru |
//+------------------------------------------------------------------+

// BASED ON:
//+------------------------------------------------------------------+
//|                                                   ^X_Sensors.mq4 |
//|                                                    Version 2.0.1 |
//|------------------------------------------------------------------|
//|                     Copyright © 2007, Mr.WT, Senior Linux Hacker |
//|                                     http://w-tiger.narod.ru/wk2/ |
//+------------------------------------------------------------------+
#property copyright "Andrei Andreev"
#property link      "http://www.andand.ru"

#property indicator_chart_window
extern int ForDays=10;
extern int _Shift = 20;
extern color _R_Color = Crimson;
extern color _S_Color = Gold;


int _N_Time,  _My_Period,  ObjectId;
string OBJECT_PREFIX = "LEVELS";
//-------------------------------------------------------------------------------------------
int init() {

_My_Period=PERIOD_D1;



_N_Time = 0;

ObjectCreate("S1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);

ObjectCreate("R1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);
ObjectCreate("R2 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);



ObjectSet("S1 line", OBJPROP_RAY, 1);
ObjectSet("S1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("S1 line", OBJPROP_COLOR, _S_Color);


ObjectSet("R1 line", OBJPROP_RAY, 1);
ObjectSet("R1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R1 line", OBJPROP_COLOR, _R_Color);

ObjectSet("R2 line", OBJPROP_RAY, 1);
ObjectSet("R2 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R2 line", OBJPROP_COLOR, _R_Color);






ObjectCreate("R1 label", OBJ_TEXT, 0, Time[0], 0);
ObjectCreate("R2 label", OBJ_TEXT, 0, Time[0], 0);

ObjectCreate("S1 label", OBJ_TEXT, 0, Time[0], 0);



ObjectId = 0;
return(0);
}
//-------------------------------------------------------------------------------------------
int deinit() {


ObjectDelete("R1 label");
ObjectDelete("R1 line");
ObjectDelete("R2 label");
ObjectDelete("R2 line");

ObjectDelete("S1 label");
ObjectDelete("S1 line");


ObDeleteObjectsByPrefix(OBJECT_PREFIX);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {

if ( _N_Time == Time[0] ) return(0);

double open,close, high, low, koeff1, koeff2,P, R1, R2, S1;
double _rates[][6];
double AverageRange;

ArrayCopyRates(_rates, NULL, _My_Period);
int err = GetLastError();
if(err == 4066) {
  Sleep(1000);
  if(iClose(NULL, _My_Period, 0) != Close[0]) {
    Sleep(1000);
    return(0);
  }
}
close = _rates[1][4];
high = _rates[0][3];
low = _rates[0][2];
open = _rates[0][1];

AverageRange=0;
for (int i=1;i<ForDays+1;i++)
    {
    AverageRange=AverageRange+(_rates[i][3]-_rates[i][2])/Point;
    }
AverageRange=NormalizeDouble(AverageRange/ForDays,0); 

Comment("\nÄèàïàçîí:",
        "\nÑåãîäíÿ:  ",(high-low)/Point,
        "\nÂ÷åðà:     ",(_rates[1][3]-_rates[1][2])/Point,
        "\nÑðåäíèé:  ",AverageRange," çà ",ForDays," äíåé");       

S1 =open;
R1 =low;
R2 =high;

 

string s1,r1,r2;

  s1 = DoubleToStr(S1, Digits);

  r1 = DoubleToStr(R1, Digits);
  r2 = DoubleToStr(R2, Digits);


  

//---- Pivot Lines
ObjectSetText("R1 label", "                          Min "+r1+"", 8, "Fixedsys", _R_Color);
ObjectSetText("R2 label", "                          Max "+r2+"", 8, "Fixedsys", _R_Color);
ObjectSetText("S1 label", "                        Open "+s1+"", 8, "Fixedsys", _S_Color);



ObjectMove("R1 label", 0, Time[0], R1);
ObjectMove("R2 label", 0, Time[0], R2);


ObjectMove("S1 label", 0, Time[0], S1);


ObjectMove("S1 line", 0, Time[_Shift], S1);
ObjectMove("S1 line", 1, Time[0], S1);




ObjectMove("R1 line", 0, Time[_Shift], R1);
ObjectMove("R1 line", 1, Time[0], R1);

ObjectMove("R2 line", 0, Time[_Shift], R2);
ObjectMove("R2 line", 1, Time[0], R2);


//====
   
_N_Time = Time[0];
//---- End Of Program
return(0);
}
//+------------------------------------------------------------------+



void ObDeleteObjectsByPrefix(string Prefix)
  {
   int L = StringLen(Prefix);
   int i = 0; 
   while(i < ObjectsTotal())
     {
       string ObjName = ObjectName(i);
       if(StringSubstr(ObjName, 0, L) != Prefix) 
         { 
           i++; 
           continue;
         }
       ObjectDelete(ObjName);
     }
  }
//-------------------------------------------------------------------------------------------

Comments