MT4-Psychological

Download script
Author: Copyright � 2007, Bruce Hellstrom (brucehvn)
MT4-Psychological

The Psychological Indicator is a market analysis tool designed to help traders understand the underlying "sentiment" of a currency pair or asset by measuring the momentum of price movement over a specific timeframe. Unlike standard indicators that might focus solely on price volatility, this tool looks at the frequency of upward versus downward movements to gauge whether the market is feeling optimistic or pessimistic.

How the Logic Works

The core logic of this indicator relies on "counting" successful price actions. It examines a user-defined number of past periods (defaulting to 25) and performs the following steps:

  • Trend Counting: The script scans the history of closing prices to see how many times the price closed higher than it did in the previous period. Each time a "higher close" occurs, the indicator adds to its count.
  • Sentiment Calculation: By comparing these upward movements against the total number of periods examined, the tool generates a percentage score. This result is displayed as a line on your chart in a separate window.
  • Visual Benchmarks: The indicator includes specific horizontal levels (25%, 50%, and 75%) to help you quickly identify market extremes. These levels serve as visual cues for identifying potential overbought or oversold conditions, or shifts in the dominant market trend.

Practical Application

Instead of just seeing a price line moving up and down, this indicator translates that movement into a "psychological" score:

  • High Scores (near 75%+): Suggest a strong prevailing bullish sentiment where the majority of recent price actions have been positive.
  • Low Scores (near 25%-): Suggest a dominant bearish sentiment where the majority of recent price actions have been negative.
  • Mid-Range (near 50%): Represents a balanced market where neither bulls nor bears have established clear dominance over the lookback period.

By providing this percentage-based view, the indicator helps traders see "the big picture" of market momentum, allowing for a clearer understanding of whether the current price action is driven by consistent strength or temporary fluctuations.

Miscellaneous
Implements a curve of type %1
7 Views
0 Downloads
0 Favorites
MT4-Psychological
/////////////////////////////////////////////////////////////////////
// Psychological Indicator (Ported from FXAccucharts)
// Version 1.0
// Copyright © 2007, Bruce Hellstrom (brucehvn)
// bhweb@speakeasy.net
// http://www.metaquotes.net
/////////////////////////////////////////////////////////////////////

/*

    This indicator is ported from the FXAccuCharts platform to MT4.  The formula
    used here has been tested on FXAccuCharts to insure it displays the same as
    their default psychological indicator.
    
    Input Parameters:
    PsychPeriod - Lookback periods for the indicator (25 default)
    
    
    Revision History
    Version 1.0
    * Initial Revision
    
*/    


#property copyright "Copyright © 2007, Bruce Hellstrom (brucehvn)"
#property link      "http: //www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_style1 STYLE_SOLID

#property indicator_level1 50.0
#property indicator_level2 75.0
#property indicator_level3 25.0
#property indicator_levelcolor Silver
#property indicator_levelwidth 1
#property indicator_levelstyle STYLE_DOT

#define INDICATOR_VERSION "v1.0"


// Input Parameters
extern int PsychPeriod = 25;

// Buffers
double PsychBuffer[];

// Other Variables
string ShortName;
int CountBuf[];


/////////////////////////////////////////////////////////////////////
// Custom indicator initialization function
/////////////////////////////////////////////////////////////////////

int init() {

    IndicatorBuffers( 1 );
    SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 1 );
    SetIndexBuffer( 0, PsychBuffer );
    SetIndexDrawBegin( 0, PsychPeriod );
    
    ArraySetAsSeries( CountBuf, true );
    
    ShortName = "Psychological-" + INDICATOR_VERSION + "(" + PsychPeriod + ")";
    
    IndicatorShortName( ShortName );
    SetIndexLabel( 0, ShortName );
    
    Print( ShortName );
    Print( "Copyright (c) 2007 - Bruce Hellstrom, bhweb@speakeasy.net" );
    
    return( 0 );
}

/////////////////////////////////////////////////////////////////////
// Custom indicator deinitialization function
/////////////////////////////////////////////////////////////////////

int deinit() {
    return( 0 );
}

/////////////////////////////////////////////////////////////////////
// Indicator Logic run on every tick
/////////////////////////////////////////////////////////////////////

int start() {
    
    int counted_bars = IndicatorCounted();
    
    // Check for errors
    if ( counted_bars < 0 ) {
        return( -1 );
    }

    // Last bar will be recounted
    if ( counted_bars > 0 ) {
        counted_bars--;
    }
    
    // Resize the non-buffer array if necessary
    if ( ArraySize( CountBuf ) != ArraySize( PsychBuffer ) ) {
        ArraySetAsSeries( CountBuf, false );
        ArrayResize( CountBuf, ArraySize( PsychBuffer ) );
        ArraySetAsSeries( CountBuf, true );
    }
    

    // Get the upper limit
    int limit = Bars - counted_bars;
    
    for ( int ictr = 0; ictr < limit; ictr++ ) {
        int Count = 0;
        int endctr = ictr + 1 + PsychPeriod;
        
        for ( int jctr = ictr + 1; jctr < endctr; jctr++ ) {
            if ( Close[jctr] > Close[jctr + 1] ) {
                Count++;
            }
        }

        if ( Close[ictr] > Close[ictr + 1] ) {
            Count++;
        }
                
        if ( Close[ictr + PsychPeriod] > Close[ictr + PsychPeriod + 1] ) {
            Count--;
        }

        double dCount = Count;
        PsychBuffer[ictr] = ( dCount / PsychPeriod ) * 100.0;
    }
            
    return( 0 );
}

    

Comments