void compareSignals()
{
int i, shift;
for (shift=shiftN; shift<=shiftK; shift=shift+10)
{
if (iOpen(NULL, StPer,0)-iOpen(NULL, StPer, shift)>=20*Point)
{
for (i=2;i<=22;i++)
{
if (Force(shift, i)==1) ForceResult[(shift-20)/10][i-2]++;
else if (Force(shift, i)==-1) ForceResult[(shift-20)/10][i-2]--;
}
// Alert(i);
}
if (iOpen(NULL, StPer, shift)-iOpen(NULL, StPer,0)>=20*Point)
{
for (i=5;i<=105;i=i+2)
{
if (Force(shift, i)==-1) ForceResult[(shift-20)/10][i-2]++;
else if (Force(shift, i)==1) ForceResult[(shift-20)/10][i-2]--;
}
// Alert(i);
}
}
}
double RadToGrad(double Rad)
{
double pi=3.1415926535;
return(180/pi*Rad);
}
double corner(double forceCurr, double forcePrev, double forcePrevPrev)
{
double corn1, corn2;
corn1=RadToGrad(MathArctan(0.1/MathAbs(forcePrev-forcePrevPrev)));
corn2=RadToGrad(MathArctan(0.1/MathAbs(forceCurr-forcePrev)));
ObjectSetText("my","Угол="+(corn1+corn2)+" градусов");
return(corn1+corn2);
}
extern double corn=45;
int Force(int shift, int Per) // второй экран - стохастика, индекс силы и ADX - если хотя бы двое дают сигнал - совершаем сделку
{
int ball=0;
double forceCurr, forcePrev, forcePrevPrev;
forceCurr=iForce(NULL, Per, 3, MODE_EMA, PRICE_CLOSE, 0+shift);
forcePrev=iForce(NULL, Per, 3, MODE_EMA, PRICE_CLOSE, 1+shift);
forcePrevPrev=iForce(NULL, Per, 3, MODE_EMA, PRICE_CLOSE, 2+shift);
if (forceCurr<0 && forceCurr>forcePrev && forcePrevPrev>forcePrev && MACDsamp()==1)
{
if (corner(forceCurr, forcePrev, forcePrevPrev)<corn) ball++;
}
if (forceCurr>0 && forceCurr<forcePrev && forcePrevPrev<forcePrev && MACDsamp()==1)
{
if (corner(forceCurr, forcePrev, forcePrevPrev)<corn) ball--;
}
if (ball>=1) return(1);
if (ball<=-1) return(-1);
return(0);
}