mikko_painmeter2
Download scriptThe Mikko PainMeter is a specialized technical analysis tool designed to measure market sentiment by calculating the psychological "stress" or "pain" experienced by different sides of a trade (buyers and sellers). Rather than looking at simple price movements, it focuses on the cumulative pressure within a specific window of time to identify potential turning points in the market.
Core Logic and Mechanics
1. Sentiment Calculation (Pain/Ecstasy) The script examines historical price data over a user-defined period (the "count"). For every new candle, it compares the current price against previous prices within that window.
- Bullish Pain: It calculates how much potential profit is being lost or how much pressure is building against the buyers.
- Bearish Pain: It tracks the pressure exerted against sellers. By aggregating these differences over multiple steps, the indicator creates a "Pain Meter" that shows which side of the market is currently under the most stress.
2. The Difference and Smoothing (Moving Average) The indicator then calculates the net difference between Bearish and Bullish pain. This raw data can be volatile, so the script applies a Moving Average to smooth out the noise. This smoothed line represents the overall prevailing "sentiment" of the market. When the sentiment shifts rapidly from one extreme to another, it often suggests that the current trend is becoming overextended.
3. Signal Identification (Arrows) The indicator automatically places visual markers (arrows) on the chart based on specific momentum shifts:
- Buy Signals: These occur when the smoothed sentiment line reaches a significant "valley" or local minimum and begins to curl upward, suggesting that the bearish pressure has peaked and buyers may be regaining control.
- Sell Signals: These appear when the sentiment line reaches a significant "peak" or local maximum and begins to turn downward, indicating that bullish exhaustion has occurred and sellers may be taking over.
4. Symmetry Tracking Additionally, the script calculates a "symmetry" value. This measures the rate of change in the smoothed sentiment. It helps in understanding the velocity at which market sentiment is shifting, providing a clearer picture of whether a move is accelerating or stabilizing.
Summary for the User
In essence, this tool acts as a psychological map of the market. Instead of just telling you where the price is, it tries to show you how "stressed" the participants are. By identifying moments where extreme emotional pressure (pain) reaches a breaking point and begins to reverse, the indicator aims to highlight high-probability areas for potential trend changes.
//+------------------------------------------------------------------+
//| MinMax indicator |
//| Mikko |
//| |
//+------------------------------------------------------------------+
#property copyright "Mikko"
#property link "noneOfYOurBusiness"
#property indicator_separate_window
//#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Gray
#property indicator_color4 White
#property indicator_color5 Yellow
#property indicator_color6 Orange
#property indicator_color7 YellowGreen
double bullPain[];
double bearPain[];
double painDiff[];
double painMA[];
double buy[];
double sell[];
double symmetry[];
extern int ma = 30;
extern int count = 60;
extern int arrowPeak = 150;
extern int step = 1;
extern int mamode = MODE_LWMA;
extern int symmetryCount = 5;
/*
extern int count2 = 50;
extern int step2 = 1;
extern double multiplier2 = 2;
extern int count3 = 100;
extern int step3 = 1;
extern int multiplier3 = 3;
*/
int init() {
IndicatorBuffers(7);
SetIndexBuffer(0, bullPain);
SetIndexStyle(0, DRAW_LINE, EMPTY, 1);
SetIndexBuffer(1, bearPain);
SetIndexStyle(1, DRAW_LINE, EMPTY, 1);
SetIndexBuffer(2, painDiff);
SetIndexStyle(2, DRAW_LINE, EMPTY, 1);
SetIndexBuffer(3, painMA);
SetIndexStyle(3, DRAW_LINE, EMPTY, 1);
SetIndexBuffer(4, buy);
SetIndexStyle(4, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(4, SYMBOL_ARROWUP);
SetIndexBuffer(5, sell);
SetIndexStyle(5, DRAW_ARROW, EMPTY, 1);
SetIndexArrow(5, SYMBOL_ARROWDOWN);
SetIndexBuffer(6, symmetry);
SetIndexStyle(6, DRAW_HISTOGRAM, EMPTY, 1);
IndicatorShortName("Mikko PainMeter "+count+"/"+ma);
//SetIndexDrawBegin(0, 0);
return(0);
}
int deinit() {
return(0);
}
int start() {
int counted_bars=IndicatorCounted();
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
int limit = Bars - counted_bars;
double move;
int j;
for(int i = limit; i >= 0; i--) {
move = 0;
bullPain[i] = 0;
bearPain[i] = 0;
painMA[i] = 0;
int k;
for(k=0; k<count; k+=step) {
j = i+k;
double jval = (High[j]+Low[j]+Close[j]*2)/4;
double nowval = (High[i]+Low[i]+Close[i]*2)/4;
// volume does not represent deal count!
double multiplier = 1;
/** Pain/ecstacy of loss for each step **/
bullPain[i] += (jval-nowval)*multiplier;
bearPain[i] += (nowval-jval)*multiplier;
/** Pain of gaining something and not cashing at the high point or
perfect entry ecstacy **/
/*
int highPos = iHighest(Symbol(),0,MODE_HIGH,k,i);
int lowPos = iLowest(Symbol(),0,MODE_LOW,k,i);
if(High[highPos] > nowval)
bullPain[i] += High[highPos]-nowval;
if(Low[lowPos] < nowval)
bearPain[i] += nowval-Low[lowPos];
*/
painDiff[i] = bearPain[i]-bullPain[i];
}
}
for(i=limit; i>=0; i--) {
painMA[i] = iMAOnArray(painDiff, 0, ma, 0, mamode, i);
//Print(painMA[i+1]+"["+i+"]("+arrowPeak+") < "+painMA[ArrayMinimum(painMA, arrowPeak, i+2)]+"["+ArrayMinimum(painMA, arrowPeak, i+2)+"]");
/*
if(bearPain[i] > bullPain[i] &&
bearPain[i] < bearPain[i+1] && bearPain[i+1] > bearPain[i+2]) {
if(bearPain[i+1] > bearPain[ArrayMinimum(bearPain, arrowPeak, i+2)])
{
buy[i] = bearPain[i];
}
}
if(bearPain[i] < bullPain[i] &&
bullPain[i] < bullPain[i+1] && bullPain[i+1] > bullPain[i+2]) {
if(bullPain[i+1] > bullPain[ArrayMaximum(bullPain, arrowPeak, i+2)])
{
sell[i] = bullPain[i];
}
}
*/
if(painMA[i] > painMA[i+1] && painMA[i+1] < painMA[i+2]) {
if(painMA[i+1] < painMA[ArrayMinimum(painMA, arrowPeak, i+2)]) {
buy[i] = painMA[i];
}
}
if(painMA[i] < painMA[i+1] && painMA[i+1] > painMA[i+2]) {
if(painMA[i+1] > painMA[ArrayMaximum(painMA, arrowPeak, i+2)]) {
sell[i] = painMA[i];
}
}
// calculate symmetry for this Point
symmetry[i] = (painMA[i]-painMA[i+1])*3;
}
return(0);
}
double dist(double a, double b) {
if(a > b)
return(a-b);
else
return(b-a);
}
Comments