int OnCalculate(const int32_t rates_total,
const int32_t 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 int32_t &spread[])
{
//---
int limit = rates_total - prev_calculated;
for(int i = MathMin(limit + 1, rates_total - 1); i >= 0 && !IsStopped(); i--)
{
bar15 = 1 + iBarShift(_Symbol, PERIOD_M15, time[i]);
bar30 = 1 + iBarShift(_Symbol, PERIOD_M30, time[i]);
bar60 = 1 + iBarShift(_Symbol, PERIOD_H1, time[i]);
bar240 = 1 + iBarShift(_Symbol, PERIOD_H4, time[i]);
CopyBuffer(a15,0,bar15,2,alma15);
CopyBuffer(a30,0,bar30,2,alma30);
CopyBuffer(a60,0,bar60,2,alma60);
CopyBuffer(a240,0,bar240,2,alma240);
CopyBuffer(t1015,0,bar15,2,tsr1015);
CopyBuffer(t1030,0,bar30,2,tsr1030);
CopyBuffer(t1060,0,bar60,2,tsr1060);
CopyBuffer(t10240,0,bar240,2,tsr10240);
CopyBuffer(t2015,0,bar15,2,tsr2015);
CopyBuffer(t2030,0,bar30,2,tsr2030);
CopyBuffer(t2060,0,bar60,2,tsr2060);
CopyBuffer(t20240,0,bar240,2,tsr20240);
a15_1 = alma15[0];
a15_2 = alma15[1];
a30_1= alma30[0];
a30_2= alma30[1];
a60_1= alma60[0];
a60_2 = alma60[1];
a240_1 =alma240[0];
a240_2 = alma240[1];
t1015_2 = tsr1015[1];
t1015_1 = tsr1015[0];
t1030_2 = tsr1030[1];
t1030_1 = tsr1030[0];
t1060_2 = tsr1060[1];
t1060_1 = tsr1060[0];
t10240_2 = tsr10240[1];
t10240_1 = tsr10240[0];
t2015_2 = tsr2015[1];
t2015_1 = tsr2015[0];
t2030_2 = tsr2030[1];
t2030_1 = tsr2030[0];
t2060_2 = tsr2060[1];
t2060_1 = tsr2060[0];
t20240_2 = tsr20240[1];
t20240_1 = tsr20240[0];
score = 0;
dxn = clrGray;
if(a15_1 > a15_2 && t1015_1 > t1015_2 && t2015_1 > t2015_2)
{
score += 10;
}
if(a30_1 > a30_2 && t1030_1 > t1030_2 && t2030_1 > t2030_2)
{
score += 10;
}
if(a60_1 > a60_2 && t1060_1 > t1060_2 && t2060_1 > t2060_2)
{
score += 10;
}
if(a240_1 > a240_2 && t10240_1 > t10240_2 && t20240_1 > t20240_2)
{
score += 10;
}
if(a15_1 < a15_2 && t1015_1 < t1015_2 && t2015_1 < t2015_2)
{
score += -10;
}
if(a30_1 < a30_2 && t1030_1 < t1030_2 && t2030_1 < t2030_2)
{
score += -10;
}
if(a60_1 < a60_2 && t1060_1 < t1060_2 && t2060_1 < t2060_2)
{
score += -10;
}
if(a240_1 < a240_2 && t10240_1 < t10240_2 && t20240_1 < t20240_2)
{
score += -10;
}
color_index = 2;
if(MathAbs(score) > minimum && score > 0)
{
dxn = clrAqua;
}
if(MathAbs(score) < minimum && score < 0)
{
dxn = clrMagenta;
}
if(dxn == clrMagenta)
{
color_index = 0;
}
if(dxn == clrAqua)
{
color_index = 1;
}
ColorBarsBuffer1[i] = iOpen(_Symbol,PERIOD_CURRENT,i);
ColorBarsBuffer2[i] = iHigh(_Symbol,PERIOD_CURRENT,i);
ColorBarsBuffer3[i] = iLow(_Symbol,PERIOD_CURRENT,i);
ColorBarsBuffer4[i] = iClose(_Symbol,PERIOD_CURRENT,i);
ColorBarsColors[i] = colors[color_index];
}
//--- return value of prev_calculated for next call
return(rates_total);
}