TrendTriggerMod
Download scriptThe RD-TrendTrigger is a specialized technical analysis tool designed to identify and visualize market momentum by measuring the relative strength between "Buy Power" and "Sell Power." Rather than simply looking at current price movement, this script evaluates the relationship between recent price peaks and older price troughs to determine which side of the market holds the most influence.
Core Logic and Methodology
The indicator operates through a multi-step mathematical process to filter out market noise and highlight underlying trends:
1. Momentum Calculation (Buy vs. Sell Power) The script identifies four key price points within a specific lookback period:
- It compares the Highest High of the most recent price action against the Lowest Low of an older period to calculate "Buy Power."
- Conversely, it compares the Highest High of the older period against the Lowest Low of the recent period to calculate "Sell Power."
- By comparing these two values, the script generates a percentage score. A higher positive score indicates dominant buying pressure, while a lower (or negative) score suggests dominant selling pressure.
2. Signal Smoothing and Filtering To prevent the indicator from reacting too aggressively to minor, insignificant price fluctuations (market "noise"), the raw data is passed through a smoothing algorithm. This ensures that the resulting trend line is fluid and represents a broader market direction rather than erratic moment-to-moment changes.
3. Trend Identification The final processed value is displayed as an oscillator in a separate window on your chart. This allows traders to see the "pulse" of the market clearly:
- Positive Values: Indicate that the upward momentum is currently stronger than the downward pressure.
- Negative Values: Indicate that the downward momentum is overpowering the buying interest.
Visual Signals and Thresholds
The script includes a built-in "Trigger Level" (defaulted at 50). This creates a clear visual boundary:
- When the trend line moves above the upper trigger, it signals a significant shift toward bullish momentum.
- When the trend line moves below the lower trigger, it signals a significant shift toward bearish momentum.
Summary for the User
Essentially, this tool acts as a "momentum filter." It looks back at historical price extremes to see who is winning the tug-of-war between buyers and sellers, smooths out the chaotic movements of the market, and provides a clear, readable line that shows whether the current trend is leaning aggressively toward one side or the other.
/*+------------------------------------------------------------------+
RD-TrendTrigger: MQ4 Conversion by Shimodax (www.strategybuilder.com)
Original Notes and Authors:
Reference := Technical Analysis of Stocks and Commodities, Dec. 2004,p.28. M.H. Pee
TTF Author := Paul Y. Shimada
Link := PaulYShimada@Y...
Notes := Modified version of Trend Trigger Factor by mikesbon (thanks to perkyz)
//+------------------------------------------------------------------*/
#property copyright ""
#property link ""
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_level1 0
#property indicator_color1 CadetBlue
#property indicator_color2 Blue
#property indicator_color3 Red
//---- input parameters
extern int Regress= 15;
extern int T3= 5;
extern double B= 0.7;
extern int HistoryMax= 1000;
extern int TriggerLevel= 50;
//---- buffers
double Osc[];
double Trigger1[];
double Trigger2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Osc);
SetIndexStyle(1,DRAW_LINE, STYLE_DOT, 1);
SetIndexBuffer(1,Trigger1);
SetIndexStyle(2,DRAW_LINE, STYLE_DOT, 1);
SetIndexBuffer(2,Trigger2);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars= IndicatorCounted(),
limit;
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
limit= Bars - counted_bars;
TrendTrigger(0, limit, Osc, Regress, T3, B);
return (0);
}
//+------------------------------------------------------------------+
//| Calc forecast buffers from lastbar down to offset |
//+------------------------------------------------------------------+
void TrendTrigger(int offset, int lastbar, double &osc[], int regress, int t3, double b)
{
int shift, length;
double b2=b*b,
b3=b2*b,
c1=-b3,
c2=(3*(b2+b3)),
c3=-3*(2*b2+b+b3),
c4=(1+3*b+b3+3*b2),
n = 1 + 0.5*(t3-1),
w1 = 2 / (n + 1),
w2 = 1 - w1,
WT,
e1,e2,e3,e4,e5,e6,tmp,tmp2;
lastbar= MathMin(lastbar, HistoryMax);
lastbar= MathMin(Bars-31-regress, lastbar);
for (shift= lastbar+30; shift>=offset; shift--) {
/*=================================*/
/* Standard Specific Computations */
/*=================================*/
double
HighestHighRecent = High[Highest(NULL, 0, MODE_HIGH,regress,shift)],
HighestHighOlder = High[Highest(NULL, 0, MODE_HIGH,regress,shift + regress)],
LowestLowRecent = Low [Lowest(NULL, 0, MODE_LOW,regress,shift)],
LowestLowOlder = Low [Lowest(NULL, 0, MODE_LOW,regress,shift+regress)],
BuyPower = HighestHighRecent - LowestLowOlder,
SellPower = HighestHighOlder - LowestLowRecent,
TTF = (BuyPower - SellPower) / (0.5 * (BuyPower + SellPower)) * 100;
e1 = w1* TTF + w2*e1;
e2 = w1*e1 + w2*e2;
e3 = w1*e2 + w2*e3;
e4 = w1*e3 + w2*e4;
e5 = w1*e4 + w2*e5;
e6 = w1*e5 + w2*e6;
TTF = c1*e6 + c2*e5 + c3*e4 + c4*e3;
if (shift<=lastbar) { // don't put swing in cycle into the signal buffers
osc[shift] = TTF;
Trigger1[shift]= TriggerLevel;
Trigger2[shift]= -TriggerLevel;
}
}
return(0);
}
/*======================*
loopBegin = loopBegin + 1; //Replot previous bar
For shift = loopBegin Downto 0
{
//================================
// Standard Specific Computations
//=================================
HighestHighRecent = High[Highest(MODE_HIGH,shift,TTFbars)];
HighestHighOlder = High[Highest(MODE_HIGH,shift + TTFbars,TTFbars)];
LowestLowRecent = Low [Lowest(MODE_LOW,shift,TTFbars)];
LowestLowOlder = Low [Lowest(MODE_LOW,shift+TTFbars,TTFbars)];
BuyPower = HighestHighRecent - LowestLowOlder;
SellPower = HighestHighOlder - LowestLowRecent;
TTF = (BuyPower - SellPower) / (0.5 * (BuyPower + SellPower)) * 100;
e1 = w1 * TTF + w2 * e1;
e2 = w1 * e1 + w2 * e2;
e3 = w1 * e2 + w2 * e3;
e4 = w1 * e3 + w2 * e4;
e5 = w1 * e4 + w2 * e5;
e6 = w1 * e5 + w2 * e6;
TTF = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3;
SetIndexValue(shift,TTF);
Switch mode_0Sep_1Main
{
Case 0: //Separate window Line (with dual trigger)
SetIndexValue(shift,TTF);
//Dual value trigger +/-100
If TTF >= 0 Then SetIndexValue2(shift,50) Else SetIndexValue2(shift,(-50));
Case 1: //Main Window Colored Bars
If TTF >= 100 Then //Bull Trend, Blue bars
{
SetIndexValue(shift,High[shift]);
SetIndexValue2(shift,Low[shift]);
}
Else
If TTF <= (-100) Then //Bear Trend, Red bars
{
SetIndexValue(shift,Low[shift]);
SetIndexValue2(shift,High[shift]);
}
Else //No Trend, No colored bars
{
SetIndexValue(shift,0);
SetIndexValue2(shift,0);
}
}; //If TTF >= 100 Then ... Else
}; //Switch mode_0Sep_1Main
loopBegin = loopBegin - 1;
}
*/
Comments