Author: Copyright � 2005-2006, RickD
Stodiv

This technical indicator is designed to help traders identify potential price turning points by combining three distinct market signals: historical structural peaks (Fractals), momentum trends (Stochastic Oscillator), and relative price distance.

How the Logic Works

The script scans your price chart to find specific "signals" where the market might be reaching a limit. It does this by looking for two specific scenarios:

1. Identifying Upper Price Reversals (Bearish Signals) To determine if the price is likely to drop, the script looks for a "Fractal"—a peak in the price chart that is higher than the surrounding candles. However, it doesn't just mark every peak; it applies two extra layers of logic:

  • Structural Distance: It ensures the current peak is significantly higher than any other nearby peaks within a specific range (defined by the "dx" and "dy" settings). This helps filter out minor price fluctuations.
  • Momentum Confirmation: Once a significant high is found, it checks the Stochastic Oscillator. If the current momentum is lower than the momentum at that peak, it suggests that while the price is high, the "speed" of the move is weakening. When both conditions are met, it places a visual arrow above the candle.

2. Identifying Lower Price Reversals (Bullish Signals) Similarly, to find opportunities where the price might start moving up, the script looks for "Lower Fractals"—valleys in the price chart. It applies the same rigorous screening:

  • Structural Depth: It verifies that the current low is significantly lower than other nearby lows within the designated range.
  • Momentum Confirmation: It checks the Stochastic Oscillator to see if momentum is increasing compared to the previous valley. If the price is at a structural low but the upward momentum is strengthening, it places a visual arrow below the candle.

Summary of Key Features

  • Filtering Noise: By requiring a minimum distance between peaks (structural integrity), the script ignores small, insignificant "wiggles" in the market and focuses on major turning points.
  • Double Verification: The tool doesn't rely on price alone; it requires both a structural shape (Fractals) and a mathematical trend change (Stochastic) to agree before giving you a signal.
  • Visual Clarity: Instead of cluttering your screen with lines, the script provides clean visual cues—arrows placed specifically above high points and below low points—to highlight where these conditions have been met.
Indicators Used
FractalsStochastic oscillator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Stodiv
//+------------------------------------------------------------------+
//|                                                       Stodiv.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property copyright "Copyright © 2005-2006, RickD"
#property link      "http://e2e-fx.net"


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Crimson
#property indicator_color2 DodgerBlue


extern int MaxBars = 300;
extern int dx = 30;
extern int dy = 20;

extern int KPeriod = 5;
extern int DPeriod = 3; 
extern int Slowing = 3;

double buf1[];
double buf2[];

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void init() {
  SetIndexBuffer(0, buf1);
  SetIndexBuffer(1, buf2);
  
  SetIndexStyle(0, DRAW_ARROW, EMPTY, 2);
  SetIndexArrow(0, 234);

  SetIndexStyle(1, DRAW_ARROW, EMPTY, 2);
  SetIndexArrow(1, 233);  
}


void start() {
  
  double fr0, fr1;
  double sto0, sto1;
  
  
  int counted = IndicatorCounted();
  if (counted < 0) return (-1);
  
  if (counted > 0) counted--;
  int limit = Bars-counted;
  limit = MathMin(limit, Bars-dx);
  limit = MathMin(limit, MaxBars);
  
  
  for(int i=0; i < limit; i++) {
    buf1[i] = 0;
    
    fr0 = iFractals(NULL, 0, MODE_UPPER, i+2);
    if (fr0 == 0) continue;
    
    for(int j=i+1; j < i+dx; j++) {
      fr1 = iFractals(NULL, 0, MODE_UPPER, j+2);
      if (fr1 == 0) continue;
    
      if (fr0 > fr1+dy*Point) {
        sto0 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i+2);
        sto1 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, j+2);
    
        if (sto0 < sto1) {
          buf1[i] = High[i] + 20*Point;
          break;
        }
      }
    }
  }

  for(i=0; i < limit; i++) {
    buf2[i] = 0;
    
    fr0 = iFractals(NULL, 0, MODE_LOWER, i+2);
    if (fr0 == 0) continue;
    
    for(j=i+1; j < i+dx; j++) {
      fr1 = iFractals(NULL, 0, MODE_LOWER, j+2);
      if (fr1 == 0) continue;
    
      if (fr0 < fr1-dy*Point) {
        sto0 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i+2);
        sto1 = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, j+2);
    
        if (sto0 > sto1) {
          buf2[i] = Low[i] - 20*Point;
          break;
        }
      }
    }
  }
  
  
}

Comments