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
This indicator calculates the proximity of the current price to the daily high and daily low using percentage values. The closer the price is to the daily high, the higher the value in the "HighProximityBuffer," and the closer the price is to the daily low, the higher the value in the "LowProximityBuffer." These values can then be used to visualize the proximity of the price to the daily high and low on the chart.
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
// Define indicator buffers
double HighProximityBuffer[];
double LowProximityBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
// Set indicator label
IndicatorShortName("Daily High-Low Proximity");
// Set indicator buffers
SetIndexBuffer(0, HighProximityBuffer);
SetIndexBuffer(1, LowProximityBuffer);
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[])
{
// Calculate daily high and low
double daily_high = High[0];
double daily_low = Low[0];
// Calculate proximity in percentage
double high_proximity = 100.0 * (daily_high - close[0]) / (daily_high - daily_low);
double low_proximity = 100.0 * (close[0] - daily_low) / (daily_high - daily_low);
// Set indicator values in buffers
HighProximityBuffer[0] = high_proximity;
LowProximityBuffer[0] = low_proximity;
return(rates_total);
}
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
-
This indicator calculates the proximity of the current price to the daily high and daily low using percentage values. The closer the price is to the daily high, the higher the value in the "HighProximityBuffer," and the closer the price is to the daily low, the higher the value in the "LowProximityBuffer." These values can then be used to visualize the proximity of the price to the daily high and low on the chart.
Beta Was this translation helpful? Give feedback.
All reactions