This script, titled "Juice," is a custom technical analysis tool designed to visualize market momentum and volatility trends in a separate window on your trading platform. It simplifies complex price movements into a visual histogram that helps traders identify directional strength.
Core Logic and Mechanics
The indicator functions by calculating the relationship between price volatility and a specific predefined threshold. Here is the breakdown of how it processes data:
1. Volatility Measurement
The tool begins by analyzing the "Standard Deviation" of the market over a user-defined period (set by the Periyod variable). Standard deviation is a mathematical way to measure how much prices are swinging away from their average; high values indicate intense movement, while low values indicate stability.
2. The Threshold Filter The script takes this volatility measurement and subtracts a specific "Level" value from it. This creates a baseline—essentially a "gravity point" that the market must overcome to register a significant signal.
- If the volatility minus the level results in a positive number, it suggests upward momentum is exceeding the set threshold.
- If the result is negative, it suggests downward pressure is dominating.
3. Dynamic Adjustments The script contains built-in logic to automatically adjust its sensitivity based on the specific currency pair you are viewing. For example, if you are trading Yen pairs (like USDJPY, EURJPY, or GBPJPY), the script automatically recalibrates its internal "Level" to accommodate the higher price fluctuations typical of those currencies. It also performs a secondary check to refine the level if you are looking at a specific timeframe (the 5-minute chart).
4. Visual Representation (The Histogram) The final output is displayed as a two-colored histogram:
- Green Bars: These appear when the momentum calculation is positive, signaling potential bullish strength.
- Red Bars: These appear when the momentum calculation is negative, signaling potential bearish weakness.
By isolating these movements into a separate window, the script allows you to see whether the current market "heat" is trending in your favor without the visual clutter of the main price chart.
//+------------------------------------------------------------------+
//| Juice.mq4 |
//| Perky_z |
//| http://fxovereasy.atspace.com/index |
//+------------------------------------------------------------------+
#property copyright "perky"
#property link "http://fxovereasy.atspace.com/index"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 FireBrick
//---- indicator parameters
extern int Periyod=7;
extern double Level=0.0004;
//---- indicator buffers
double OsMAUpBuffer[];
double OsMADownBuffer[];
double OsMABuffer[];
double MACDBuffer[];
double SignalBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(5);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexDrawBegin(0,Level);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- 3 indicator buffers mapping
if(!SetIndexBuffer(0,OsMAUpBuffer) &&
!SetIndexBuffer(1,OsMADownBuffer) &&
!SetIndexBuffer(2,OsMABuffer) &&
!SetIndexBuffer(3,MACDBuffer) &&
!SetIndexBuffer(4,SignalBuffer))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Heat("+Periyod+","+Level+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{
//if ( Period != 15) Alert ("Juice Is Recommended for 15 Min Chart only!!");
if (Symbol()=="USDJPY") Level=0.040;
if (Symbol()=="EURJPY") Level=0.040;
if (Symbol()=="GBPJPY") Level=0.040;
int limit,i;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if (Level== 0.0004 && Period()==5)Level=0.0002;
//---- main loop
for(i=0; i<limit; i++)
{
OsMABuffer[i]=iStdDev (NULL,0,Periyod,MODE_EMA,0,PRICE_CLOSE,i)-(Level);
//----
if(OsMABuffer[i]>0)
{
OsMAUpBuffer[i]=OsMABuffer[i];
OsMADownBuffer[i]=0;
}
else if(OsMABuffer[i]<0)
{
OsMADownBuffer[i]=OsMABuffer[i];
OsMAUpBuffer[i]=0;
}
else
{
OsMAUpBuffer[i]=0;
OsMADownBuffer[i]=0;
}
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments