Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+------------------------------------------------------------------+
- //| Tesste CR & MR.mq5 |
- //| Copyright 2019, MetaQuotes Software Corp. |
- //| https://www.mql5.com |
- //+------------------------------------------------------------------+
- #property copyright "Copyright 2019, MetaQuotes Software Corp."
- #property link "https://www.mql5.com"
- #property version "1.00"
- #property indicator_chart_window
- #property indicator_buffers 2
- #property indicator_plots 2
- //--- plot vend
- #property indicator_label1 "vend"
- #property indicator_type1 DRAW_LINE
- #property indicator_color1 clrRed
- #property indicator_style1 STYLE_SOLID
- #property indicator_width1 1
- //--- plot comp
- #property indicator_label2 "comp"
- #property indicator_type2 DRAW_LINE
- #property indicator_color2 clrDarkTurquoise
- #property indicator_style2 STYLE_SOLID
- #property indicator_width2 1
- //--- input parameters
- input string Ativo;
- input int periodo;
- //--- indicator buffers
- double vendBuffer[];
- double compBuffer[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int OnInit()
- {
- //--- indicator buffers mapping
- SetIndexBuffer(0,vendBuffer,INDICATOR_DATA);
- SetIndexBuffer(1,compBuffer,INDICATOR_DATA);
- //---
- 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[])
- {
- //---
- MqlRates rates[];
- int copied=CopyRates(Ativo,0,0,20,rates);
- if(copied<=0)
- Print("Erro ao copiar dados de preços ",GetLastError());
- else Print("Copied ",ArraySize(rates)," bars");
- for (int i=15; i<rates_total; i++)
- {
- double comp = rates[i].open;
- compBuffer[i] = comp;
- }
- //--- return value of prev_calculated for next call
- return(rates_total);
- }
- //+------------------------------------------------------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement