JJN-ActiveHours

Download script
Author: Copyright � 2010, JJ Newark
JJN-ActiveHours

Overview

The JJN-ActiveHours tool is a visual aid designed for traders to clearly identify specific time windows of high market activity directly on their trading charts. By automatically highlighting the hours you define as most significant, it helps you stay focused on relevant price action and ignore periods of low liquidity or inactivity.

Core Functionality

The script scans your historical price data and draws horizontal markers across the chart to visually "bracket" your preferred trading session. Instead of you having to manually identify when a specific day's trading window begins or ends, the tool automates this process based on your personalized settings.

How it Works

  • Time Window Customization: You can define exactly when your "Active Hours" start and stop (for example, a morning session or an evening peak).
  • Smart Logic for Overnight Sessions: The logic is designed to be flexible. It intelligently handles standard daytime sessions (where the start hour is earlier than the end hour) as well as "overnight" sessions that cross over midnight (where the start hour is numerically higher than the end hour).
  • Visual Mapping: Once your hours are set, the script looks back through a specific number of price bars on your chart. For every bar that falls within your designated active window, it places a visual line in the background.
  • Customizable Appearance: To ensure the information doesn't clutter your view, the lines are placed in the background of the chart. You can also customize the thickness and color of these markers to suit your personal chart aesthetics.

Key Benefits for Traders

  • Improved Focus: Quickly identify "Go" zones where volatility is expected.
  • Clutter Reduction: By visually separating active hours from inactive ones, it is easier to spot relevant price movements at a glance.
  • Automation: Eliminates the need to constantly check your clock or manually draw lines on every new candle during a trading session.
12 Views
0 Downloads
0 Favorites
JJN-ActiveHours
//+------------------------------------------------------------------+
//|                                              JJN-ActiveHours.mq4 |
//|                                      Copyright © 2010, JJ Newark |
//|                                           http://jjnewark.atw.hu |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, JJ Newark"
#property link      "http://jjnewark.atw.hu"

//---- indicator settings
#property  indicator_chart_window


//---- indicator parameters


extern string   __Copyright__               = "http://jjnewark.atw.hu";
extern string   _IndicatorSetup_            = ">>> Indicator Setup:<<<";
extern int      Start_Hour                  = 9;
extern int      Stop_Hour                   = 21;
extern int      BarsToProcess               = 500;
extern string   _DisplaySetup_              = ">>> Display Setup:<<<";
extern int      LineWidth                   = 1;
extern color    LineColor                   = Lavender;



int init()
  {
   Comment(">> JJN-ActiveHours || http://jjnewark.atw.hu");

//----
   return(0);
  }

int deinit()
  {
//----
   for(int w=0; w<BarsToProcess; w++)
     {
     ObjectDelete("_HourLines"+w);
     }
   Comment("");
   
//----
   return(0);
  }

//

int start()
  {
   
//---- 

   for(int w=0; w<BarsToProcess; w++)
     {
     ObjectDelete("_HourLines"+w);
     }
   Comment("");
      
   for(w=0; w<BarsToProcess; w++)
     {
     if(Start_Hour<Stop_Hour)
     {
     if(TimeHour(Time[w])>=Start_Hour && TimeHour(Time[w])<Stop_Hour)
     {
     ObjectCreate("_HourLines"+w,OBJ_TREND,0,Time[w],0.0001,Time[w],0.001);
     ObjectSet("_HourLines"+w,OBJPROP_RAY,TRUE);
     ObjectSet("_HourLines"+w,OBJPROP_BACK,TRUE); // obj in the background
     ObjectSet("_HourLines"+w,OBJPROP_STYLE,STYLE_SOLID);
     ObjectSet("_HourLines"+w,OBJPROP_WIDTH,LineWidth);
     ObjectSet("_HourLines"+w,OBJPROP_COLOR,LineColor);
     }
     }
     else if(Start_Hour>Stop_Hour)
     {
     if(TimeHour(Time[w])>=Start_Hour || TimeHour(Time[w])<Stop_Hour)
     {
     ObjectCreate("_HourLines"+w,OBJ_TREND,0,Time[w],0.0001,Time[w],0.001);
     ObjectSet("_HourLines"+w,OBJPROP_RAY,TRUE);
     ObjectSet("_HourLines"+w,OBJPROP_BACK,TRUE); // obj in the background
     ObjectSet("_HourLines"+w,OBJPROP_STYLE,STYLE_SOLID);
     ObjectSet("_HourLines"+w,OBJPROP_WIDTH,LineWidth);
     ObjectSet("_HourLines"+w,OBJPROP_COLOR,LineColor);
     }
     }
     }
     
     
   
    
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments