自動で標準偏差チャネルを描画する処理のMQLコードです。

パラメータの期間(period)で指定した期間無いの最高値と最安値で、単純にチャネルを結びます。

期間の設定によっては最新箇所でチャネルを引かないケースもありますが、方向性の確認として無いよりはマシかなというレベルです。

インジケーターのコードを乗せておきます。
ダウンロードは「 AutoStdDevChannel.mq4」からどうぞ。

//+------------------------------------------------------------------+
//|                                            AutoStdDevChannel.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                     https://fxtrading.greeds.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://fxtrading.greeds.net"
#property version   "1.00"
#property strict
#property indicator_chart_window

input int SERCH_PERIOD=50;
input double DEVIATION=1;
string obj_name = "AUTO_STDDEVCHANNEL";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
  CreateStdChannel();
  return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
  ObjectDelete(obj_name);
}
//+------------------------------------------------------------------+
//| 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[])
{
  if(!isNewBar())
  return 0;
  ObjectDelete(obj_name);
  CreateStdChannel();
  return(rates_total);
}


void CreateStdChannel()
{
  int upperIdx=iHighest(NULL,0,MODE_HIGH,SERCH_PERIOD,1);
  int lowerIdx=iLowest (NULL,0,MODE_LOW ,SERCH_PERIOD,1);
  
  if(upperIdx>lowerIdx)
  {
    int    chart_id = 0;
    ObjectCreate(chart_id,obj_name,
                 OBJ_STDDEVCHANNEL,
                 0,
                 Time[upperIdx],
                 0,
                 Time[lowerIdx],
                 0
                 );
    ObjectSetInteger(chart_id,obj_name,OBJPROP_COLOR,Pink);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_STYLE,STYLE_SOLID);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_WIDTH,1);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_BACK,false);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_SELECTABLE,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_SELECTED,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_HIDDEN,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_ZORDER,0);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_RAY_LEFT,false);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_RAY_RIGHT,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_FILL,false);
    ObjectSetDouble(chart_id,obj_name,OBJPROP_DEVIATION,DEVIATION);
  }
  if(upperIdx<lowerIdx)
  {
    int    chart_id = 0;
    ObjectCreate(chart_id,obj_name,
                 OBJ_STDDEVCHANNEL,
                 0,
                 Time[lowerIdx],
                 0,
                 Time[upperIdx],
                 0
                 );
    ObjectSetInteger(chart_id,obj_name,OBJPROP_COLOR,SkyBlue);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_STYLE,STYLE_SOLID);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_WIDTH,1);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_BACK,false);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_SELECTABLE,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_SELECTED,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_HIDDEN,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_ZORDER,0);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_RAY_LEFT,false);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_RAY_RIGHT,true);
    ObjectSetInteger(chart_id,obj_name,OBJPROP_FILL,false);
    ObjectSetDouble(chart_id,obj_name,OBJPROP_DEVIATION,1.0);
  }
}
bool isNewBar()
{
  static datetime time=Time[0];
  bool ret=false;
  if(Time[0]!=time)
  {
    time=Time[0];
    ret=true;
  }
  return ret;
}