//+------------------------------------------------------------------+
//| Random.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property indicator_chart_window
extern int min = 1;
extern int max = 9;
int Random;
datetime BarTime;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
BarTime = 0;
//---
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[])
{
//---
if(BarTime!=iTime(NULL,PERIOD_D1,0))
{
BarTime = iTime(NULL,PERIOD_D1,0);
Random = MathRand();
while(Random<min) Random*=10;
while(Random>max) Random/=10;
}
Comment("\n min - ",min,"\n max - ",max,"\n Random - ",Random);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+