كود:
//+------------------------------------------------------------------+
//|                                                        saged.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

extern int maPeriod = 500;
extern int deviation = 50;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
IndicatorBuffers (0);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 233);
SetIndexShift(0, 0);
SetIndexBuffer (0, High );
SetIndexEmptyValue (0, 0.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 limit = rates_total - prev_calculated;

for (int i= 0; i < limit; i++)
{
double maValue = iMA(NULL,0,maPeriod,0,MODE_EMA,PRICE_CLOSE,i);

if (close[i]< maValue && (maValue - close[i] )> deviation && close[i] < open [i] )

{
  SetIndexArrow (0,233);
  High[i] = maValue;
  }
  
if (close[i]> maValue && ( close[i] - maValue )> deviation && close[i] > open [i] )

{
  SetIndexArrow (0,234);
  High[i] = maValue;

}
}




   
//--- return value of prev_calculated for next call
   return(rates_total);
  }