Sniper_Tools_v2.2

Author: Colin Reeve
Sniper_Tools_v2.2

This tool is designed to assist traders by identifying specific momentum shifts across multiple timeframes simultaneously. Instead of looking at a single chart in isolation, the script analyzes the relationship between the current timeframe you are viewing and several higher-level timeframes to ensure that market signals are aligned before providing an alert.

Core Logic Overview

The primary objective of this script is "Multi-Timeframe Alignment." It looks for a specific state where price momentum (measured via the Moving Average Convergence Divergence, or MACD) is moving in a consistent direction across various horizons—from short-term fluctuations to long-term trends.

How it Works

  1. Timeframe Scanning: The script automatically identifies which timeframe you are currently viewing (e.g., 1-minute, 5-minute, 15-minute, etc.). It then looks "upward" at three additional higher timeframes simultaneously.
  2. Momentum Synchronization: It calculates the MACD values for both your current chart and the three higher timeframes. It is specifically looking for a consensus:
    • Bearish Alignment: It checks if the momentum on your current chart AND all three higher timeframes are currently negative (below zero). If they align, it identifies a potential downward signal.
    • Bullish Alignment: It looks for a specific "breakout" condition where the momentum on your current chart and two of the higher timeframes are positive (above zero), while the highest long-term trends remain negative. This is designed to catch a shift in sentiment where short-term price action begins to overpower the larger, slower trend.
  3. Visual Feedback: When these specific mathematical conditions are met across all checked timeframes, the script places a gold arrow on your chart. This serves as a visual "Sniper" signal, indicating that the market momentum is synchronized enough to act upon.

Key Features for the User

  • Automatic Synchronization: The script handles the complex math of "shifting" the time between different charts (e.g., finding exactly what the 4-hour chart was doing at the exact second you are looking at a 1-minute chart).
  • Trend Filtering: By requiring higher timeframe confirmation, it helps filter out "noise"—those small, erratic price movements that often lead to false signals on lower timeframes.
  • Customizable Periods: The logic allows for specific settings for the MACD calculations across every timeframe, ensuring the sensitivity of the signals can be tailored to different trading styles.
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Sniper_Tools_v2.2
//+------------------------------------------------------------------+
//|                                                 Sniper Tools.mq4 |
//|                                                      Colin Reeve |
//|                                             midworld08@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Colin Reeve"
#property link      "midworld08@gmail.com"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Gold
#property indicator_style1 DRAW_ARROW

//---- External inputs from user
extern int  Higher_TF1 = 60,
            Higher_TF2 = 240,
            Higher_TF3 = 1440,
            MACD_M1_FastMAPeriod=12,
            MACD_M1_SlowMAPeriod=26,
            MACD_M1_SignalMAPeriod=5,
            MACD_M5_FastMAPeriod=12,
            MACD_M5_SlowMAPeriod=26,
            MACD_M5_SignalMAPeriod=5,
            MACD_M15_FastMAPeriod=12,
            MACD_M15_SlowMAPeriod=26,
            MACD_M15_SignalMAPeriod=5,
            MACD_M30_FastMAPeriod=12,
            MACD_M30_SlowMAPeriod=26,
            MACD_M30_SignalMAPeriod=5,
            MACD_H1_FastMAPeriod=12,
            MACD_H1_SlowMAPeriod=26,
            MACD_H1_SignalMAPeriod=5,
            MACD_H4_FastMAPeriod=12,
            MACD_H4_SlowMAPeriod=26,
            MACD_H4_SignalMAPeriod=5,
            MACD_D_FastMAPeriod=12,
            MACD_D_SlowMAPeriod=26,
            MACD_D_SignalMAPeriod=5;
extern color Signal_Color=Gold;
            
int MACD_Var[7,3];          
int period[]={1,5,15,30,60,240,1440,10080,43200};  //array used to pass variables repeatedly to indicators
string periodString[]={"M1","M5","M15","M30","H1","H4","D1","W1","MN1"}; //arrays used to show time value above arrows

double Activator_Buffer[];
int ExtCountedBars=0;
bool First_Signal=false;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//set up the MACD Variables array 
   MACD_Var[0,0] = MACD_M1_FastMAPeriod;
   MACD_Var[0,1] = MACD_M1_SlowMAPeriod;
   MACD_Var[0,2] = MACD_M1_SignalMAPeriod;
   MACD_Var[1,0] = MACD_M5_FastMAPeriod;
   MACD_Var[1,1] = MACD_M5_SlowMAPeriod;
   MACD_Var[1,2] = MACD_M5_SignalMAPeriod;
   MACD_Var[2,0] = MACD_M15_FastMAPeriod;
   MACD_Var[2,1] = MACD_M15_SlowMAPeriod;
   MACD_Var[2,2] = MACD_M15_SignalMAPeriod;
   MACD_Var[3,0] = MACD_M30_FastMAPeriod;
   MACD_Var[3,1] = MACD_M30_SlowMAPeriod;
   MACD_Var[3,2] = MACD_M30_SignalMAPeriod;
   MACD_Var[4,0] = MACD_H1_FastMAPeriod;
   MACD_Var[4,1] = MACD_H1_SlowMAPeriod;
   MACD_Var[4,2] = MACD_H1_SignalMAPeriod;
   MACD_Var[5,0] = MACD_H4_FastMAPeriod;
   MACD_Var[5,1] = MACD_H4_SlowMAPeriod;
   MACD_Var[5,2] = MACD_H4_SignalMAPeriod;
   MACD_Var[6,0] = MACD_D_FastMAPeriod;
   MACD_Var[6,1] = MACD_D_SlowMAPeriod;
   MACD_Var[6,2] = MACD_D_SignalMAPeriod;
   
 //set up the activator symbol to show the sniper active Symbol
   SetIndexStyle(0,DRAW_ARROW,EMPTY,EMPTY,Signal_Color);
   SetIndexArrow(0,181);
   SetIndexBuffer(0,Activator_Buffer);
   SetIndexEmptyValue(0,0.0);

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 //time to figure out which bars of the currently shown graph have the MACD travelling in the same direction
   double MACD_Histo[4];
   int   i=0,Chart_Pos[4],Base_Chart_Period;
   datetime Bar_Time;
   if (Period()>30) return(0);
   while (Period()!=period[i])   //loop until next higher time period is found
   {  
      i++;
   }
   Base_Chart_Period=i;    //store value to be used again
   Chart_Pos[0]=Bars-2;
   if(ExtCountedBars>2) Chart_Pos[0]=Bars-ExtCountedBars-1;
//---- main calculation loop
   while(Chart_Pos[0]>=0)
   {
      Bar_Time=Time[Chart_Pos[0]];  //fetch the current bar time
      i=Base_Chart_Period; 
      MACD_Histo[0] = iCustom(NULL,Period(),"iMACD",MACD_Var[i,0],MACD_Var[i,1],MACD_Var[i,2],2,Chart_Pos[0]);
      i=4;
      Chart_Pos[1]=iBarShift(NULL,Higher_TF1,Bar_Time);      //find the bar in the next higher time frame
      MACD_Histo[1] = iCustom(NULL,Higher_TF1,"iMACD",MACD_Var[i,0],MACD_Var[i,1],MACD_Var[i,2],2,Chart_Pos[1]);
      i++;
      Chart_Pos[2]=iBarShift(NULL,Higher_TF2,Bar_Time);
      MACD_Histo[2] = iCustom(NULL,Higher_TF2,"iMACD",MACD_Var[i,0],MACD_Var[i,1],MACD_Var[i,2],2,Chart_Pos[2]);
      i++;      
      Chart_Pos[3]=iBarShift(NULL,Higher_TF3,Bar_Time);
      MACD_Histo[3] = iCustom(NULL,Higher_TF3,"iMACD",MACD_Var[i,0],MACD_Var[i,1],MACD_Var[i,2],2,Chart_Pos[3]);      
      Activator_Buffer[Chart_Pos[0]]=0.0;    //set buffer to zero for default value
      //check to see if we have an MACD alignment
      if ((First_Signal==false)&&(MACD_Histo[0]<0)&&(MACD_Histo[1]<0)&&(MACD_Histo[2]<0)&&(MACD_Histo[3]<0))
         {
            Activator_Buffer[Chart_Pos[0]]=High[Chart_Pos[0]];
         }
      if ((First_Signal==false)&&(MACD_Histo[0]>0)&&(MACD_Histo[1]>0)&&(MACD_Histo[2]<0)&&(MACD_Histo[3]<0))
         {
            Activator_Buffer[Chart_Pos[0]]=Low[Chart_Pos[0]] ;
         }
 	   Chart_Pos[0]--;
   }
  return(0);
  }
//+------------------------------------------------------------------+

Comments