Ergodic Oscillator_v1

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
Ergodic Oscillator_v1

This technical tool is designed as a visual aid for traders to identify market trends and momentum by smoothing out price fluctuations. It functions as an oscillator, meaning it moves up and down relative to a central "zero" line, helping users see the strength of a market move rather than just the raw price action.

How the Logic Works

The script operates through a multi-layered filtering process to provide a cleaner view of market dynamics:

1. Core Signal Foundation The tool begins by pulling data from a primary "TSI" (True Strength Index) oscillator. This acts as the raw heartbeat of the indicator, capturing the initial momentum of price movements. It uses specific timeframes and smoothing constants (which you can adjust in the settings) to determine the basic speed of the market.

2. The First Smoothing Layer (Ergodic Buffer) To prevent the visual data from being too "noisy" or erratic, the script takes that core signal and applies an Exponential Moving Average (EMA). This step acts as a stabilizer; it filters out minor price spikes and "jitter," leaving behind a smoother curve that represents the broader trend of the momentum.

3. The Final Signal Refinement For maximum clarity, the logic performs one final smoothing pass on the previously stabilized data. By applying a second layer of moving averages, the indicator creates a highly polished visual line. This helps traders identify long-term direction and significant shifts in sentiment without being distracted by short-term market noise.

Visual Interpretation for Traders

The tool displays two primary lines on your chart:

  • The Main Trend: A smooth curve that represents the processed momentum of the market.
  • The Signal Line: A secondary, even more refined average that acts as a guide.

By observing how these two lines interact—such as when they cross each other or move away from the center levels (20 and -20)—traders can better identify potential turning points and the relative strength of the current market direction.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Ergodic Oscillator_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

  //+------------------------------------------------------------------+
//|                                                          TSI.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_level1 0
#property indicator_level2 20
#property indicator_level3 -20
//---- input parameters
extern int       First_R=8;
extern int       Second_S=5;
extern int       SignalPeriod=5;
extern int       Mode_Smooth=1;
//---- buffers
double ErgodicBuffer[];
double Signal_Buffer[];
double TSI_Siganl_Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);

   SetIndexBuffer(2, TSI_Siganl_Buffer);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ErgodicBuffer);
   SetIndexLabel(0,"Ergodic");
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,Signal_Buffer);
   SetIndexLabel(1,"Signal");
   IndicatorShortName("Ergodic Osc"+"("+First_R+","+Second_S+","+SignalPeriod+")");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit,i;
   limit=Bars-counted_bars-1;
   for (i=limit;i>=0;i--)
      {
      TSI_Siganl_Buffer[i]=iCustom(NULL,0,"TSI-Osc",First_R,Second_S,SignalPeriod,Mode_Smooth,1,i);
      }
      
   for (i=limit;i>=0;i--)
      {
      ErgodicBuffer[i]=iMAOnArray(TSI_Siganl_Buffer,0,5,0,MODE_EMA,i);
      }

   for (i=limit;i>=0;i--)
      {
      Signal_Buffer[i]=iMAOnArray(ErgodicBuffer,0,5,0,MODE_EMA,i);
      }

//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments