DIBS_TriggerLines1.2

Author: Copyright � 2008, ForexArea.com
DIBS_TriggerLines1.2

This script is designed to work on the 1-hour timeframe of a trading platform. It automatically identifies and visually marks specific price action patterns that traders use to determine entry points for buying or selling.

Core Logic Overview

The tool focuses on identifying "Inside Bars"—a technical setup where a candle's high and low prices are completely contained within the range of the previous candle. When these bars appear during a specific trading window, the script creates visual "trigger lines" to signal potential price movements.

Key Features and Visual Cues

  • Time-Specific Monitoring: The script does not analyze every moment of the day. It is configured to monitor a specific set number of hours starting from a user-defined opening hour. This allows traders to focus on high-activity periods (such as the London or New York sessions).

  • Automatic Boundary Marking: To provide context for price action, the script automatically draws vertical lines on your chart:

    • Day Open: Marks the exact price where the trading day began.
    • Day Close: Marks the end of the specified trading window.
    • Weekly Open: A permanent horizontal dotted line showing where the current week started.
  • Buy and Sell Triggers: The script looks for specific interactions between "Inside Bars" and the Day Open price:

    • Buy Triggers: If an Inside Bar is formed and its high price is above the Day Open, a horizontal orange-red line is drawn. This suggests a potential bullish move.
    • Sell Triggers: If an Inside Bar is formed and its low price is below the Day Open, a horizontal dark orange line is drawn. This suggests a potential bearish move.
  • Visual Enhancements & Alerts:

    • Stop Loss Visualization: Users can choose to display arrows that indicate potential stop-loss levels based on the high or low of the trigger candle.
    • Real-Time Notifications: The script includes an alert system. When a new trigger is detected in real-time, it can trigger a pop-up message on the screen and play a sound file to grab the trader's attention.
    • Backtesting Mode: There is a toggle that allows users to see these historical triggers on past data, or restrict the view to only show today's current action.

Summary for the User

Essentially, this script automates the "scanning" of the 1-hour chart. Instead of manually looking for inside bars and checking their position relative to the day's opening price, the tool draws the lines for you instantly. It highlights where price action suggests a breakout might occur, providing a cleaner, more organized visual guide for your trading strategy.

Price Data Components
Series array that contains open prices of each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
It plays sound alerts
14 Views
0 Downloads
0 Favorites
DIBS_TriggerLines1.2
//+------------------------------------------------------------------+
//|                                         DIBS_TriggerLines1.2.mq4 |
//|                                  Copyright © 2008, ForexArea.com |
//|                                         http://www.forexarea.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, ForexArea.com"
#property link      "http://www.forexarea.com"

// DIBS Indicator - for more information http://www.forexfactory.com/showthread.php?t=86766 
// or http://www.forexfactory.com/showthread.php?t=56907

#property indicator_chart_window

extern int     iOpenHour               = 5;  // open day hour 
extern int     iBarsToTrade            = 9;  // active hours to monitor (recommended 9-10)
extern int     iTriggerLineLength      = 10;  // lenght of trigger lines 
extern color   cBuyTriggerClr          = OrangeRed;
extern color   cSellTriggerClr         = DarkOrange;
extern color   cDayOpenClr             = FireBrick;
extern color   cDayCloseClr            = Black;
extern bool    bShowDayClose           = true;
extern bool    bShowStoploss           = false;
extern bool    bShowWeeklyOpen         = true;
extern int     iPriceLabelSize         = 2;
extern string  sComment1               = "---- Only set ONE alert to true!!! ----";
extern bool    bPopUpAlert             = true; // can only have one type of alert sound or popup
extern bool    bSoundAlert             = false;  // NOT both!!!
extern string  sSoundFile              = "puff.wav"; // name of sound file 
extern int     iDelayBetweenAlarm      = 60; // delay between each alarm  
extern bool    bBackTest               = false;  // set to false to only show current day 
extern int     iBarsToCount            = 200;


double dBuyTriggerLines[], dSellTriggerLines[];
bool bDrawAll;
bool bDrawLines;
int iTriggerObjects = 10000;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   //NewBar();  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   DeleteAll();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void DeleteAll(){

   ObjectDelete("DIBS_WeeklyOpen");
   
   for(int j = 0; j <= 10000; j++){
      ObjectDelete("DIBS_Trigger_B" + j);
      ObjectDelete("DIBS_Trigger_S" + j);
      ObjectDelete("DIBS_DayOpen" + j);
      ObjectDelete("DIBS_DayClose" + j);
      ObjectDelete("DIBS_Stoploss_B" + j);
      ObjectDelete("DIBS_Stoploss_S" + j);
   } 
}

int start()
  {
  
      if(Period() != PERIOD_H1){Comment("Only works on 1H timeframe!"); return(0);}
  
     if(NewBar()){DeleteAll(); bDrawLines = true; iTriggerObjects = 10000;}

     int limit;
     int counted_bars=IndicatorCounted();
     int iBarHour;
     int iExtension;
     double dDayOpenPrice;
     bool bDrawToday;
     int iUniqueID;
     int i;

     
  //---- check for possible errors
     if(counted_bars<0) return(-1);

     if(iBarsToCount == 0){
         limit=Bars;
      }else{
         limit=iBarsToCount;
      }
      
      
  //---- main loop
  
while(bDrawLines==true){

   if(bShowWeeklyOpen)DrawWeeklyOpen();

   // MUST be left at -1
   for(i=limit; i>0; i--){
      
      bDrawToday = false;
	   // only draw objects for today
      if(bBackTest == false && TimeDay(Time[i]) == TimeDay(TimeCurrent()) && TimeMonth(Time[i]) == TimeMonth(TimeCurrent())){
            bDrawToday = true;
         }else{
           bDrawToday = false;
         }
	     
     if(bBackTest == true){
            bDrawToday = true;
        }
        
     if(bDrawToday){
		   // only trade set hours
		   iBarHour = TimeHour(Time[i]);
		   if( iBarHour+1 >= iOpenHour && iBarHour+1 <= iOpenHour + iBarsToTrade ){
			   // get day open price
			   
			   if(iBarHour+1 == iOpenHour){
			      dDayOpenPrice = iOpen(NULL, 0, i);
			      // draw vertical bar to show open of day 
			      ObjectCreate("DIBS_DayOpen" + i, OBJ_VLINE, 0, Time[i-1], 0);
			      ObjectSet("DIBS_DayOpen" + i, OBJPROP_COLOR, cDayOpenClr);
			      //ObjectSet("DIBS_DayOpen" + i, OBJPROP_STYLE, STYLE_DOT);
			   }
			   
			   if(iBarHour+1 == iOpenHour + iBarsToTrade && bShowDayClose){
			      // draw vertical bar to show close of day 
			      ObjectCreate("DIBS_DayClose" + i, OBJ_VLINE, 0, Time[i-1], 0);
			      ObjectSet("DIBS_DayClose" + i, OBJPROP_COLOR, cDayCloseClr);
			      //ObjectSet("DIBS_DayClose" + i, OBJPROP_STYLE, STYLE_DOT);
			   }
			   
			   // see if we have an inside bar 
			   if(iHigh(NULL, 0, i) <= iHigh(NULL, 0, i+1) && iLow(NULL, 0,i) >= iLow(NULL, 0, i+1)){
			      // IB found so draw triggers
			      if(iHigh(NULL, 0, i) > dDayOpenPrice){
                  // draw buy trigger object 
                  iTriggerObjects--;
                  if(i<iBarsToTrade){
                        iExtension = i;
                        //iUniqueID = 25000;
                        iUniqueID = iTriggerObjects;
                    }else{
                        iExtension = iTriggerLineLength-1;
                        iUniqueID = iTriggerObjects;
                     }
                  if(bSoundAlert && i == 1)Alerts(1);
                  if(bPopUpAlert && i == 1)Alert("DIBS " + Symbol() + " - Buy Trigger");
                     if(ObjectFind("DIBS_Trigger_B" + iUniqueID) != 0){
                           ObjectCreate("DIBS_Trigger_B" + iUniqueID, OBJ_TREND, 0, Time[i], iHigh(NULL, 0, i) , Time[i-iExtension], iHigh(NULL, 0, i));
                           ObjectSet("DIBS_Trigger_B" + iUniqueID, OBJPROP_RAY, false);
                           ObjectSet("DIBS_Trigger_B" + iUniqueID, OBJPROP_WIDTH, 5);
                           ObjectSet("DIBS_Trigger_B" + iUniqueID, OBJPROP_COLOR, cBuyTriggerClr);
                        }else{
                           ObjectMove("DIBS_Trigger_B" + iUniqueID, 2, Time[i], iHigh(NULL, 0, i));  
                        }

                     if(bShowStoploss){
                        ObjectCreate("DIBS_Stoploss_B" + iUniqueID, OBJ_ARROW, 0, Time[i], iLow(NULL, 0, i));
                        ObjectSet("DIBS_Stoploss_B" + iUniqueID, OBJPROP_ARROWCODE, 5);
                        ObjectSet("DIBS_Stoploss_B" + iUniqueID, OBJPROP_COLOR, cBuyTriggerClr);
                        ObjectSet("DIBS_Stoploss_B" + iUniqueID, OBJPROP_WIDTH, iPriceLabelSize);
                    }
                    
               }
               if(iLow(NULL, 0, i) < dDayOpenPrice){
                  // draw sell trigger object 
                  iTriggerObjects--;
                  if(i<iBarsToTrade){
                        iExtension = i;
                        //iUniqueID = 25000;
                        iUniqueID = iTriggerObjects;
                    }else{
                        iExtension = iTriggerLineLength-1;
                        iUniqueID = iTriggerObjects;
                     }
                  if(bSoundAlert && i == 1)Alerts(1);
                  if(bPopUpAlert && i == 1)Alert("DIBS " + Symbol() + " - Sell Trigger");
                  if(ObjectFind("DIBS_Trigger_S" + iUniqueID) != 0){
                        ObjectCreate("DIBS_Trigger_S" + iUniqueID, OBJ_TREND, 0, Time[i], iLow(NULL, 0, i) , Time[i-iExtension], iLow(NULL, 0, i));
                        ObjectSet("DIBS_Trigger_S" + iUniqueID, OBJPROP_RAY, false);
                        ObjectSet("DIBS_Trigger_S" + iUniqueID, OBJPROP_WIDTH, 5);
                        ObjectSet("DIBS_Trigger_S" + iUniqueID, OBJPROP_COLOR, cSellTriggerClr);
                     }else{
                        ObjectMove("DIBS_Trigger_S" + iUniqueID, 2, Time[i], iLow(NULL, 0, i)); 
                     }
                  if(bShowStoploss){
                     ObjectCreate("DIBS_Stoploss_S" + iUniqueID, OBJ_ARROW, 0, Time[i], iHigh(NULL, 0, i));
                     ObjectSet("DIBS_Stoploss_S" + iUniqueID, OBJPROP_ARROWCODE, 5);
                     ObjectSet("DIBS_Stoploss_S" + iUniqueID, OBJPROP_WIDTH, iPriceLabelSize);
                     ObjectSet("DIBS_Stoploss_S" + iUniqueID, OBJPROP_COLOR, cSellTriggerClr);
                 }
               
		        } 
			   }// if 3
		    }// if 2
	   }// if 1    
   }// for
  bDrawLines = false;
}
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

void DrawWeeklyOpen(){

   double WkOpen = iOpen(NULL, PERIOD_W1, 0);
   
   ObjectCreate("DIBS_WeeklyOpen", OBJ_HLINE, 0, 0, WkOpen);
   ObjectSet("DIBS_WeeklyOpen" , OBJPROP_COLOR, DarkGreen);
   ObjectSet("DIBS_WeeklyOpen" , OBJPROP_WIDTH, 5);
   ObjectSet("DIBS_WeeklyOpen" , OBJPROP_STYLE, STYLE_DOT);
			      
}

bool NewBar() {

	static datetime LastTime = 0;
   
	if (Time[0] != LastTime) {
		LastTime = Time[0];
		bDrawLines = true;		
		return (true);
	} else
		return (false);
}

void Alerts(int Direction)
{
   static datetime AlertLastTime = 0;

   if(TimeCurrent() > AlertLastTime ) {
      AlertLastTime = TimeCurrent()+iDelayBetweenAlarm;
      PlaySound(sSoundFile);
   
   }
}

Comments