This tool, titled "Aggressiveness," is designed to measure the intensity of price movement within a trading chart. Rather than telling you which direction the market is moving (up or down), it focuses purely on the magnitude of the volatility by calculating the average distance traveled per candle.
How it Works
The script analyzes a specific number of recent historical candles (defined by a user-set period) to determine how much "ground" the price covers. Here is the logical breakdown of its process:
- Direction-Neutral Analysis: The logic treats price movement as an absolute value. Whether a candle finishes higher or lower than it started, the script captures the size of that movement. This allows you to see how active the market is, regardless of the current trend.
- Movement Calculation: For every candle within the selected period, the tool identifies the difference between the current closing price and the previous closing price. It adds these distances together to get a total sum of movement for that timeframe.
- Averaging for Consistency: The tool then divides that total sum by the number of candles in your chosen period. This results in an "Average Pips" value, representing the typical distance a price moves during a single candle in the current market environment.
Key Features and Customization
The logic includes several layers of flexibility to suit different trading styles:
- Dynamic Scaling: You can choose how many candles the tool looks back at. A larger number of candles provides a smoother, long-term average of market "aggression," while a smaller number reacts more quickly to sudden changes in volatility.
- Unit Conversion: By default, the tool displays the result in pips (the standard measurement for price movement). However, it can be configured to convert this data into a monetary value based on your specific lot size and account currency, showing you the potential "value" of that price movement in real money.
- Real-Time Updating: The script includes a toggle to decide how it handles the current, unfinished candle. You can choose to have the indicator update instantly with every tiny price tick (Real-time), or have it remain fixed based on the last completed candle for a more stable visual.
In summary, this tool acts as a "speedometer" for the market, helping traders understand how fast or slow the price is moving at any given moment.
//+---------------------------------------------------------------------+
//| Aggressiveness.mq4 |
//| Copyright © Trofimov 2009 |
//+---------------------------------------------------------------------+
//| Àãðåññèâíîñòü |
//| |
//| Îïèñàíèå: Ïîêàçûâàåò ñêîëüêî ïóíêòîâ ïðîõîäèò èíñòðóìåíò |
//| â ñðåäíåì çà îäíó ñâå÷ó, àíàëèçèðóÿ ïîñëåäíèå MyPeriod ïåðèîäîâ |
//| Íåâàæíî â êàêîì íàïðàâëåíèè! |
//| |
//| Àâòîðñêîå ïðàâî ïðèíàäëåæèò Òðîôèìîâó Åâãåíèþ Âèòàëüåâè÷ó, 2009 |
//+---------------------------------------------------------------------+
#property copyright "Copyright © Trofimov Evgeniy Vitalyevich, 2009"
#property link "http://TrofimovVBA.narod.ru/"
//---- Ñâîéñòâà èíäèêàòîðà
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Black
#property indicator_width1 1
//---- Âõîäÿùèå ïàðàìåòðû
extern int MyPeriod=22;
extern double Lot=0; // 0 - â ïóíêòàõ
// >0 - â âàëþòå äåïîçèòà
bool ReDraw=true; //-åñëè âêëþ÷åí, òî ïåðåðèñîâûâàåò íóëåâîé áàð ïðè êàæäîì íîâîì òèêå
// åñëè âûêëþ÷åí, òî íóëåâîé áàð ñîäåðæèò ôèêñèðîâàííîå çíà÷åíèå, âû÷èñëåííîå ïî ïðåäûäóùèì (ãîòîâûì) áàðàì
double Buff_line1[];
//+------------------------------------------------------------------+
//| Ôóíêöèÿ èíèöèàëèçàöèè èíäèêàòîðà |
//+------------------------------------------------------------------+
int init()
{
//---- x äîïîëíèòåëüíûõ áóôåðà, èñïîëüçóåìûõ äëÿ ðàñ÷åòà
IndicatorBuffers(1);
IndicatorDigits(0);
//---- ïàðàìåòðû ðèñîâàíèÿ (óñòàíîâêà íà÷àëüíîãî áàðà)
SetIndexDrawBegin(0,MyPeriod);
//---- x ðàñïðåäåëåííûõ áóôåðà èíäèêàòîðà
SetIndexBuffer(0,Buff_line1);
//---- èìÿ èíäèêàòîðà è ïîäñêàçêè äëÿ ëèíèé
if(Lot==0) {
IndicatorShortName("Aggressiveness("+MyPeriod+"), (pips) = ");
} else {
IndicatorShortName("Aggressiveness("+MyPeriod+"), ("+AccountCurrency()+"·"+DoubleToStr(Lot,2)+") = ");
}
return(0);
}
//+------------------------------------------------------------------+
//| Ôóíêöèÿ èíäèêàòîðà |
//+------------------------------------------------------------------+
int start() {
int limit, RD;
if(ReDraw) RD=1;
// Ïðîïóùåííûå áàðû
int counted_bars=IndicatorCounted();
//---- îáõîäèì âîçìîæíûå îøèáêè
if(counted_bars<0) return(-1);
//---- íîâûå áàðû íå ïîÿâèëèñü è ïîýòîìó íè÷åãî ðèñîâàòü íå íóæíî
limit=Bars-counted_bars-1+RD;
//---- îñíîâíûå ïåðåìåííûå
double B;
//---- îñíîâíîé öèêë
for(int t=limit-RD; t>-RD; t--) {
B=0;
for(int x=t+MyPeriod-1; x>=t; x--) {
if(Close[x]>Open[x]) {
//áåëàÿ ñâå÷à
B=B+(Close[x]-Close[x+1]);
}else{
//÷¸ðíàÿ ñâå÷à
B=B+(Close[x+1]-Close[x]);
}
}//Next x
Buff_line1[t]=B/Point/MyPeriod;
if(Lot>0) Buff_line1[t]=Buff_line1[t]*MarketInfo(Symbol(),MODE_TICKVALUE)*Lot;
if(!ReDraw && t==1) Buff_line1[0]=Buff_line1[1];
}//Next t
return(0);
}
//+------------------------------------------------------------------+
Comments