SAR Color Bar

Download script
Author: Kalenzo Code adapted by cja
SAR Color Bar

This tool is designed to provide a visual representation of market momentum by transforming standard price action data into a color-coded histogram. Instead of showing complex lines or overlapping figures, it simplifies market sentiment into two distinct visual states: upward potential and downward potential.

How the Logic Works

The core functionality relies on a mathematical calculation known as the Parabolic SAR (Stop and Reverse). In standard trading, this is often viewed as a "trailing" indicator that identifies potential turning points. This specific script takes that data and applies a binary logic to it to determine the visual output:

  • Market Sentiment Detection: The script constantly monitors the current price relative to the calculated Parabolic SAR value.
  • The "Up" Condition: If the calculated value is found to be at or above the highest price reached during a specific period, the script identifies this as an upward channel. It then highlights the data in Red.
  • The "Down" Condition: Conversely, if the calculated value falls below the high price of that period, the script recognizes a downward trend and reflects this by highlighting the data in Green.

Visual Representation

By using these two states, the tool creates a "Color Bar" effect in a separate window on your trading platform. Rather than cluttering your main price chart, it provides a dedicated space where you can see the progression of market trends:

  • Red Bars: Indicate periods where the logic identifies upward pressure or specific resistance levels.
  • Green Bars: Indicate periods where the logic identifies downward pressure or support levels.

Key Parameters

To ensure the tool aligns with your specific trading style, the script utilizes three primary settings:

  1. Step: Controls the acceleration of the calculation (how quickly the indicator reacts to new price changes).
  2. Maximum: Sets a limit on that acceleration to prevent the indicator from moving too erratically during high volatility.
  3. Precision: Determines how many decimal places are used for the calculations, ensuring the data is smoothed and accurate according to your currency or asset's pricing.

In summary, this tool acts as a visual filter, stripping away market noise to show you at a glance whether the current momentum leans toward an upward or downward direction based on historical price highs.

Price Data Components
Series array that contains the highest prices of each bar
Indicators Used
Parabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
SAR Color Bar
//+------------------------------------------------------------------+
//|                                                SAR Color Bar.mq4 |
//+------------------------------------------------------------------+
#property copyright "Kalenzo Code adapted by cja"
#property link      "http://www.foreksik.prv.pl"

#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 3
#property indicator_width2 3
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_maximum 1
#property indicator_minimum 0

double sarUp[],sarDn[];//buffers
extern double Step = 0.013;
extern double Maximum = 0.2;
extern int Precision = 5;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(0,sarUp);
   SetIndexBuffer(1,sarDn);
  
   
   IndicatorShortName("SAR COLORED Bar");
   SetIndexLabel(0,"SAR Up Channel");
   SetIndexLabel(1,"SAR Down Channel");
   
   SetIndexDrawBegin(0,2);
   SetIndexDrawBegin(1,2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
   for(int i = 0; i<limit ;i++)
   {
      double sar = NormalizeDouble(iSAR(Symbol(),0,Step,Maximum,i),Precision);
      if(sar >= iHigh(Symbol(),0,i)) 
      {
         sarUp[i] = sar;  
         sarDn[i] = 0;
      }
      else
      {
         sarUp[i] = 0;
         sarDn[i] = sar;
      }
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+//+------------------------------------------------------------------+

Comments