Waddah Attar Scalping
Download scriptThis tool is designed to provide a visual representation of market momentum by analyzing price movements across two different timeframes simultaneously. Instead of looking at a single chart, the logic works by "layering" information from two distinct periods to help identify where the current price stands in relation to historical highs, lows, and averages.
How the Logic Works
1. Dual-Timeframe Analysis The script evaluates the market using two different timeframes (defined as P1 and P2). By looking at the data from two perspectives at once—for example, a short-term view and a longer-term view—the tool attempts to capture a more complete picture of the market's behavior than a single timeframe could provide on its own.
2. Calculating the "Market Center" For both timeframes, the script looks back over a specific historical period (the IPeriod) to identify three key data points:
- The highest price reached.
- The lowest price reached.
- A calculated average of the closing prices from the immediate preceding bars.
It then combines these three points to establish a "center" or equilibrium point for that specific timeframe.
3. Measuring Deviation (The A and B Factors) The core logic then calculates how far the current market price has drifted away from that "center" point:
- Factor A: Represents the distance from the center in the first timeframe.
- Factor B: Represents the distance from the center in the second timeframe.
If the current price is above the center, the result is positive; if it is below the center, the result is negative.
4. Visualizing the Momentum The final output is displayed as a histogram in a separate window at the bottom of your chart. The logic determines what to show based on whether the deviations are moving in the same direction:
- Bullish Alignment: If the current price is above the center point in both timeframes simultaneously, the tool calculates the combined strength of these movements and displays it as a Green histogram. This suggests that both short-term and long-term trends are currently pushing upwards.
- Bearish Alignment: If the current price is below the center point in both timeframes simultaneously, the tool combines those values and displays them as a Red histogram. This indicates that both timeframes are currently pushing downwards.
Summary for Traders
Essentially, this script acts as a confirmation filter. It ignores "noisy" movements where one timeframe might be going up while another is going down. Instead, it highlights moments of high conviction where both timeframes agree on the direction of the market, providing a clearer visual cue of the prevailing trend.
#property copyright "Copyright © 2009, Waddah Attar"
#property link "waddahattar@hotmail.com"
//----
extern int IPeriod=180;
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_level1 0
extern int P1=1;
extern int P2=5;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_HISTOGRAM,0,2);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1, DRAW_HISTOGRAM,0,2);
SetIndexBuffer(1, ExtMapBuffer2);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Float Pivot |
//+------------------------------------------------------------------+
int start()
{
//----
int i,j;
double max,min,pivot,A,B;
i=1000;
while(i>=0)
{
j=iBarShift(Symbol(),P1,Time[i],false);
max=iHigh(Symbol(),P1,iHighest(Symbol(),P1,MODE_HIGH,IPeriod,j));
min=iLow(Symbol(),P1,iLowest(Symbol(),P1,MODE_LOW,IPeriod,j));
pivot=(iClose(Symbol(),P1,j+1)+iClose(Symbol(),P1,j+2)+iClose(Symbol(),P1,j+3))/3;
A=(Close[i]-((max + min + pivot)/3))/Point;
j=iBarShift(Symbol(),P2,Time[i],false);
max=iHigh(Symbol(),P2,iHighest(Symbol(),P2,MODE_HIGH,IPeriod,j));
min=iLow(Symbol(),P2,iLowest(Symbol(),P2,MODE_LOW,IPeriod,j));
pivot=(iClose(Symbol(),P2,j+1)+iClose(Symbol(),P2,j+2)+iClose(Symbol(),P2,j+3))/3;
B=(Close[i]-((max + min + pivot)/3))/Point;
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
if(A>0 && B>0)
{
ExtMapBuffer1[i]=(A+B);
}
if(A<0 && B<0)
{
ExtMapBuffer2[i]=(A+B);
}
i--;
}
return(0);
}
Comments