Deltaforce_v1
Download scriptDelta Force Overview
The Delta Force indicator is designed to provide traders with a visual representation of price momentum by measuring the cumulative "force" or distance moved during consecutive price trends. Unlike standard oscillators that might just show current price movement, this tool focuses on how much ground the market covers as it moves in a specific direction.
How the Logic Works
The indicator monitors the closing prices of candles to determine if the market is trending upward or downward. It then calculates the "Delta" (the difference in price) for each move and aggregates these values to show the strength of the current trend.
1. Tracking Upward Momentum (Green Histogram)
When the price closes higher than the previous candle, the script identifies this as an upward move. It calculates the distance gained between these two points and adds it to a running total.
- Cumulative Effect: As long as the price continues to close higher than the previous bar, the indicator continues to add the new distance to the existing total.
- Visual Representation: This creates a growing "force" measurement in the green histogram, showing how much total ground has been gained during a sustained climb.
2. Tracking Downward Momentum (Red Histogram)
Conversely, when the price closes lower than the previous candle, the script identifies a downward move. It calculates the distance lost and adds it to a separate running total.
- Cumulative Effect: Similar to the upward trend, as long as each new bar closes lower than the last, the "downward force" continues to accumulate.
- Visual Representation: This is displayed in the red histogram, allowing traders to see the magnitude of a descending price move.
3. Resetting the Force
The logic includes a "reset" mechanism to ensure the data remains relevant to the current trend:
- If the price was trending upward and then drops, the upward "force" is reset to zero.
- If the price was trending downward and then rises, the downward "force" is reset to zero.
Summary for Traders
Essentially, this script acts as a momentum accumulator. It doesn't just tell you that the price is going up or down; it measures the intensity of that movement. A rapidly growing histogram indicates a strong, consistent trend where the market is moving significantly with each new candle. When the histogram shrinks or resets, it signals that the current momentum is breaking or reversing.
//+------------------------------------------------------------------+
//| Delta Force.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
//---- indicator buffers
double ind_buffer1[];
double ind_buffer2[];
double ind_buffer3[];
//----
double CB = 0, valueh1 = 0, valuel = 0, valueh = 0, value = 0, price = 0, hi = 1, lo = 1;
double resh = 0, resl = 0, deltah = 0, deltal = 0;
int CurrentBar=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 1 additional buffer used for counting.
IndicatorBuffers(3);
//---- drawing settings
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1);
SetIndexDrawBegin(0, 34);
SetIndexDrawBegin(1, 34);
//---- 3 indicator buffers mapping
if(!SetIndexBuffer(0, ind_buffer1) &&
!SetIndexBuffer(1, ind_buffer2) &&
!SetIndexBuffer(2, ind_buffer3))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("DeltaForce");
SetIndexLabel(0, "DF1");
SetIndexLabel(1, "DF2");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Delta Force |
//+------------------------------------------------------------------+
int start()
{
for(CB = 0 ; CB <= Bars ; CB++)
{
CurrentBar = Bars - CB;
if(Close[CurrentBar] > Close[CurrentBar+1])
{
resl = 0;
if(resh == 0)
deltah = 0;
deltah = deltah + (Close[CurrentBar] - Close[CurrentBar+1]);
// valueh = High[CurrentBar];
resh= 1;
}
if(resh == 0)
deltah = 0;
ind_buffer1[CurrentBar] = deltah;
if(Close[CurrentBar] < Close[CurrentBar+1] )
{
resh = 0;
if(resl == 0)
deltal = 0;
deltal = deltal + (Close[CurrentBar+1] - Close[CurrentBar]);
//valuel = Low[CurrentBar];
resl= 1;
}
if(resl == 0 )
deltal=0;
ind_buffer2[CurrentBar] = deltal;
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments