MaksiGen_KaHaJI_CkaJIneP_v1

Download script
Author: MaksiGen
MaksiGen_KaHaJI_CkaJIneP_v1

This tool is designed as a visual market indicator for the MetaTrader 4 platform, specifically built to identify key price boundaries and trading opportunities during specific time windows. Instead of providing constant signals, it focuses on "active" sessions defined by the user.

Core Functionality

1. Time-Based Filtering The script operates based on two distinct time slots that you can customize (e.g., morning and afternoon sessions). It automatically monitors the server's clock to determine when these periods begin and end. The indicator only calculates its primary logic during these active windows, allowing traders to focus on high-volatility periods while ignoring "noisy" market activity outside of those times.

2. Dynamic Range Detection At the exact moment a defined time session begins, the script performs a look-back analysis. It scans previous price data to identify the highest and lowest price points reached leading up to that moment. These two points serve as the foundational "boundaries" for the trading session.

3. Visual Price Channels Once the boundaries are established, the script projects four distinct lines on your chart:

  • The Upper Boundaries: Two lines representing the high price point (the "ceiling"). One is the actual high, and the other is set slightly below it to create a visible buffer.
  • The Lower Boundaries: Two lines representing the low price point (the "floor"). One is the actual low, and the other is set slightly above it to create a similar visual buffer.

Trading Logic & Intelligence

The script performs a real-time calculation of the "Width" of the price channel—measuring the distance between the identified high and low points.

It then applies a user-defined threshold (a "Minimum Width" setting). This serves as a quality control filter:

  • If the market movement is significant: If the distance between the high and low boundaries exceeds your specified width, the script provides an on-screen comment identifying the specific price levels to look for "Buys" (at the lower boundary) and "Sells" (at the upper boundary).
  • If the market movement is too small: If the price range is narrow and does not meet your threshold, the script will notify you that there is "not trading," signaling that the current price action lacks sufficient volatility to be considered reliable.

User Interface

The tool provides a real-time status update in the corner of your chart screen. This display shows:

  • The active time windows being monitored.
  • The calculated width of the current price channel.
  • A dynamic notification indicating whether the current market range is sufficient for trading or if it is currently too narrow to act upon.
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
MaksiGen_KaHaJI_CkaJIneP_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                     MaksiGen_KaHaJI_CkaJIneP.mq4 |
//|                                                         MaksiGen |
//|                                                          http:// |
//+------------------------------------------------------------------+
#property copyright "MaksiGen"
#property link      "http://"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Aqua
#property indicator_color2 Violet
#property indicator_color3 DarkTurquoise
#property indicator_color4 Magenta
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
extern string Time_Start_1="08.15";
extern string Time_End_1="11.30";
extern string Time_Start_2="14.00";
extern string Time_End_2="17.30";
extern int MuH_IIIuPuHa_KaHaJIa=25;
double val_1[],val_2[],val_3[],val_4[],HighKaHaJI,LowKaHaJI;
string TextHour_Start_1,TextMinute_Start_1,TextHour_End_1,TextMinute_End_1;
string TextHour_Start_2,TextMinute_Start_2,TextHour_End_2,TextMinute_End_2;
string BbIBog;
int Hour_Start_1,Minute_Start_1,Hour_End_1,Minute_End_1;
int Hour_Start_2,Minute_Start_2,Hour_End_2,Minute_End_2;
int IIIuPuHa_KaHaJIa;
bool on_off_trade;
//datetime DateTime_Start_1,DateTime_Start_2,DateTime_End_1,DateTime_End_2;

int init()
{
//---- indicators
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_LINE,1,3);
SetIndexStyle(1,DRAW_LINE,1,3);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(0,val_1);
SetIndexBuffer(1,val_2);
SetIndexBuffer(2,val_3);
SetIndexBuffer(3,val_4);
//---- Time
TextHour_Start_1=StringSubstr(Time_Start_1,0,2);Hour_Start_1=StrToInteger(TextHour_Start_1);
TextMinute_Start_1=StringSubstr(Time_Start_1,3,2);Minute_Start_1=StrToInteger(TextMinute_Start_1);

TextHour_End_1=StringSubstr(Time_End_1,0,2);Hour_End_1=StrToInteger(TextHour_End_1);
TextMinute_End_1=StringSubstr(Time_End_1,3,2);Minute_End_1=StrToInteger(TextMinute_End_1);

TextHour_Start_2=StringSubstr(Time_Start_2,0,2);Hour_Start_2=StrToInteger(TextHour_Start_2);
TextMinute_Start_2=StringSubstr(Time_Start_2,3,2);Minute_Start_2=StrToInteger(TextMinute_Start_2);

TextHour_End_2=StringSubstr(Time_End_2,0,2);Hour_End_2=StrToInteger(TextHour_End_2);
TextMinute_End_2=StringSubstr(Time_End_2,3,2);Minute_End_2=StrToInteger(TextMinute_End_2);

// Setting MSK time (Moscow time)to Alpari server's time
//Hour_Start_1=Hour_Start_1-2;Hour_End_1=Hour_End_1-2;
//Hour_Start_2=Hour_Start_2-2;Hour_End_1=Hour_End_2-2;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
int shift,i,ii;
int Counted_Bars=IndicatorCounted();

if (Period()>30)
{
if (Minute_Start_1!=0) {Minute_Start_1=0;}
if (Minute_End_1!=0) {Hour_End_1++;Minute_End_1=0;}
if (Minute_Start_2!=0) {Minute_Start_2=0;}
if (Minute_End_2!=0) {Hour_End_2++;Minute_End_2=0;}
}

//----
if (Counted_Bars>=Bars) Counted_Bars=Bars;
if(Counted_Bars<0) return(-1);//---- checking for possible errors

for (shift=Counted_Bars+10;shift>0;shift--)
  {
  on_off_trade=false;//-estimate trading time
  if (TimeHour(Time[shift])>Hour_Start_1 && TimeHour(Time[shift])<Hour_End_1) on_off_trade=true;
  if (TimeHour(Time[shift])==Hour_Start_1 && TimeMinute(Time[shift])>=Minute_Start_1) on_off_trade=true;
  if (TimeHour(Time[shift])==Hour_End_1 && TimeMinute(Time[shift])<=Minute_End_1) on_off_trade=true;

  if (TimeHour(Time[shift])>Hour_Start_2 && TimeHour(Time[shift])<Hour_End_2) on_off_trade=true;
  if (TimeHour(Time[shift])==Hour_Start_2 && TimeMinute(Time[shift])>=Minute_Start_2) on_off_trade=true;
  if (TimeHour(Time[shift])==Hour_End_2 && TimeMinute(Time[shift])<=Minute_End_2) on_off_trade=true;

  //---
  if (TimeHour(Time[shift])==Hour_Start_1 && TimeMinute(Time[shift])==Minute_Start_1)
   {
   HighKaHaJI=0;
   LowKaHaJI=10000;

   for (i=shift+MathRound((Hour_Start_1*60+Minute_Start_1)/Period());i>shift;i--)
     {
     if (High[i]>HighKaHaJI) HighKaHaJI=High[i];
     if (Low[i]<LowKaHaJI) LowKaHaJI=Low[i];
     }
   }
  //---


  if (on_off_trade)
    {
    val_1[shift]=HighKaHaJI;
    val_3[shift]=HighKaHaJI+10*Point;
    val_2[shift]=LowKaHaJI;
    val_4[shift]=LowKaHaJI-10*Point;
    }
  IIIuPuHa_KaHaJIa=(HighKaHaJI-LowKaHaJI)/Point;
}
if (IIIuPuHa_KaHaJIa>MuH_IIIuPuHa_KaHaJIa)
     {BbIBog=", Buy from "+DoubleToStr(HighKaHaJI,4)+", Sell from "+DoubleToStr(LowKaHaJI,4);}
else {BbIBog=", not trading";}
Comment("\n","\n","Working server's time: since ",TextHour_Start_1,":",TextMinute_Start_1," till ",TextHour_End_1,":",TextMinute_End_1,
" and since ",TextHour_Start_2,":",TextMinute_Start_2," äî ",TextHour_End_2,":",TextMinute_End_2,
"\n","Width of the channel: ",IIIuPuHa_KaHaJIa,BbIBog);
//----
   return(0);
}
//+------------------------------------------------------------------+

Comments