Advertisement
Guest User

teste 0111

a guest
Jan 23rd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.64 KB | None | 0 0
  1. //+------------------------------------------------------------------+
  2. //|                                               Tesste CR & MR.mq5 |
  3. //|                        Copyright 2019, MetaQuotes Software Corp. |
  4. //|                                             https://www.mql5.com |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright 2019, MetaQuotes Software Corp."
  7. #property link      "https://www.mql5.com"
  8. #property version   "1.00"
  9. #property indicator_chart_window
  10. #property indicator_buffers 2
  11. #property indicator_plots   2
  12. //--- plot vend
  13. #property indicator_label1  "vend"
  14. #property indicator_type1   DRAW_LINE
  15. #property indicator_color1  clrRed
  16. #property indicator_style1  STYLE_SOLID
  17. #property indicator_width1  1
  18. //--- plot comp
  19. #property indicator_label2  "comp"
  20. #property indicator_type2   DRAW_LINE
  21. #property indicator_color2  clrDarkTurquoise
  22. #property indicator_style2  STYLE_SOLID
  23. #property indicator_width2  1
  24. //--- input parameters
  25. input string      Ativo;
  26. input int      periodo;
  27. //--- indicator buffers
  28. double         vendBuffer[];
  29. double         compBuffer[];
  30. //+------------------------------------------------------------------+
  31. //| Custom indicator initialization function                         |
  32. //+------------------------------------------------------------------+
  33. int OnInit()
  34.   {
  35. //--- indicator buffers mapping
  36.    SetIndexBuffer(0,vendBuffer,INDICATOR_DATA);
  37.    SetIndexBuffer(1,compBuffer,INDICATOR_DATA);
  38.    
  39. //---
  40.    return(INIT_SUCCEEDED);
  41.   }
  42. //+------------------------------------------------------------------+
  43. //| Custom indicator iteration function                              |
  44. //+------------------------------------------------------------------+
  45. int OnCalculate(const int rates_total,
  46.                 const int prev_calculated,
  47.                 const datetime &time[],
  48.                 const double &open[],
  49.                 const double &high[],
  50.                 const double &low[],
  51.                 const double &close[],
  52.                 const long &tick_volume[],
  53.                 const long &volume[],
  54.                 const int &spread[])
  55.   {
  56. //---
  57.   MqlRates rates[];
  58.    int copied=CopyRates(Ativo,0,0,20,rates);
  59.    if(copied<=0)
  60.       Print("Erro ao copiar dados de preços ",GetLastError());
  61.    else Print("Copied ",ArraySize(rates)," bars");
  62.        
  63.         for (int i=15; i<rates_total; i++)
  64.   {
  65.   double comp = rates[i].open;
  66.    compBuffer[i] = comp;
  67.   }
  68.  
  69.  
  70.  
  71. //--- return value of prev_calculated for next call
  72.    return(rates_total);
  73.   }
  74. //+------------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement