I'm using CSS 1.06. When I compare CSS $ from GPF (with sunday candle) with HotForex or FxPro (without sunday candle) result are differents (ex. -0.11 instead of -0.32 ).
In GetSlope code, you skip well sunday candle, but not in calcTmaTrue() and CalcPrevTrue(). You use a loop for the last 20 bars...where there are Sunday candles ! I have try with 24 (4 sunday in 20 days) and the result is OK.
Could you have a look and confirm.
Philippe
Code: Select all
double GetSlope(string symbol, int tf, int shift)
{
double dblTma, dblPrev;
int shiftWithoutSunday = shift;
if ( addSundayToMonday && sundayCandlesDetected && tf == PERIOD_D1 )
{
if ( TimeDayOfWeek( iTime( symbol, PERIOD_D1, shift ) ) == 0 ) shiftWithoutSunday++;
}
double atr = iATR(symbol, tf, 100, shiftWithoutSunday + 10) / 10;
double gadblSlope = 0.0;
if ( atr != 0 )
{
if ( ignoreFuture )
{
dblTma = calcTmaTrue( symbol, tf, shiftWithoutSunday );
dblPrev = calcPrevTrue( symbol, tf, shiftWithoutSunday );
}
else
{
dblTma = calcTma( symbol, tf, shiftWithoutSunday );
dblPrev = calcTma( symbol, tf, shiftWithoutSunday + 1 );
}
gadblSlope = ( dblTma - dblPrev ) / atr;
}
return ( gadblSlope );
}Code: Select all
//+------------------------------------------------------------------+
//| calcTmaTrue() |
//+------------------------------------------------------------------+
double calcTmaTrue( string symbol, int tf, int inx )
{
return ( iMA( symbol, tf, 21, 0, MODE_LWMA, PRICE_CLOSE, inx ) );
}
//+------------------------------------------------------------------+
//| calcPrevTrue() |
//+------------------------------------------------------------------+
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 );
}