Untitled
unknown
plain_text
5 months ago
2.2 kB
3
Indexable
//+------------------------------------------------------------------+ //| Custom Indicator for Candle Power and Gap Detection | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Green // Green Up Arrow #property indicator_color2 Red // Red Down Arrow double CandlePowerBuffer[]; double ArrowBufferUp[]; double ArrowBufferDown[]; // Initialization function int OnInit() { IndicatorShortName("Candle Power and Gap Indicator"); // Buffers for storing candle power and arrows SetIndexBuffer(0, ArrowBufferUp); SetIndexBuffer(1, ArrowBufferDown); SetIndexArrow(0, 233); // Up Arrow symbol SetIndexArrow(1, 234); // Down Arrow symbol return(INIT_SUCCEEDED); } // Calculation 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 start = prev_calculated > 0 ? prev_calculated - 1 : 0; for (int i = start; i < rates_total; i++) { // 1. Candle Power Calculation (High - Low) double candlePower = high[i] - low[i]; // Display the candle power above/below each candle Comment("Candle Power: ", DoubleToString(candlePower, 2)); // Optional - Display on the chart // 2. Gap Up/Gap Down Arrows if (i > 0) { if (open[i] > close[i-1]) { ArrowBufferUp[i] = low[i] - 10 * Point; // Place green arrow below the candle ArrowBufferDown[i] = EMPTY_VALUE; // No down arrow } else if (open[i] < close[i-1]) { ArrowBufferDown[i] = high[i] + 10 * Point; // Place red arrow above the candle ArrowBufferUp[i] = EMPTY_VALUE; // No up arrow } else { ArrowBufferUp[i] = EMPTY_VALUE; ArrowBufferDown[i] = EMPTY_VALUE; } } } return(rates_total); } //+------------------------------------------------------------------+
Editor is loading...
Leave a Comment