FX Sniper's Chandelier

Download script
FX Sniper's Chandelier

This tool is designed to automatically calculate and display dynamic support and resistance levels on your trading chart. It serves as a visual guide to help traders identify potential "Stop Loss" zones by reacting to market volatility and price movement in real-time.

Core Logic Overview

The script functions by analyzing the relationship between current price action and market volatility. Instead of using a fixed pip value for support or resistance, it uses a mathematical approach that adjusts based on how much the market is "swinging" at any given moment.

How it Works

The logic operates differently depending on whether you are looking for upward (Long) or downward (Short) movements:

For Long Positions:

  • Initial Placement: When a new entry point is identified, the script establishes an initial baseline.
  • Dynamic Tracking: As the price moves forward, the indicator monitors the "highs" of the candles. If the price pushes higher, the indicator follows it.
  • Volatility Buffer: It uses a calculation (based on the Average True Range) to create a "cushion." The support line will only move up if the new price high is significant enough to break through that cushion. This prevents the indicator from jumping around erratically during minor fluctuations, ensuring it stays anchored to meaningful structural changes in the market.

For Short Positions:

  • Initial Placement: The script establishes a baseline based on the low of the entry candle.
  • Dynamic Tracking: It monitors the "lows" of the candles as the price moves.
  • Volatility Buffer: Similar to the long logic, it creates a protective ceiling. The resistance line only moves down if the market drops significantly enough to surpass the volatility buffer. If the price stays within the buffer, the line remains stable.

Key Visual Features

  • Automatic Updating: The script processes every candle automatically, meaning the levels on your chart update dynamically as new data arrives.
  • Visual Markers: It places specific markers (arrows) on the chart to clearly highlight where these calculated levels are located.
  • Adaptability: Because it uses a volatility factor, the distance between the price and the indicator line will expand during "choppy" markets and tighten during calm markets, providing a more organic representation of market behavior.

Summary for Traders

Essentially, this script acts as a "smart" trailing stop. It provides a moving floor (for buys) or a moving ceiling (for sells) that follows the trend but remains rigid enough to ignore minor noise. By reacting to both price peaks and market volatility simultaneously, it helps identify where a trend might be structurally breaking.

Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
FX Sniper's Chandelier

#property link      ""
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  Blue
#property indicator_chart_window


//---- buffers
double Buffer1[];
double Buffer2[];
extern int ATR_Period = 10;
extern double Chandelier_Factor = 1.25;
extern int Entry_Bar = 1;
bool iSL = true;
extern bool LONG = true;
extern double Initial_SL_Factor = 0.75;
int i;
double lprice[],hprice[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);

   SetIndexBuffer(0,Buffer1);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(1,Buffer2);
   SetIndexLabel(0,"L Stop");
   SetIndexLabel(1,"S Stop");
   SetIndexBuffer(2,lprice);
   SetIndexBuffer(3,hprice);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
 for (i=Bars;i >=0;i--)
   {
   Buffer1[i] = EMPTY_VALUE;
   Buffer2[i] = EMPTY_VALUE;
 
   }

//----
   return(0);
  }
//====================================================================
int start()
  {
   int    counted_bars=IndicatorCounted();
 
   

if (LONG==true)
//=================================  LONG =============================
{
   if (iSL == true)
   {
   Buffer1[Entry_Bar]= Open[Entry_Bar] - Initial_SL_Factor * iATR(NULL,0,ATR_Period,Entry_Bar);
   iSL = false;
   }

   else
   {
      for( i=Entry_Bar-1;i>=0;i--)
      {
         if (High[i] <= High[i+1])
         Buffer1[i]= Buffer1[i+1];
         else
         {
         if (Buffer1[i+1] >= High[i] - Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1))
            Buffer1[i] = Buffer1[i+1];
         else    
            Buffer1[i]= High[i] - Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1);
         }
      }   
    }
      
     
   
}   
//=================== SHORT ==========================

else
      {
         if (iSL == true)
         {
            Buffer2[Entry_Bar]= Low[Entry_Bar] + Initial_SL_Factor * iATR(NULL,0,ATR_Period,Entry_Bar);
            iSL = false;
         }
         else
         {
            for( i=Entry_Bar-1;i>=0;i--)
            {
               if (Low[i] >= Low[i+1])
               Buffer2[i]= Buffer2[i+1];
               else
               {
                  if(Buffer2[i+1] <= Low[i] + Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1))
                  Buffer2[i]=Buffer2[i+1];
                  else
                  Buffer2[i]= Low[i] + Chandelier_Factor * iATR(NULL,0,ATR_Period,i+1);
               }
            }
         }

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

Comments