s.th that is equal is not reconized as equal ??

 

Hi,

I am sorry for this rather ridiculous piece of code - but it drives me crazy.

To save mainly backtest time I want to execute a function only once with in a bar not every tick so I wrote:

// PERs[] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, ...
// pSET[per][sys] <= {0,0,1,0,..  => pSET[2][sys] = 1 anything else = 0
static int n=0;
for(per=0;per<9;per++) {

        if( pSET[per][sys] == 0 ) continue; //  this continue works!!
        // per must be 2 now

        t = iTime( NULL, PERs[per], 0); // open time of the currecnt 15m-candle
        if( lstOPN[per] == t ) continue; // THIS continue DOES NOT WORK and I don't understand why???
        // here a new candle with its first tick - or not?
        // first I had, but this didn't do it either:
        // if( (pSET[per][sys] == 0) || (lstOPN[per] == iTime( NULL, PERs[per], 0)) ) continue;

        lstOPN[per] = t; // set the new OPEN-time
        n++; // count every bypass
        calcME(per); // calc but lony once in 15 min
}

The first continue: if ( ..[sys] == 0) continue; works perfectly!!

The second does not, what ever I try?? On every new tick the second if .. continue; is passed as if lstOPN[per] would NOT be equal t?

I stamped all that on the screen with TimeToStr( x, TIME_SECONDS) and I see that t and lstOPN[per] DO show exactly the same time e.g. 22:15:00,
while TimeCurrent() (as well priinted) shows 22:17:23 and then 22:17:33, 22:17:36 and so on and my 'brach-counter' count2 continously up each new tick???

Even if I print out on my screen the pure integer-values of the times: lstOPN[per] shows the same value as t (1328472900 for 20:15:00 (backtest!) while TimeCurrent() has 1328473150,
so the second if (.. == t ) continue; is passed and the next iteration is not called.

What the hell I do wrong, where broke my brain?

I thank you very much in advance for any help out of this trap.

Gooly

 
  1. gooly:

    To save mainly backtest time I want to execute a function only once with in a bar not every tick

    void function(){
       static datetime Time0; if (Time0 == Time[0]) return; Time0 = Time[0];
       :

  2. if( lstOPN[per] == t ) continue; // THIS continue DOES NOT WORK and I don't understand why???
            // here a new candle with its first tick - or not?
    Do you have history for the other timeframes? Also remember you can't get other data in the tester for other timeframes.
 
gooly:

Hi,

I am sorry for this rather ridiculous piece of code - but it drives me crazy.

...

What the hell I do wrong, where broke my brain?

I thank you very much in advance for any help out of this trap.

Gooly

I can't see a specific error, but then again the declaration of the variable may be the problem. Try posting a piece of compilable code so the variable types can be checked. (For example if lstOpen[] is defined as double that might be a problem.)
 
WHRoeder:
  1. gooly:

    To save mainly backtest time I want to execute a function only once with in a bar not every tick


  2. Do you have history for the other timeframes? Also remember you can't get other data in the tester for other timeframes.

hmm, I read:
Zero bar of another timeframe for the same symbol under test is modeled approximately

Open = correct Open, Close = correct Close, Low = min (Open,Close), High = max (Open,Close), Volume = final Volume (false)

Actually I am not trying to get data from other timeframes - at the moment the timeframe of the backtest (visual mode) is the same as the one selected by PERs[per] = m15.

But, thanks, I didn't know this, I'll be aware of this!

 
gooly:

Actually I am not trying to get data from other timeframes - at the moment the timeframe of the backtest (visual mode) is the same as the one selected by PERs[per] = m15.


By "other timeframe" WHR means "different to the chart time frame". If you were using the chart timeframe then you would simply use Period.
Reason: