i-Levels_RS

Download script
Author: ��� ����� �. aka KimIV
i-Levels_RS

This script is designed to automatically populate your trading chart with pre-defined support and resistance levels based on historical data. Instead of calculating these levels dynamically using complex formulas, the tool functions as a visual data importer that reads specific coordinates from an external file.

How it Works

1. Data Source Integration The script looks for a specific CSV file (formatted for your specific trading symbol) saved on your computer. This file acts as a database containing the exact prices and dates for various support and resistance levels. By using an external file, you can pre-determine "key zones" that have historical significance to you.

2. Automated Drawing Once the script is active, it scans the data file and automatically draws horizontal lines on your chart. It organizes these into three main categories:

  • Resistance Levels (R1, R2, R3): These represent price ceilings where selling pressure might increase.
  • Support Levels (S1, S2, S3): These represent price floors where buying interest might emerge.

3. Intelligent Filtering The logic includes a specific filter to manage visual clutter on your chart:

  • Strength Identification: Each level in the data file is assigned a "strength" value.
  • Strong-Only Mode: You have the option to toggle a setting that hides minor levels, showing only the most significant (strong) barriers. This allows you to focus on major structural turns rather than small price fluctuations.

4. Timeframe Awareness To ensure accuracy, the script is optimized for lower timeframes. It includes a built-in check to notify you if you are trying to view it on a timeframe that is too large (specifically larger than 4 hours), as the visual layout of the levels is intended for more granular analysis.

Key Visual Features

  • Dynamic Coloring: Each type of level (Resistance vs. Support) is assigned a distinct color to help you quickly identify the market structure at a glance.
  • Variable Line Weight: The thickness of the lines on your chart automatically adjusts based on the "strength" assigned to that level in your data file; stronger levels appear bolder and more prominent.
  • Clean Workspace: The script is designed to manage its own objects, ensuring that when you remove the tool from the chart, it cleans up the drawings and leaves your workspace tidy.
Miscellaneous
Uses files from the file systemIt reads information from a file
10 Views
0 Downloads
0 Favorites
i-Levels_RS
//+------------------------------------------------------------------+
//|                         i-Levels_RS.mq4 âåðñèÿ 1.1 îò 02.08.2005 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 DarkBlue
#property indicator_color2 Blue
#property indicator_color3 SkyBlue
#property indicator_color4 Orange
#property indicator_color5 Red
#property indicator_color6 Maroon
//------- input parameters
extern int  NumberOfDay = 10;     // Êîëè÷åñòâî äíåé
extern bool StrongOnly  = false;  // Ïîêàçûâàòü òîëüêî ñèëüíûå óðîâíè
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
datetime Data[];
double   R3[], PR3[];
double   R2[], PR2[];
double   R1[], PR1[];
double   S1[], PS1[];
double   S2[], PS2[];
double   S3[], PS3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init()
{
  // Óñòàíîâêà ðàçìåðíîñòè ìàññèâîâ
  ArrayResize(Data, NumberOfDay);
  ArrayResize(R3, NumberOfDay); ArrayResize(PR3, NumberOfDay);
  ArrayResize(R2, NumberOfDay); ArrayResize(PR2, NumberOfDay);
  ArrayResize(R1, NumberOfDay); ArrayResize(PR1, NumberOfDay);
  ArrayResize(S1, NumberOfDay); ArrayResize(PS1, NumberOfDay);
  ArrayResize(S2, NumberOfDay); ArrayResize(PS2, NumberOfDay);
  ArrayResize(S3, NumberOfDay); ArrayResize(PS3, NumberOfDay);

  // Çàãðóçêà óðîâíåé èç ôàéëà â ìàññèâû
  int fh = FileOpen("Levels_RS_"+Symbol()+".csv", FILE_CSV|FILE_READ, ";");
  if (fh > 0)
  {
    for (int i = 0; i < NumberOfDay; i++)
    {
      Data[i] = StrToTime(FileReadString(fh));

      R3 [i] = StrToDouble(FileReadString(fh));
      PR3[i] = StrToInteger(FileReadString(fh));
      
      R2 [i] = StrToDouble(FileReadString(fh));
      PR2[i] = StrToInteger(FileReadString(fh));
      
      R1 [i] = StrToDouble(FileReadString(fh));
      PR1[i] = StrToInteger(FileReadString(fh));
      
      S1 [i] = StrToDouble(FileReadString(fh));
      PS1[i] = StrToInteger(FileReadString(fh));
      
      S2 [i] = StrToDouble(FileReadString(fh));
      PS2[i] = StrToInteger(FileReadString(fh));
      
      S3 [i] = StrToDouble(FileReadString(fh));
      PS3[i] = StrToInteger(FileReadString(fh));
    }
    FileClose(fh);
  }
  Comment("");
}

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit()
{
  // Óäàëåíèå îáúåêòîâ
  for (int i = 0; i < NumberOfDay; i++)
  {
    ObjectDelete("R3"+i);
    ObjectDelete("R2"+i);
    ObjectDelete("R1"+i);
    ObjectDelete("S1"+i);
    ObjectDelete("S2"+i);
    ObjectDelete("S3"+i);
  }
  Comment("");
}

//+------------------------------------------------------------------+
//| Ñîçäàíèå îáúåêòîâ ËÈÍÈß è èõ îòðèñîâêà íà ãðàôèêå                |
//+------------------------------------------------------------------+
// nv - Íàèìåíîâàíèå óðîâíÿ
// nd - Íîìåð äíÿ îò 0 (òåêóùèé) è äàëüøå â ãëóáü èñòîðèè
// zl - Çíà÷åíèå óðîâíÿ
// sl - Ñèëà óðîâíÿ (0-ñëàáûé, 1-ñèëüíûé)
// cl - Öâåò ëèíèè
void DrawLine(string nv, int nd, double zl, bool sl, color cl)
{
  datetime dd1 = Data[nd];
  datetime dd2 = StrToTime(TimeToStr(dd1, TIME_DATE)+" 23:59");

  if (!StrongOnly || sl)
  {
    ObjectCreate(nv+nd, OBJ_TREND, 0, dd1, zl, dd2, zl);

    ObjectSet(nv+nd, OBJPROP_RAY  , False);
    ObjectSet(nv+nd, OBJPROP_COLOR, cl);
    ObjectSet(nv+nd, OBJPROP_STYLE, STYLE_SOLID);      
    ObjectSet(nv+nd, OBJPROP_WIDTH, (sl + 1) * 2);
  }
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start()
{
  if (Period() > 240) Comment("Èíäèêàòîð Levels_RS ÒÔ áîëüøå Í4 íå ïîääåðæèâàåò!");
  else
  {
    // Îòîáðàæåíèå óðîâíåé íà ãðàôèêå
    for (int i = 0; i < NumberOfDay; i++)
    {
      if (R3[i]>0) DrawLine("R3", i, R3[i], PR3[i], indicator_color1);
      if (R2[i]>0) DrawLine("R2", i, R2[i], PR2[i], indicator_color2);
      if (R1[i]>0) DrawLine("R1", i, R1[i], PR1[i], indicator_color3);
      if (S1[i]>0) DrawLine("S1", i, S1[i], PS1[i], indicator_color4);
      if (S2[i]>0) DrawLine("S2", i, S2[i], PS2[i], indicator_color5);
      if (S3[i]>0) DrawLine("S3", i, S3[i], PS3[i], indicator_color6);
    }
  }
}
//+------------------------------------------------------------------+

Comments