V-T&Bv6_v1
Download scriptThis script is a specialized technical analysis tool designed to identify potential price reversal points by analyzing specific candlestick formations and market volatility. It focuses on detecting "wicks"—the thin lines on candles that represent price movement that failed to hold—to signal where the market might be exhausting its momentum.
Core Logic Overview
The script operates by scanning past and current price data to identify two specific types of signals: V-Tops (potential overhead resistance) and V-Bottoms (potential underlying support).
To confirm these signals, the logic uses a multi-layered filtering process:
1. Wick Geometry Analysis
The tool first looks for candles where the "wick" is significantly larger than the "body" of the candle. By using a customizable ratio, it ignores standard price movements and only highlights instances where price pushed aggressively in one direction but was quickly rejected. Specifically:
- High Wicks: Identified when the highest point reached by the price exceeds the previous candle's high, accompanied by a long upper wick relative to the candle's size.
- Low Wicks: Identified when the lowest point reached by the price drops below the previous candle's low, accompanied by a long lower wick relative to the candle's size.
2. Market Context and State Detection
The script doesn't just look at a single candle in isolation; it evaluates the relationship between the current candle and the one immediately preceding it. It categorizes the market into four "States" based on whether the momentum is Bullish (upward) or Bearish (downward):
- Bearish Momentum vs. Bullish Action
- Bearish Momentum vs. Bearish Action
- Bullish Momentum vs. Bullish Action
- Bullish Momentum vs. Bearish Action
By identifying these states, the tool can better understand if a rejection (a wick) is happening against the prevailing trend or as a result of it.
3. Volatility Filtering ("Juice")
To ensure the signals are relevant to active market conditions, the script includes a volatility check referred to in the code as "Juice." It calculates the standard deviation of price movements over a specific period. If the current market activity falls below a certain threshold, the script filters out the signal, preventing "noisy" entries during periods of extremely low liquidity or stagnant movement.
4. Precision Confirmation
Finally, for higher accuracy, the script performs a "penetration" check. It calculates how far into the previous candle's price range the current wick reached. If the wick penetrates a specific percentage of the previous price action while meeting all other criteria (geometry, state, and volatility), it triggers an alert.
Visual and Audio Feedback
When these conditions are met, the script provides immediate feedback to the user:
- Visual: It places colored arrows on the chart (Red for potential tops, Green for potential bottoms).
- Audio: If enabled in the settings, it plays a specific sound notification to alert the trader in real-time.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| V-T&B.mq4 |
//| Don Lawson (don_forex) |
//+------------------------------------------------------------------+
#property copyright "Coded by Don Lawson (don_forex)"
#property link "d_n_d_enterprises@sbcglobal.net"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_color2 Green
#property indicator_width2 2
extern double WickRatio = 0.5;
extern double WickPercent = 50;
extern int JuicePeriod = 7;
extern int JuiceLevelForAlert = 5;
extern bool Notify = false;
extern bool UseNew = true;
double VTop[];
double VBottom[];
double DistanceFromCandle;
int Level = 5;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY);
SetIndexArrow(0, 234);
SetIndexBuffer(0, VTop);
SetIndexStyle(1, DRAW_ARROW, EMPTY);
SetIndexArrow(1, 233);
SetIndexBuffer(1, VBottom);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
void SetVTop(int index)
{
double Juice, JuiceLevel;
// Check for Juice
JuiceLevel = Level*Point;
if (Period()==5 ) JuiceLevel=JuiceLevel/2;
Juice = iStdDev (NULL,0,JuicePeriod,MODE_EMA,0,PRICE_CLOSE,index)-JuiceLevel;
if (Juice > JuiceLevelForAlert*Point) {
VTop[index] = High[index]+ DistanceFromCandle;
if (Notify) PlaySound("V-Top.wav");
}
}
void SetVBottom(int index)
{
double Juice, JuiceLevel;
// Check for Juice
JuiceLevel = Level*Point;
if (Period()==5 ) JuiceLevel=JuiceLevel/2;
Juice = iStdDev (NULL,0,JuicePeriod,MODE_EMA,0,PRICE_CLOSE,index)-JuiceLevel;
if (Juice > JuiceLevelForAlert*Point) {
VBottom[index] = Low[index]- DistanceFromCandle;
if (Notify) PlaySound("V-Bottom.wav");
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, i,State;
double WickPenetration;
double BullWickPenHi,BullWickPenLow;
double BearWickPenHi,BearWickPenLow;
double BullWickHi,BullWickLow,BullBody;
double BearWickHi,BearWickLow,BearBody;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
WickPenetration = WickPercent/100.0;
DistanceFromCandle = Point*8;
for(i = 1; i <= limit; i++) {
bool CurrentBull = false,
CurrentBear = false,
Bull = false,
Bear = false,
HiWick = false,
LoWick = false;
if (Open[i-1]<Close[i-1])
CurrentBull = true;
else
CurrentBear = true;
if (Open[i]<Close[i])
Bull = true;
else
Bear = true;
BullWickHi = High[i] - Close[i];
BullWickLow = Open[i] - Low[i];
BullBody = Close[i] - Open[i];
BearWickHi = High[i] - Open[i];
BearWickLow = Close[i] - Low[i];
BearBody = Open[i] - Close[i];
// Check for VTOP
if (High[i] > High[i+1])
{
if (Bull) {
if ((BullWickHi > BullBody * WickRatio))// && (BullWickHi > BullWickLow)
HiWick = true;
}
if (Bear){
if ((BearWickHi > BearBody * WickRatio))// && (BearWickHi > BearWickLow)
HiWick = true;
}
}
// Check for VBottom
if (Low[i] < Low[i+1])
{
if (Bull){
if ((BullWickLow > BullBody * WickRatio))// && (BullWickLow > BullWickHi)
LoWick = true;
}
if (Bear){
if ((BearWickLow > BearBody * WickRatio))// && (BearWickLow > BearWickHi)
LoWick = true;
}
}
// Set up State Table
if (CurrentBear && Bull) State = 1;
if (CurrentBear && Bear) State = 2;
if (CurrentBull && Bull) State = 3;
if (CurrentBull && Bear) State = 4;
// Set Arrow
if (HiWick) {
BullWickPenHi = Close[i] + BullWickHi * WickPenetration;
BearWickPenHi = Open[i] + BearWickHi * WickPenetration;
switch (State)
{
case 1 : // CurrentBear && Bull
if (UseNew)
{
if ( Open[i-1] < BullWickPenHi) SetVTop(i);
}
else
{
SetVTop(i);
}
break;
case 2 : // CurrentBear && Bear
if (UseNew)
{
if (Open[i-1] < BearWickPenHi) SetVTop(i);
}
else
{
SetVTop(i);
}
break;
case 3 : // CurrentBull && Bull
if (UseNew)
{
if (Close[i-1] < BullWickPenHi) SetVTop(i);
}
else
{
SetVTop(i);
}
break;
case 4 : // CurrentBull && Bear
if (UseNew)
{
if (Close[i-1] < BearWickPenHi) SetVTop(i);
}
else
{
SetVTop(i);
}
break;
}
}
if (LoWick) {
BullWickPenLow = Open[i] - BullWickLow * WickPenetration;
BearWickPenLow = Close[i] - BearWickLow * WickPenetration;
switch (State)
{
case 1 : // CurrentBear && Bull
if (UseNew)
{
if (Close[i-1] > BullWickPenLow) SetVBottom(i);
}
else
{
SetVBottom(i);
}
break;
case 2 : // CurrentBear && Bear
if (UseNew)
{
if (Close[i-1] > BearWickPenLow) SetVBottom(i);
}
else
{
SetVBottom(i);
}
break;
case 3 : // CurrentBull && Bull
if (UseNew)
{
if (Open[i-1] > BullWickPenLow) SetVBottom(i);
}
else
{
SetVBottom(i);
}
break;
case 4 : //CurrentBull && Bear)
if (UseNew)
{
if (Open[i-1] > BearWickPenLow) SetVBottom(i);
}
else
{
SetVBottom(i);
}
break;
}
}
}
return(0);
}
Comments