Hope you can help the following code is suppossed to look at the previous 2 bars and compare bar current -2 and bar current -1 and provide values accordingly. But the value change on every tick??
can someone lookat the code and help me to change this as the values should only change on the openening of a new bar ie the comparrision between the two previous bars will then change
thank you
double spd1,spd2,v1,v2;
int limit,vcs;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=50; //Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
spd1 = High[i+1] - Low[i+1];
spd2 = High[i+2] - Low[i+2];
R[i]=0; D[i]=0; S[i]=0; W[i]=0;
v1=iVolume(NULL,0,i+1);
v2=iVolume(NULL,0,i+2);
if ( spd1 > spd2 )
{
if ( v1 < v2 )
{
if ( High[i+1]-Close[i+1] < Close[i+1]-Low[i+1] )
{
vcs=1; Print(vcs);
}
if ( High[i+1]-Close[i+1] > Close[i+1]-Low[i+1] )
{
vcs=2; Print(vcs,);
}
}
if ( v1 > v2 )
{
if ( High[i+1]-Close[i+1] < Close[i+1]-Low[i+1] )
{
vcs=1; Print(vcs);
}
if ( High[i+1]-Close[i+1] > Close[i+1]-Low[i+1] )
{
vcs=-1; Print(vcs,);
}
}
}
if ( spd1 < spd2 )
if ( v1 > v2 )
{
vcs=3; Print(vcs);
}
}
return(vcs);
}
can someone lookat the code and help me to change this as the values should only change on the openening of a new bar ie the comparrision between the two previous bars will then change
thank you
double spd1,spd2,v1,v2;
int limit,vcs;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=50; //Bars-counted_bars;
for(int i=limit; i>=0; i--)
{
spd1 = High[i+1] - Low[i+1];
spd2 = High[i+2] - Low[i+2];
R[i]=0; D[i]=0; S[i]=0; W[i]=0;
v1=iVolume(NULL,0,i+1);
v2=iVolume(NULL,0,i+2);
if ( spd1 > spd2 )
{
if ( v1 < v2 )
{
if ( High[i+1]-Close[i+1] < Close[i+1]-Low[i+1] )
{
vcs=1; Print(vcs);
}
if ( High[i+1]-Close[i+1] > Close[i+1]-Low[i+1] )
{
vcs=2; Print(vcs,);
}
}
if ( v1 > v2 )
{
if ( High[i+1]-Close[i+1] < Close[i+1]-Low[i+1] )
{
vcs=1; Print(vcs);
}
if ( High[i+1]-Close[i+1] > Close[i+1]-Low[i+1] )
{
vcs=-1; Print(vcs,);
}
}
}
if ( spd1 < spd2 )
if ( v1 > v2 )
{
vcs=3; Print(vcs);
}
}
return(vcs);
}