Research Indicator
Download scriptThis tool is designed as a historical data analyzer for the MetaTrader platform. Its primary purpose is to automatically scan your trading chart's history to categorize past price movements into two distinct groups: "up" movements and "down" movements.
How the Logic Works
The script performs a comprehensive review of every completed candle (bar) on your current chart, starting from the very beginning of the available history up to the most recent data point. For every individual candle it examines, it looks at two specific criteria:
- The Previous Candle: It first identifies whether the previous period ended with a price increase or a decrease.
- The Current Candle: It then compares that movement to the current period's performance.
The Counting Process
The script operates on a comparative logic to determine the trend:
- Positive Momentum (Profit): If the market shows a consistent downward move from one candle to the next, or if it demonstrates a specific sequence of price action where the closing price is lower than the opening price following a previous decline, the tool logs this as a "profit" count.
- Negative Momentum (Loss): Conversely, if the price action fails to meet those specific downward criteria—specifically when the current candle closes higher than it opened following a prior increase—it logs this as a "loss" count.
The Final Output
Once the script has finished scanning every single bar on your chart, it compiles all the individual results into a final summary. Instead of showing complex lines or shapes on your screen, it outputs a research report directly into your platform's journal or log window.
This report provides you with two key totals:
- Total Up Days: The cumulative number of times the price moved in an upward direction based on the script's logic.
- Total Down Days: The cumulative number of times the price moved in a downward direction.
Essentially, this is a "research" tool that allows you to quickly audit your historical chart data to see the frequency of upward versus downward price action over a long period of time.
//+------------------------------------------------------------------+
//| Research Indicator.mq4 |
//| Copyright © 2006, Akuma99. |
//| http://www.beginnertrader.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Akuma99."
#property link "http://www.beginnertrader.com"
#property indicator_chart_window
//+------------------------------------------------------------------+
int init()
{
Print ("-- Research underway --");
return(0);
}
int deinit()
{
return(0);
}
int start() {
int counted_bars=IndicatorCounted();
int shift,limit;
int upDay,downDay,profit,loss;
limit = Bars;
for (shift=limit;shift>=0;shift--) {
if (Close[shift+1] < Open[shift+1]) {
if (Close[shift] < Open[shift]) {
profit++;
} else {
loss++;
}
} else if (Close[shift+1] > Open[shift+1]) {
if (Close[shift] < Open[shift]) {
profit++;
} else {
loss++;
}
}
}
Print (" -- START Akuma99 Research Report --");
Print ("Total up days: ",profit," | Total down days: ",loss);
Print (" -- END Akuma99 Research Report --");
return(0);
}
Comments