Different Backtest Results depending on visual or non-visula mode?

 
Hi
I am backtesting my EA in 15min timeframe and I get different results just because I backtest once in visual mode and once in non visual modes?

Everything(!) stays the same only the “Visual mode” of the Strategy Tester is either enabled or disabled?
The Stops and Targets of the 19 to 20 trades are between 50 and 80 pips so it cannot be an issue of slippage.
The results are reproducible for me.

non Visual mode:

Bars in test 140834 Ticks modelled 66890736 Modelling quality 99.00%
Total net profit -3.11 Gross profit 68.35 Gross loss -71.46
Total trades 19 Short positions (won %) 19 (47.37%) Long positions (won %) 0 (0.00%)

Visual mode:
Bars in test 140834 Ticks modelled 66890736 Modelling quality 99.00%
Total net profit 66.86 Gross profit 106.22 Gross loss -39.36
Total trades 20 Short positions (won %) 9 (77.78%) Long positions (won %) 11 (72.73%)


Visual mode:         20 Trades   9 short, 11 long
Non-Visual mode: 19 Trades 19 short,   0 long.

Any ideas about the reason and how to get the same results?
Thanks in advance

Gooly

 
gooly:
Hi
I am backtesting my EA in 15min timeframe and I get different results just because I backtest once in visual mode and once in non visual modes?

Everything(!) stays the same only the “Visual mode” of the Strategy Tester is either enabled or disabled?

What was the Spread for each run ?  do you use any Objects in your code and use them to determine when to place or exit trades ?
 
RaptorUK:
What was the Spread for each run ?  do you use any Objects in your code and use them to determine when to place or exit trades ?


Spread is about 0.5 pip, no objects.

I think that may be this indicator https://www.mql5.com/en/code/7157 (i-FractalsEx) may caused this as this determines whether to trade short or long.

my code to get its values:

double qFrac[3];
#define OP_DIR 2
...
int setFrac( int i=0 ) {
        while(i<100) {
                double hi = iCustom(Symbol(), chartFrac, "i-FractalsEx", 6, 500, 0, i);  // 6, 500 are its standard values
                double lo = iCustom(Symbol(), chartFrac, "i-FractalsEx", 6, 500, 1, i); 
                if (hi > 0.0) {
                        qFrac[OP_SELL] = hi; // OP_SELL = 1
                        qFrac[OP_DIR]  = -1.0; // 0
                        if (qFrac[OP_BUY]> 0.0) return(OP_SELL);
                } else if (lo > 0.0) {
                        qFrac[OP_BUY]  = lo; // OP_BUY = 0
                        qFrac[OP_DIR]  = 1.0; // 0
                        if (qFrac[OP_SELL] > 0.0) return(OP_BUY);       
                }
                i++;
        }
        return(-1);
}

...

start() {
     if ( qFrac[OP_DIR] > 0.0 ) {// buy ..}
     if ( qFrac[OP_DIR] < 0.0 ) {// sell ..}
....
}

Any ideas?

Gooly


	          
 
gooly:

Spread is about 0.5 pip, no objects.


About ?  but what was it in reality for each run ?  disconnect from your Broker so the Spread stays the same and do the runs again,  then if the results change you know it isn't related to the Spread.
 

Even if I use the the a little bit different version of i-FractalsEx from that link and changed a bit my function so:

int setFractal( int i=0 ) {
        bool set = false;
        qFrac[OP_SELL] = 0.0;
        qFrac[OP_BUY]  = 0.0;
        while(i<100) {
                double hi = iCustom(SYM, chartFrac, "i-FractalsEx", 6, 6, 0, 4, 500, 1, i); //default values
                double lo = iCustom(SYM, chartFrac, "i-FractalsEx", 6, 6, 0, 4, 500, 1, i); 
                if (hi > 0.0) {
                        qFrac[OP_SELL] = hi; // 0
                        if ( !set ) {
                                qFrac[OP_DIR]  = -1.0; // 0
                                set = true;
                        }
                        if (qFrac[OP_BUY]> 0.0) return(OP_SELL);
                } else if (lo > 0.0) {
                        qFrac[OP_BUY]  = lo; // 0
                        if ( !set ) {
                                qFrac[OP_DIR]  = 1.0; // 0
                                set = true;
                        }
                        if (qFrac[OP_SELL] > 0.0) return(OP_BUY);       
                }
                i++;
        }
        return(-1);
}
 
  1. Spread changed between runs, most likely the difference.
  2. There is no slippage in the tester.
  3. Objects are irrelevant, They aren't really drawn, but testing of them should be is fine.
  4. CI should be fine, unless it looks a Bid, not Close[i], uses Hour(), not TimeHour(Time[i]) things like that.
  5. There is no mind readers here, you need to post ALL the code.
 

I've got it, mea culpa, mea maxima culpa.

I called my (miss-placed) function within an if-branch which was disabled if it should run at highest speed (backtest).

Now I get same results..

Sorry for inconvenieces caused..

Gooly

Reason: