Author: Copyright � 2005, Nick Bilak
TTF_TR_v1

This technical indicator is designed to provide traders with a visual representation of market momentum and trend direction by comparing recent price movements against historical data over a specific timeframe. It identifies whether the market is currently showing more "buying strength" or "selling pressure" relative to its recent past.

Core Logic and Functionality

The script operates by analyzing two distinct sets of price extremes: the current immediate price action and a slightly older historical window (defined by the user-set "bars" parameter).

1. Measuring Market Power To determine the strength of a move, the indicator calculates two different types of "Power" values:

  • Buy Power: This is calculated by looking at the highest price reached in the most recent bar and comparing it against the lowest price reached over a historical period. It essentially measures how much the market has pushed upward compared to its previous floor.
  • Sell Power: Conversely, this looks at the highest price from the historical period and compares it against the lowest price of the most recent bar. This identifies how much downward pressure is currently being exerted relative to previous highs.

2. The Trend Oscillator (TTF) The script then takes these two power figures and performs a mathematical comparison to produce a percentage-based oscillator. This results in a value that fluctuates based on which "side" of the market—buying or selling—is dominating. When the value is positive, it suggests upward momentum; when negative, it suggests downward momentum.

3. Visual Signals The indicator provides two distinct visual components in a separate window on your chart:

  • The Main Line: This represents the calculated trend oscillator. It allows you to see the fluid movement of market sentiment as it shifts back and forth.
  • The Signal Line: This acts as a simplified trigger. Rather than showing a complex average, it provides a binary visual cue. Based on the position of the main trend line, it switches between a top and bottom boundary, making it easier for the user to identify clear zones of dominance at a glance.

Key Characteristics

  • Real-Time Accuracy: The logic is designed to be "non-repainting," meaning it calculates data based on completed price information rather than predicting future moves that might disappear or change later.
  • No Smoothing Delay: Unlike many indicators that use heavy averages which can lag behind the market, this logic focuses on raw price extremes to ensure the trend data is as responsive as possible.
  • Customizable Sensitivity: By adjusting the "bars" parameter, users can choose whether they want the indicator to react quickly to minor price fluctuations or focus on broader, longer-term trends.
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
TTF_TR_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                       Trendscalpindic.mq4        |
//|                        Based on Nick Beluk's TTF implementation  |
//|                        No redrawing, no lookahead, nosmoothing   |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Nick Bilak"
#property link      "beluck[at]gmail.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Red
//---- input parameters
extern int TTFbars=15;
//15=default number of bars for computation
//---- buffers
double MainBuffer[];
double SignalBuffer[];
//----
int TopLine=100;
int BottomLine=-100;
int draw_begin1=0;
int draw_begin2=0;
double  HighestHighRecent=0;
double  HighestHighOlder =0;
double  LowestLowRecent =0;
double  LowestLowOlder =0;
double  BuyPower =0;
double  SellPower=0;
double  TTF=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(2);
//---- indicator lines
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, MainBuffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1, SignalBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="TTF_TR("+TTFbars+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   SetIndexLabel(1,"Signal");
//----
   draw_begin1=TTFbars*2+1;
   draw_begin2=draw_begin1;
   SetIndexDrawBegin(0,draw_begin1);
   SetIndexDrawBegin(1,draw_begin2);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| ttf                                            |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k;
   int    counted_bars=IndicatorCounted();
   double price;
//----
   if(Bars<=draw_begin2) return(0);
//---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0;
      for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0;
     }
//---- %K line
   i=Bars-draw_begin1;
   if(counted_bars>draw_begin1) i=Bars-counted_bars-1;
   while(i>=0)
     {
   HighestHighRecent=High[Highest(Symbol(), 0, MODE_HIGH,1,i)];
   HighestHighOlder=High[Highest(Symbol(), 0, MODE_HIGH,TTFbars,i+1)];
   LowestLowRecent=Low [Lowest (Symbol(), 0, MODE_LOW,1,i)];
   LowestLowOlder=Low [Lowest (Symbol(), 0, MODE_LOW,TTFbars,i+1)];
   BuyPower=HighestHighRecent-LowestLowOlder;
   SellPower=HighestHighOlder-LowestLowRecent;
   TTF=(BuyPower-SellPower)/(0.5*(BuyPower+SellPower))*100;
     //Print (Time[i], "   ", HighestHighRecent, ",  ",HighestHighOlder, ",  ", LowestLowRecent, ",  ",LowestLowOlder    );

  MainBuffer[i]=TTF;
  i--;
 }
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
//---- signal line is simple movimg average
   for(i=0; i<limit; i++) {
      if (MainBuffer[i]>=0) 
         SignalBuffer[i]=TopLine;
      else
         SignalBuffer[i]=BottomLine;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments