MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
//+------------------------------------------------------------------+
//| HistoricoBB.mq5 |
//| Copyright 2011, MetaQuotes Software Corp. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, MetaQuotes Software Corp."
#property link ""
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_minimum -1000
#property indicator_maximum +1000
#property indicator_label1 "Historico de Dias Positivos&Negativos"
#property indicator_type1 DRAW_LINE
#property indicator_color1 Blue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
double Historico[]
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,Historico,INDICATOR_DATA);
return(0);
}
//+------------------------------------------------------------------+
//| 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[])
{
Historico[0] = 0.00;
for (int i= 0; i<rates_total;i++)
{
if (open[i] < close[i])
{
Historico[i] = Historico[i-1] + 1.00;
}
else if(open[i] == close[i])
{
Historico[i] = Historico[i-1];
}
else if (open[i] > close[i])
{
Historico[i] = Historico[i-1] -1.00;
}
}
return(rates_total);
}
please help! it's driving me crazy :) it shows always 0