You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
// Indicator parameters
input int swingLookbackPeriod = 5; // Number of bars to look back for swing detection
// Define indicator buffers
double HighBuffer[];
double LowBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Set indicator short name
IndicatorShortName("Price Swings Oscillator");
// Set indicator labels
SetIndexLabel(0, "High Points");
SetIndexLabel(1, "Low Points");
// Set buffer arrays
SetIndexBuffer(0, HighBuffer);
SetIndexBuffer(1, LowBuffer);
// No additional calculations needed
SetIndexEmptyValue(0, 0);
SetIndexEmptyValue(1, 0);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int lookbackBars = MathMin(swingLookbackPeriod, rates_total);
for (int i = prev_calculated; i < rates_total; i++)
{
HighBuffer[i] = 0;
LowBuffer[i] = 0;
if (i >= lookbackBars - 1)
{
double highestHigh = iHighest(NULL, 0, MODE_HIGH, lookbackBars, i - lookbackBars + 1);
double lowestLow = iLowest(NULL, 0, MODE_LOW, lookbackBars, i - lookbackBars + 1);
if (high[i] > highestHigh && high[i] > high[i - 1])
{
HighBuffer[i] = high[i];
}
if (low[i] < lowestLow && low[i] < low[i - 1])
{
LowBuffer[i] = low[i];
}
}
}
return(rates_total);
}
The Price Swings Oscillator is an indicator designed to identify and visualize potential price swing points in a financial instrument's price chart. It helps traders spot high and low points where the price trend might change direction. The oscillator is based on a user-defined lookback period, which determines the number of past bars considered for swing detection.
Here's how the oscillator works:
For each bar in the chart, the indicator calculates the highest high and lowest low within the specified lookback period.
It then compares the current bar's high with the highest high within the lookback period. If the current bar's high is both higher than the highest high and higher than the previous bar's high, it's identified as a potential high swing point.
Similarly, it compares the current bar's low with the lowest low within the lookback period. If the current bar's low is both lower than the lowest low and lower than the previous bar's low, it's considered a potential low swing point.
The indicator marks these potential swing points on the chart using blue dots for high points and red dots for low points.
In summary, the Price Swings Oscillator helps traders identify potential reversal points in the price trend by highlighting significant high and low swings in the market.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The Price Swings Oscillator is an indicator designed to identify and visualize potential price swing points in a financial instrument's price chart. It helps traders spot high and low points where the price trend might change direction. The oscillator is based on a user-defined lookback period, which determines the number of past bars considered for swing detection.
Here's how the oscillator works:
In summary, the Price Swings Oscillator helps traders identify potential reversal points in the price trend by highlighting significant high and low swings in the market.
Beta Was this translation helpful? Give feedback.
All reactions