This tool is designed to create a dynamic, visual guideline on your trading chart that tracks significant price movements. Its primary purpose is to identify and "lock onto" specific price levels based on a fixed interval that you define.
Core Logic Overview
The indicator operates by establishing a "grid" of value steps. Think of it like a ladder where the distance between each rung is set by the Step parameter. Instead of just showing a static line, the script calculates these levels based on historical price action to ensure the visual aid remains relevant to the current market structure.
How It Works
- Initialization: The script looks back at a large volume of historical data (determined by the CountBars setting) to understand the general price context.
- Establishing the Baseline: It identifies a starting value based on the closing price of the market at that distant point in history. This ensures the "ladder" of steps is properly aligned with the past movement of the asset.
- Dynamic Tracking: As the script moves forward through time toward the current candle:
- It constantly monitors the closing price of each bar.
- If the market price moves up significantly—specifically, if it exceeds the current level by the amount defined in your Step setting—the indicator "steps up" to the next level.
- Conversely, if the price drops significantly enough to fall below the previous level's margin, the indicator "steps down."
- Visual Output: The result is a continuous line on your chart that follows the trend. It doesn't move with every tiny fluctuation; it only shifts when the market makes a meaningful move forward or backward according to your chosen step size.
Practical Application
By using this tool, you can see the "zones" of price movement more clearly. It helps filter out minor market noise and highlights the major structural shifts in price. Because the step distance is customizable, you can adjust it to capture large, sweeping trends or smaller, more frequent fluctuations depending on your specific trading style.
// Step.mq4
// Èíäèêàòîð
#property copyright "mandorr@gmail.com"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_width1 2
#property indicator_style1 0
#property indicator_color1 IndianRed
extern int Step=25; // Øàã
extern int CountBars=10000; // Êîëè÷åñòâî îòîáðàæàåìûõ áàðîâ
double buffer[];
void init() {
IndicatorShortName("Step ("+Step+")");
IndicatorDigits(Digits);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,buffer);
SetIndexLabel(0,"Value");
SetIndexDrawBegin(0,0);
}
void start()
{
int price=MathRound(Close[CountBars-1]/Point);
int value=Step*(price/Step);
for (int i=CountBars-1; i>=0; i--)
{
price=MathRound(Close[i]/Point);
if (price>=value+Step) value=value+Step;
if (price<=value-Step) value=value-Step;
buffer[i]=value*Point;
}
}
Comments