parallax background

MQL5: [6] Acessando dados de outros Indicadores

MQL5: [5] Estilos e cores
09/11/2017
1IFR,.mq5
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 1
#property indicator_plots   1

#property indicator_label1  "IFR"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDodgerBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

#property indicator_level1 70
#property indicator_level2 30
#property indicator_level3 50

input int      Periodos=14;

double         IFRBuffer[];

int OnInit()
  {
   SetIndexBuffer(0,IFRBuffer,INDICATOR_DATA);
   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[])
  {
   CopyBuffer(iRSI(_Symbol,_Period,Periodos,PRICE_CLOSE),0,0,rates_total,IFRBuffer);

   return(rates_total);
  }
2Sinal IFR.mq5
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3

#property indicator_label1  "Venda"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrTomato
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

#property indicator_label2  "Compra"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1

#property indicator_label3  "IFR"
#property indicator_type3   DRAW_NONE
#property indicator_color3  clrRed
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1

input int      Periodos=14;

double         VendaBuffer[];
double         CompraBuffer[];
double         IFRBuffer[];

int OnInit()
  {
   SetIndexBuffer(0,VendaBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,CompraBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,IFRBuffer,INDICATOR_DATA);

   PlotIndexSetInteger(0,PLOT_ARROW,234);
   PlotIndexSetInteger(1,PLOT_ARROW,233);

   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[])
  {
   CopyBuffer(iRSI(_Symbol,_Period,Periodos,PRICE_CLOSE),0,0,rates_total,IFRBuffer);

   for(int i=1; i<rates_total; i++)
     {
      CompraBuffer[i]=IFRBuffer[i-1]<30 && IFRBuffer[i]>=30 ? low[i]: 0;
      VendaBuffer[i]=IFRBuffer[i-1]>70 && IFRBuffer[i]<=70 ? high[i]: 0;
     }

   return(rates_total);
  }

Deixe uma resposta