Author: Copyright � 2004, scorpion.
JMA_CCI

This tool is designed as a technical analysis indicator for the MetaTrader platform, specifically blending two distinct types of market data to help traders identify price momentum and potential overextended conditions.

Core Logic Overview

The script functions by merging a modified version of the Commodity Channel Index (CCI) with the Jurik Moving Average (JMA). Instead of using a standard moving average—which often suffers from "lag" (reacting too slowly to price changes) or "noise" (reactting too quickly to minor fluctuations)—this script utilizes the Jurik Moving Average as its foundation. This provides a smoother, more responsive baseline for calculating price deviations.

How the Calculation Works

The logic follows a structured four-step process to generate the final visual data:

  1. Baseline Establishment: The script first calculates the Jurik Moving Average based on a user-defined period. This creates a "smooth" path of the market's recent average price, serving as the anchor point for all other calculations.
  2. Relative Price Positioning: It determines the distance between the current market price (calculated as the average of the High, Low, and Close prices) and the Jurik Moving Average. This tells the script how far the price has strayed from its "normal" path.
  3. Volatility Measurement: The tool calculates the "Standard Deviation," which measures the intensity of price swings over a specific window of time. It specifically looks at the absolute difference between recent prices and the Jurik baseline to understand how volatile the market is currently behaving.
  4. Final Ratio Calculation: Finally, the script divides the Relative Price Positioning by the Volatility Measurement. This produces the final indicator value.

Practical Meaning for the User

By dividing the price distance by the volatility, the indicator essentially "normalizes" the market movement.

  • In low-volatility environments, it helps identify when a small move is actually significant enough to warrant attention.
  • In high-volatility environments, it prevents the indicator from giving false signals during wide, erratic price swings that don't represent a true change in trend.

The result is a smoothed momentum line that reacts more intelligently to market shifts than standard oscillators, aiming to provide a clearer picture of whether the price is overextended or gaining strength.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
JMA_CCI
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                          JMA_CCI.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, scorpion."
#property link      "http://www.fxfisherman.com/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
//---- input parameters
extern int CCIPeriod=14;
extern int JMAPhrase=0;
//---- buffers
double CCIBuffer[];
double RelBuffer[];
double DevBuffer[];
double MovBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(4);
   SetIndexBuffer(1, RelBuffer);
   SetIndexBuffer(2, DevBuffer);
   SetIndexBuffer(3, MovBuffer);
//---- indicator lines
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,CCIBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="JMA CCI("+CCIPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,CCIPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Commodity Channel Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,k,counted_bars=IndicatorCounted();
   double price,sum,mul;
   if(Bars<=CCIPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
     {
      for(i=1;i<=CCIPeriod;i++) CCIBuffer[Bars-i]=0.0;
      for(i=1;i<=CCIPeriod;i++) DevBuffer[Bars-i]=0.0;
      for(i=1;i<=CCIPeriod;i++) MovBuffer[Bars-i]=0.0;
     }
//---- last counted bar will be recounted
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;
//---- moving average
   for(i=0; i<limit; i++)
      MovBuffer[i]=iCustom(NULL,0,"JMA",CCIPeriod,0,i);
      //MovBuffer[i]=iMA(NULL,0,CCIPeriod,0,MODE_SMA,PRICE_TYPICAL,i);
//---- standard deviations
   i=Bars-CCIPeriod+1;
   if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;
   mul=0.015/CCIPeriod;
   while(i>=0)
     {
      sum=0.0;
      k=i+CCIPeriod-1;
      while(k>=i)
       {
         price=(High[k]+Low[k]+Close[k])/3;
         sum+=MathAbs(price-MovBuffer[i]);
         k--;
       }
      DevBuffer[i]=sum*mul;
      i--;
     }
   i=Bars-CCIPeriod+1;
   if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      price=(High[i]+Low[i]+Close[i])/3;
      RelBuffer[i]=price-MovBuffer[i];
      i--;
     }
//---- cci counting
   i=Bars-CCIPeriod+1;
   if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      if(DevBuffer[i]==0.0) CCIBuffer[i]=0.0;
      else CCIBuffer[i]=RelBuffer[i]/DevBuffer[i];
      i--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments