Mt5 code MTF supplement

MT5.Boy  

How do I change this code or what should I add to have the option to set MTF? (I would like to set e.g. On time plane H1, if W1/D1/H4/H1/M15/M5/M1 can be set. )

Can someone rewrite it like that, thanks in advance.

//+------------------------------------------------------------------+
//|                                              ڪ MQL5 Source File |
//|                                              Copyright by MT5.Boy |
//|                                               https://xxxxxxx |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_ARROW

//--- input parameters
input ENUM_TIMEFRAMES Timeframe = PERIOD_D1; // MTF time plane selector
//--- indicator buffers

double Arrow[];
color clrCustom = clrRed;


// This variable determines whether the indicator should display on its own chart or on the MN,W1,D1,H4,H1,M15,M5,M1 chart
bool showInMN = true;
bool showInW1 = true;
bool showInD1 = true;
bool showInH4 = true;
bool showInH1 = true;
bool showInM15 = true;
bool showInM5 = true;
bool showInM1 = true;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
#define CHART_ARROW_UP 0
#define CHART_ARROW_DOWN 1
#define CHART_ARROW_COLOR 2

   int ArrowUp = CHART_ARROW_UP;
   int ArrowDown = CHART_ARROW_DOWN;
   int ArrowColor = CHART_ARROW_COLOR;

   ChartSetInteger(0, CHART_ARROW_UP, ArrowUp);
   ChartSetInteger(0, CHART_ARROW_DOWN, ArrowDown);
   ChartSetInteger(0, CHART_ARROW_COLOR, ArrowColor);
   SetIndexBuffer(0, Arrow);
   ChartSetInteger(0, CHART_ARROW_COLOR, clrCustom);

   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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(rates_total <= prev_calculated)
    return(prev_calculated);

  int limit = rates_total - prev_calculated;

  for(int i = 0; i < limit; i++)
  {
    Arrow[i] = close[i];
  }

  // If the indicator should display on the D1 chart
  if (showInD1)
  {
    // ChartSetSymbolPeriod(0, Symbol(), PERIOD_D1);
    ChartSetInteger(0, CHART_ARROW_UP, DRAW_HISTOGRAM);
    ChartSetInteger(0, CHART_ARROW_DOWN, DRAW_HISTOGRAM);
    ChartSetInteger(0, CHART_ARROW_COLOR, clrCustom);
     
  }
  // If the indicator should display on its own chart
  else
  {
    ChartSetInteger(0, CHART_ARROW_UP, DRAW_LINE);
    ChartSetInteger(0, CHART_ARROW_DOWN, DRAW_HISTOGRAM);
    ChartSetInteger(0, CHART_ARROW_COLOR, DRAW_CANDLES);
  }

  return(rates_total);
}
MT5.Boy  
Someone? any comments?
William Roeder  
bool showInMN = true;
bool showInW1 = true;
bool showInD1 = true;
bool showInH4 = true;
bool showInH1 = true;
bool showInM15 = true;
bool showInM5 = true;
bool showInM1 = true;
Unused variables. Implement them.
Carl Schreiber  
MT5.Boy:

How do I change this code or what should I add to have the option to set MTF? (I would like to set e.g. On time plane H1, if W1/D1/H4/H1/M15/M5/M1 can be set. )

Can someone rewrite it like that, thanks in advance.

This is maybe the wrong approach?

  1. Would you like to have a different timeframe than the one of the chart - if no change the tf of the chart.
  2. In an EA you get the values of the indicator by the function iCustom() which you can call with the tf you need - look it up.
Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
iCustom - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
MT5.Boy  
Carl Schreiber #:

This is maybe the wrong approach?

  1. Would you like to have a different timeframe than the one of the chart - if no change the tf of the chart.
  2. In an EA you get the values of the indicator by the function iCustom() which you can call with the tf you need - look it up.

I am sorry, I am a beginner and can not progress further with this.

I would like to write an indicator in MQL5 that, based on one of the timeframes I specify in the input data, calculates the closing value of each candle and marks it with a black arrow symbol 159 wherever the closing value occurs. Can someone write the complete working code for this!

Reason: