Difference results between tester and Demo account

 

Hi, I am relatively new to this forum and have a problem with one of my EAs that I am currently testing on a Demo account. I have been searching through this and other forums with little success and would most value the experience of you guys on this issue as I dont well understand what´s going on...

My EA uses Pending Stop Orders on 1H timeframe. Setting is exactly the same in the Demo account and in backtesting (except that, obviously, backtesting uses Historic data).

Issue is that in the Demo account, all my Pending orders are executed inmediately like they were market orders, whereas in tester they are executed as expected in theory.

These are the data/chartsw:

A) Demo account results of 1 typical trade.

Date

Price

StopLoss

Exit time

ExitPrice

24113887

2013.09.26 14:00

sell

5.00

gbpusd

1.60287

1.60296

0.00000

2013.09.26 14:00

1.60313

0.00

0.00

0.00

-81.09

Sell Stop Order[sl]

Chart GBPUSD, H1, 2013.09.29 16:10 UTC, Forex Capital Markets, LLC, MetaTrader 4, Demo

B) Tester Results of the same trade

Date Price S/Loss

2013.09.26 14:00 sell stop 27 5.00 1.60286 1.60296

2013.09.26 15:00 sell 27 5.00 1.60286 1.60296

2013.09.26 18:00 close 27 5.00 1.60228 1.60296 Profit +290.00

Chart GBPUSD, H1, 2013.09.29 16:12 UTC, Forex Capital Markets, LLC, MetaTrader 4, Demo

As you can see, the Demo executes the order at the same time as it is placed on 2013.09.26 14:00 at the entry bar (it is meant to enter the trade at 14:00), resulting in a loss. However the tester places the order at 14:00, executes it on the following bar (15:00) and closes it at 18:00, resulting in a profit.

Can you please help

Best wishes

 
Sell price=1.60287 SL=1.60296 Your SL is only 0.9 pips above your entry. What is the spread of your broker and what did you use in the tester?
 

Hi WHRoeder, Thanks

I used 4.4pips spread in tester, which the average this broker is using for this pair in the demo account. I adjusted the stop order price to be above the ask value anyhow for a Pending buy order (to avoid an error or order being below the ask value). The MarketInfo(Symbol(), MODE_STOPLEVEL) instruction revelals that the minimum level above the aks value where you can to place a price was 0 which, as I understand, basically allows you to place your order price just above the ask value for a buy order. I used just one pip above the ask value for the stoploss as I want to keep it tight.

Conditions were the same for tester and Demo, it strikes me though that Demo behavel like this was a market order...

Best

 
alg2013:

Hi WHRoeder, Thanks

I used 4.4pips spread in tester, which the average this broker is using for this pair in the demo account. I adjusted the stop order price to be above the ask value anyhow for a Pending buy order (to avoid an error or order being below the ask value). The MarketInfo(Symbol(), MODE_STOPLEVEL) instruction revelals that the minimum level above the aks value where you can to place a price was 0 which, as I understand, basically allows you to place your order price just above the ask value for a buy order. I used just one pip above the ask value for the stoploss as I want to keep it tight.

Conditions were the same for tester and Demo, it strikes me though that Demo behavel like this was a market order...

Best

Can you Print the Spreads from the Tester and post here?
 

Increase the distance on your stop orders. If you are using a 4 pip distance, and find that your orders are immediately executing without delay, it might be an issue of your stop order being too close to the ASK / SELL price. Change your distance to 50 pips and see if it still does it. I suspect however, it is an issue with slippage and the distance being too close.

 

Ubzen thanks

Here you go; this is the results from the tester on that very trading day:

2013.09.29 21:46:23 2013.09.26 14:00 FrxScretOnStop GBPUSD,H1: BarShift=1 SPREAD=44 orderfreezelevel=0
2013.09.29 21:46:23 2013.09.26 14:00 FrxScretOnStop GBPUSD,H1: Stop_LEVEL=0 ASK=1.6033 Bid=1.6029 PendingPrice=1.6029 StopLoss=1
2013.09.29 21:46:23 2013.09.26 14:00 FrxScretOnStop GBPUSD,H1: open #27 sell stop 5.00 GBPUSD at 1.60286 sl: 1.60296 ok

 

CodeMonkey, thanks. I will change this when the trading sessions begin and will give it a go. However, the issue is still why orders are NOT inmediately executed in the tester as they are in the Demo account, as conditions are just the same. Also, this EA needs very tight SL or wont give any benefits

 
alg2013: However, the issue is still why orders are NOT inmediately executed in the tester as they are in the Demo account.
Are you testing in Every_Tick Mode |or| Open Mode?
 
ubzen:
Are you testing in Every_Tick Mode |or| Open Mode?

 

Ubzen, I am testing Open Mode

 
alg2013: Ubzen, I am testing Open Mode
Well thats the problem then. I tested with the following codes below, in the tester. On the first tick, it placed the sell_stop order and enters the position. The spreads was 5_Pips or 50_Points. EurUsd. StopLevel=0; Therefore, it enters the order but the stoploss is within the spreads [ 1_Pips ]. The log doesn't show the closed order until the next tick.
double sy_spread;
double stoplevel;

void init(){
    sy_spread=MarketInfo(Symbol(),MODE_SPREAD);
    stoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
    Print("sy_spread="+sy_spread);
    Print("stoplevel="+stoplevel);
}

void start(){
    static bool _RanOnce=false; if(_RanOnce) return;
    OrderSend( Symbol(), OP_SELLSTOP, 0.01, Bid, 0, Bid+(Point*10), Bid-(Point*100), "", 0, 0, 0);
    _RanOnce=true;
}

When you test with Open_Mode, it uses only one_tick per hour [in your case]. Anyways, the strategy tester performs as expected, within its Limitations.

-Don't use Pending Orders withing the Strategy_Tester, it doesn't simulate Slippage. And therefore would be mis-leading because it always execute your stop_price exactly, even through a Weekend Gap. This is not how things work in live environment.

-Don't use the strategy_tester for Tick_Sensitive strategies. Looking for stop-loss within 1_Pip is Tick_Sensitive Imo.

-Actual Spreads and Average_Spreads isn't the same thing, Don't use strategy_tester to confirm live results or vice-versa.