MA_ribbon_filled

Download script
Author: mladen
MA_ribbon_filled

This tool is designed to provide visual clarity on market trends by analyzing price movement through two different lenses. It functions by calculating two distinct Moving Averages—mathematical lines that smooth out "market noise" to show the underlying direction of a currency pair or asset.

Core Logic and Visual Representation

The script operates by comparing a short-term moving average against a longer-term moving average.

  • The Short-Term Average: This tracks recent price action more closely, reacting quickly to sudden shifts in momentum.
  • The Long-Term Average: This tracks the broader price history over a larger window of time, representing the overall primary trend.

By plotting these two averages simultaneously, the script creates what is known as a "ribbon" effect. When the lines are plotted on your chart, they allow you to see the relationship between immediate price momentum and the long-term market direction.

How it Works

The script performs a continuous calculation across every candle on your chart:

  1. It identifies the average price over a specific number of previous bars (defined by the user as the "Period").
  2. It calculates these averages using a standard smoothing method (Simple Moving Average) based on the closing prices.
  3. It then renders these values visually on your screen using specific colors and line thicknesses.

Trading Insights

For a trader, this logic is intended to highlight trend strength. When the short-term average moves significantly above or below the long-term average, it can signal a strengthening trend. Conversely, when the two averages move closer together or begin to flatten out, it may suggest that the current trend is losing momentum or that the market is entering a period of consolidation.

Essentially, this script simplifies complex price data into a clear visual guide, helping you distinguish between temporary price fluctuations and sustained market movements.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
MA_ribbon_filled
//+------------------------------------------------------------------+
//|                                                    MA ribbon.mq4 |
//|                                               mladenfx@gmail.com |
//|                                                                  |
//| original idea by Jose Silva                                      |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 C'0,70,0'
#property indicator_color2 C'70,0,0'
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2
#property indicator_width4 2

//
//
//
//
//

extern int       MA1Period=13;
extern int       MA1Method=MODE_SMA;
extern int       MA1Price =PRICE_CLOSE;
extern int       MA2Period=26;
extern int       MA2Method=MODE_SMA;
extern int       MA2Price =PRICE_CLOSE;

//
//
//
//
//

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   SetIndexBuffer(0,buffer3); SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,buffer4); SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(2,buffer1);
   SetIndexBuffer(3,buffer2);
   return(0);
}
int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;

   //
   //
   //
   //
   //

   for(i=limit; i>=0; i--)
   {
      buffer1[i] = iMA(NULL,0,MA1Period,0,MA1Method,MA1Price,i);
      buffer2[i] = iMA(NULL,0,MA2Period,0,MA2Method,MA2Price,i);
      buffer3[i] = buffer1[i];
      buffer4[i] = buffer2[i];
   }
   return(0);
}

Comments