XprofuterDD_v1
Download scriptThe XProfuterDD is a custom technical analysis tool designed to visualize specific price movements and trends within a separate window on your trading platform. Rather than showing standard price action, it focuses on calculating the cumulative momentum of price changes over a defined period.
Core Logic & Functionality
1. Signal Calculation (Momentum Tracking) The primary function of this script is to measure the "distance" traveled by the market. It looks back at a specific number of candles (the "Period") and calculates the difference between the opening and closing prices for each candle within that timeframe. By totaling these differences, the indicator creates a line that represents the net movement of the market over that specific window.
2. Visual Offsetting (Forward Shift) The tool includes a unique feature called a "Forward Shift." This allows the resulting data lines to be moved ahead on the chart. This is often used by traders to create a visual buffer between current market activity and the calculated signals, helping to distinguish the historical calculation from the immediate live price action.
3. Optional Trend Smoothing (Moving Average) The script includes an optional layer for those who prefer smoother data. If enabled, it applies a Simple Moving Average (SMA) specifically to the calculated signal rather than the raw price. This helps filter out "noise" or sharp fluctuations, making it easier to identify the broader direction of the momentum trend.
4. Comparative Reference (Signal 2) The script can also display a secondary reference point known as "Signal 2." This provides a direct comparison by showing the individual price change of a specific candle shifted forward. By viewing this alongside the primary cumulative signal, traders can better understand how recent price action contributes to the overall momentum being shown by the main line.
Summary for Traders
In essence, this tool translates raw price data into a momentum map. It helps you visualize whether the market has been moving aggressively in one direction over a set period, providing a smoothed and shifted perspective that can assist in identifying trend strength and potential reversals.
//+------------------------------------------------------------------+
//| |
//| Filename: XprofuterDD.mq4 |
//| |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 3
//----
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 DodgerBlue
//----
extern int per =14; // Period for signal
extern int drawShift =14; // Forward shift
extern int useMA =0; // 1 = use MA
extern int maPeriod =34; // Moving average period
extern int useSignal2=0; // Show current close - open shifted forward
// Buffers for signals
double ExtMapBuffer[];
double maBuffer[];
double closeBuffer[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
string title="XProfuter(" + (string)per + ")";
// Signal and MA are normal lines
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, maBuffer);
// Signal2 is a dotted line
SetIndexStyle(2, DRAW_LINE, 2, 1);
SetIndexBuffer(2, closeBuffer);
// Shift everything forward
SetIndexShift(0, drawShift);
SetIndexShift(1, drawShift);
SetIndexShift(2, drawShift);
// Titles for each line
SetIndexLabel(0, "Signal(" + (string)per + ")");
SetIndexLabel(1, "MA(" + (string)maPeriod + ")");
SetIndexLabel(2, "Signal2(" + (string)per + ")");
//----
if(useMA==1)
{
title=title + " MA(" + (string)maPeriod + ")";
}
IndicatorShortName(title);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int shift, i, limit, lim;
double imp;
// This is to make sure we go back and update bars that have already been drawn.
// This was missing in the original release. If it's not done the live signal line
// will be the same as Signal2.
if(counted_bars > per)
{
limit=Bars - counted_bars + per;
}
else
{
limit=Bars - 1;
}
// Loop through and calculate the signals. Everytime this runs we recalculate the
// current and all future signals. The future is not set :)
for(shift=limit; shift>=0; shift--)
{
imp=0;
// This isn't really needed but makes sure we don't look for future,
// non-existant open and close points. It's just proper coding. You never know
// how a program will handle variables that don't exist. MT4 currently sets them
// to zero but you don't know if that will change.
if(shift - per < 0)
{
lim=0;
}
else
{
lim=shift - per;
}
// Calculate the signal
for(i=shift; i>=lim; i--)
{
imp=imp + (Close[i] - Open[i])/Point;
}
ExtMapBuffer[shift]=imp;
// If Signal2 is being used set it.
if(useSignal2==1)
{
closeBuffer[i]=(Close[i] - Open[i])/Point;
}
}
// If we're using the MA calculate it.
if(useMA==1)
{
for(shift=Bars - counted_bars - 1; shift>=0; shift--)
{
if(shift < Bars - maPeriod && shift < Bars - per)
{
maBuffer[shift]=iMAOnArray(ExtMapBuffer, 0, maPeriod, 0, MODE_SMA, shift);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments