Code: Select all
if ( ignoreFuture )
{
dblTma = calcTmaTrue( symbol, tf, shift );
dblPrev = calcPrevTrue( symbol, tf, shift );
}
...and those calc functions are defined as:
double calcTmaTrue( string symbol, int tf, int inx )
{
return ( iMA( symbol, tf, 21, 0, MODE_LWMA, PRICE_CLOSE, inx ) );
}
double calcPrevTrue( string symbol, int tf, int inx )
{
double dblSum = iClose( symbol, tf, inx + 1 ) * 21;
double dblSumw = 21;
int jnx, knx;
dblSum += iClose( symbol, tf, inx ) * 20;
dblSumw += 20;
for ( jnx = 1, knx = 20; jnx <= 20; jnx++, knx-- )
{
dblSum += iClose( symbol, tf, inx + 1 + jnx ) * knx;
dblSumw += knx;
}
return ( dblSum / dblSumw );
}Then calcPrevTrue weights bar inx with weight 20, bar inx+1 with weight 21, bar inx+2 with weight 20, etc.
That's not an accurate calculation for the previous TMA value. It shouldn't have bar inx with weight 20 in it.
Instead of
dblTma = calcTmaTrue( symbol, tf, shift );
dblPrev = calcPrevTrue( symbol, tf, shift );
why not do this?
dblTma = calcTmaTrue( symbol, tf, shift );
dblPrev = calcTmaTrue( symbol, tf, shift+1 );
That would give dblPrev the accurate previous value of the TmaTrue.