Indicador de tendencia em varios tempos ao mesmo tempo

 

Bom dia, alguem sabe se existe um indicador que eu possa usar no grafico,por exemplo, de 5 minutos e eu configure este indicador para me informar qual a tendencia em um outro tempo maior, por exemplo, no tempo de 4 h.

A ideia é operar sempre na tendencia do tempo maior, mas,olhando somente o grafico no tempo de 5minutos.

Grato

Ulisses

 
Qual indicador, por exemplo?
É fácil modificar o indicador para que ele esteja em qualquer tempo gráfico, mas relacionado à outro tempo gráfico.
 
Lucas Tavares:
Qual indicador, por exemplo?
É fácil modificar o indicador para que ele esteja em qualquer tempo gráfico, mas relacionado à outro tempo gráfico.

Oi Lucas, acho que nao me expressei direito.

Vi o indicador Trend_all_period, mas ele só funciona no MT4 e gostaria de uma versao para o MT5.

Nao quero ficar toda hora mudando o tempo grafico e analisando, por exemplo, se a media movel menor esta acima ou abaixo da media movel maior.

Este indicador acima, já informa, em uma unica tela, qual a tendencia no tempo maior.

Obrigado.

 
Compreendo.
Quando está lendo um código de um indicador, dentro do parênteses tem tudo que ele fará, e de onde ele puxará as informações :
https://www.mql5.com/pt/docs/indicators/ima
Dá uma olhada na parte que tem o "period". Lá você pode colocar o atual, que irá se adaptar sempre que mudar o tempo gráfico, ou você pode colocar um fixo e compilar, pra salvar a alteração. Experimenta fazer isto com o seu.

O que eu gosto de fazer é colocar "TF" neste local, e nos parametro adicionar o TF como um parametro de "ENUM_TIMEFRAMES " Para que eu possa escolher a qualquer momento o timeframe que será analisado.
Documentação sobre MQL5: Indicadores Técnicos / iMA
Documentação sobre MQL5: Indicadores Técnicos / iMA
  • www.mql5.com
//|                                                     Demo_iMA.mq5 | //|                        Copyright 2011, MetaQuotes Software Corp. | //|                                            ;https://www.mql5.com | "O método de criação do manipulador é definido através do parâmetro "type" (tipo de função...
 
Lucas Tavares:
Compreendo.
Quando está lendo um código de um indicador, dentro do parênteses tem tudo que ele fará, e de onde ele puxará as informações :
https://www.mql5.com/pt/docs/indicators/ima
Dá uma olhada na parte que tem o "period". Lá você pode colocar o atual, que irá se adaptar sempre que mudar o tempo gráfico, ou você pode colocar um fixo e compilar, pra salvar a alteração. Experimenta fazer isto com o seu.

O que eu gosto de fazer é colocar "TF" neste local, e nos parametro adicionar o TF como um parametro de "ENUM_TIMEFRAMES " Para que eu possa escolher a qualquer momento o timeframe que será analisado.

Lucas,

Infelizmente não sou programador .. :( .. assim, não entendi muito o que voce disse.

Obg

 
Qual indicador você quer usar com tf travado?
Se for este do mt4 e você quer para o Mt5, a solução é abrir um pedido no Freelance.
Se for algum indicador que já você já está usando e está gostando, diz qual é que eu faço a versão com tf travada.
 
Lucas Tavares:
Qual indicador você quer usar com tf travado?
Se for este do mt4 e você quer para o Mt5, a solução é abrir um pedido no Freelance.
Se for algum indicador que já você já está usando e está gostando, diz qual é que eu faço a versão com tf travada.

Lucas,

Quero usar 2 medias moveis no tempo de 5 min, mas, que elas indiquem a tendência num tempo maior, por exemplo, 4h.

A ideia é colocar uma media de 200 e uma media de 365 no gráfico de 4h.

A análise seria :

Se a media de 200 estiver acima da media de 365, então a tendência é de alta

Se estiver abaixo a tendência é de baixa.

Daí, eu vou no gráfico de 5min e só abro operações comprando (se M200 acima de M365 no TF 4h) ou vendendo (se M200 abaixo de M365 no TF 4h).


O ruim é ficar toda hora mudando o TF do gráfico de 5min para 4h.


Obg

 
Você quer então um indicador de média móvel "travado" em 4h.
Irei fazer ele, você só joga no gráfico e escolhe o valor da média.
 

Isso mesmo.

mas teria como o TF não ser travado?

Obg

 

Achei um modelo que tem exatamente o que você quer, nem precisei alterar nada.

Aqui, neste artigo do próprio mql5, que explica o funcionamento do iMA, que é uma função que invoca a Média móvel, ele dá um exemplo de um código que apenas invoca a média móvel, mas que tem no parâmetro exatamente o que você quer, a opção de escolher o Timeframe.

https://www.mql5.com/en/docs/indicators/ima

Vou te ensinar a fazer isto sem precisar "ser um programado", coisa que também não sou, sou apenas curioso e auto didata.
no Mt5, aperta F4, vai abrir o metaquotes. Aperte CTRL+N, novo projeto de indicador.
Dê o nome que quiser para seu indicador, de next, e tanto faz o que colocar, quando abrir a janela com o texto pra digitar, apague tudo e cole isto :

//+------------------------------------------------------------------+
//|                                                     Demo_iMA.mq5 |
//|                        Copyright 2011, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description "The indicator demonstrates how to obtain data"
#property description "of indicator buffers for the iMA technical indicator."
#property description "A symbol and timeframe used for calculation of the indicator,"
#property description "are set by the symbol and period parameters."
#property description "The method of creation of the handle is set through the 'type' parameter (function type)."
#property description "All other parameters like in the standard Moving Average."
 
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- the iMA plot
#property indicator_label1  "iMA"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//+------------------------------------------------------------------+
//| Enumeration of the methods of handle creation                    |
//+------------------------------------------------------------------+
enum Creation
  {
   Call_iMA,               // use iMA
   Call_IndicatorCreate    // use IndicatorCreate
  };
//--- input parameters
input Creation             type=Call_iMA;                // type of the function 
input int                  ma_period=10;                 // period of ma
input int                  ma_shift=0;                   // shift
input ENUM_MA_METHOD       ma_method=MODE_SMA;           // type of smoothing
input ENUM_APPLIED_PRICE   applied_price=PRICE_CLOSE;    // type of price
input string               symbol=" ";                   // symbol 
input ENUM_TIMEFRAMES      period=PERIOD_CURRENT;        // timeframe
//--- indicator buffer
double         iMABuffer[];
//--- variable for storing the handle of the iMA indicator
int    handle;
//--- variable for storing
string name=symbol;
//--- name of the indicator on a chart
string short_name;
//--- we will keep the number of values in the Moving Average indicator
int    bars_calculated=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- assignment of array to indicator buffer
   SetIndexBuffer(0,iMABuffer,INDICATOR_DATA);
//--- set shift
   PlotIndexSetInteger(0,PLOT_SHIFT,ma_shift);   
//--- determine the symbol the indicator is drawn for  
   name=symbol;
//--- delete spaces to the right and to the left
   StringTrimRight(name);
   StringTrimLeft(name);
//--- if it results in zero length of the 'name' string
   if(StringLen(name)==0)
     {
      //--- take the symbol of the chart the indicator is attached to
      name=_Symbol;
     }
//--- create handle of the indicator
   if(type==Call_iMA)
      handle=iMA(name,period,ma_period,ma_shift,ma_method,applied_price);
   else
     {
      //--- fill the structure with parameters of the indicator
      MqlParam pars[4];
      //--- period
      pars[0].type=TYPE_INT;
      pars[0].integer_value=ma_period;
      //--- shift
      pars[1].type=TYPE_INT;
      pars[1].integer_value=ma_shift;
      //--- type of smoothing
      pars[2].type=TYPE_INT;
      pars[2].integer_value=ma_method;
      //--- type of price
      pars[3].type=TYPE_INT;
      pars[3].integer_value=applied_price;
      handle=IndicatorCreate(name,period,IND_MA,4,pars);
     }
//--- if the handle is not created
   if(handle==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",
                  name,
                  EnumToString(period),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//--- show the symbol/timeframe the Moving Average indicator is calculated for
   short_name=StringFormat("iMA(%s/%s, %d, %d, %s, %s)",name,EnumToString(period),
                           ma_period, ma_shift,EnumToString(ma_method),EnumToString(applied_price));
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
//--- normal initialization of the indicator
   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[])
  {
//--- number of values copied from the iMA indicator
   int values_to_copy;
//--- determine the number of values calculated in the indicator
   int calculated=BarsCalculated(handle);
   if(calculated<=0)
     {
      PrintFormat("BarsCalculated() returned %d, error code %d",calculated,GetLastError());
      return(0);
     }
//--- if it is the first start of calculation of the indicator or if the number of values in the iMA indicator changed
//---or if it is necessary to calculated the indicator for two or more bars (it means something has changed in the price history)
   if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)
     {
      //--- if the iMABuffer array is greater than the number of values in the iMA indicator for symbol/period, then we don't copy everything 
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated>rates_total) values_to_copy=rates_total;
      else                       values_to_copy=calculated;
     }
   else
     {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy=(rates_total-prev_calculated)+1;
     }
//--- fill the iMABuffer array with values of the Moving Average indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArrayFromBuffer(iMABuffer,ma_shift,handle,values_to_copy)) return(0);
//--- form the message
   string comm=StringFormat("%s ==>  Updated value in the indicator %s: %d",
                            TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS),
                            short_name,
                            values_to_copy);
//--- display the service message on the chart
   Comment(comm);
//--- memorize the number of values in the Moving Average indicator
   bars_calculated=calculated;
//--- return the prev_calculated value for the next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Filling indicator buffers from the MA indicator                  |
//+------------------------------------------------------------------+
bool FillArrayFromBuffer(double &values[],   // indicator buffer of Moving Average values
                         int shift,          // shift
                         int ind_handle,     // handle of the iMA indicator
                         int amount          // number of copied values
                         )
  {
//--- reset error code
   ResetLastError();
//--- fill a part of the iMABuffer array with values from the indicator buffer that has 0 index
   if(CopyBuffer(ind_handle,0,-shift,amount,values)<0)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
//--- everything is fine
   return(true);
  }
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- clear the chart after deleting the indicator
   Comment("");
  }     

Depois clique em compilar (F7), pronto, na sua lista de indicadores (CTRL+N) estará o indicador com o nome que você criou. Jogue uma vez no gráfico pra ser a média rápida, configure do jeito que quer, e depois jogue de novo pra ser a lenta.
Boa sorte no aprendizado, qualquer coisa to aqui, só pede ajuda rsrs

Documentation on MQL5: Technical Indicators / iMA
Documentation on MQL5: Technical Indicators / iMA
  • www.mql5.com
//|                                                     Demo_iMA.mq5 | //|                        Copyright 2011, MetaQuotes Software Corp. | //|                                              https://www.mql5.com | "The method of creation of the handle is set through the 'type' parameter (function type...
 

Lucas,


Muito bom .. voce é o cara .. Valeu mesmo.. era isso que eu queria.

Grande abraço


OBS: Estou em Brasíli-DF

abraços.

Razão: