TB simulation: FX slippage etc

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
Post Reply
utrading
Contributing Member
Contributing Member
Posts: 5
Joined: Thu Jan 15, 2009 4:22 pm

TB simulation: FX slippage etc

Post by utrading »

Hi,
I am evaluating TB Builder and have quite a few questions.

To get a feel for how easy it is to build some new strategies, I created a simple indicator to signal entry point using stop orders, and use simple moving average as trailing stop.

I wish to simulate the following exit strategy: at the beginning of each day, I have the moving average from previous day, which I wish to use as today's intra-day stop. This means if today's low is below the moving average, I wish to be stopped out. However it seems that the simulator stops me out on the next day, which is not desirable. Does TB support this kind of exit strategy?

When I tested the strategy on major Forex pairs, I also noticed the following: the slippage for exit is huge, usually 50pips for EURUSD, even though I checked "use pips based slippage". Is this slippage normal for EURUSD? I was expecting <=5pips. This 50pips slippage means that while I expect to risk 1% on each trade, the actual risk is much higher (closer to 2% or more).

Thanks and I hope to get some inputs from veterans users here.
sluggo
Roundtable Knight
Roundtable Knight
Posts: 2987
Joined: Fri Jun 11, 2004 2:50 pm

Post by sluggo »

Pretend that Blox software is run right after the close "Today", and generates orders for the trading session "Tomorrow".

From that perspective, I think your trading idea might be expressed in a way such as:
  • Today's moving average will be tomorrow's intra-day stop.
For example: if today is Tuesday, and today's (Tuesday's) moving average is 87.65, then I will place an order for tomorrow's trading session (Wednesday), to exit my position at 87.65 on a Stop. Clearly I need to place this order before the Open of tomorrow's trading session.

Dunno about pips, don't trade Forex, sorry. I >think< the Forex Dictionary has something to do with it ...
LeviF
Roundtable Knight
Roundtable Knight
Posts: 1436
Joined: Mon Dec 22, 2003 12:24 pm
Location: Des Moines, IA
Contact:

Re: TB simulation: FX slippage etc

Post by LeviF »

utrading wrote:
When I tested the strategy on major Forex pairs, I also noticed the following: the slippage for exit is huge, usually 50pips for EURUSD, even though I checked "use pips based slippage". Is this slippage normal for EURUSD? I was expecting <=5pips. This 50pips slippage means that while I expect to risk 1% on each trade, the actual risk is much higher (closer to 2% or more).
Pip-based slippage is defined in the forex dictionary.
Tim Arnold
Site Admin
Site Admin
Posts: 9021
Joined: Tue Apr 06, 2004 1:41 pm
Location: Boston, MA
Contact:

Post by Tim Arnold »

Yes, as sluggo pointed out you can place stop or limit orders for the trading day.

There is a minimum slippage in global parameters you should check, and the regular atr slippage is used for forex as well. So if you only want to use pip based slippage (as set in the forex dictionary) then you should set the other global slippage numbers to zero.
utrading
Contributing Member
Contributing Member
Posts: 5
Joined: Thu Jan 15, 2009 4:22 pm

How to enforce hard stop?

Post by utrading »

Hi,
Thanks all for the reply. Truly helpful.

By making sure to place order at the beginning of each day, now my stop orders, if triggered, do get executed on the same day instead of the next day :D In addition, by setting "use pips based slippage" to FALSE and setting global slippage to 0.5%, I seem to get slips reasonable for FX (5~10 pips). If I set "use pips based slippage" to TRUE, and set global slippage to 0%, I still get ~50pips slippage, don't understand why. This is builder version 2.2.13.

A new question I have is how to enforce hard stop? I understand orders are good for the day only and need to be placed everyday. So I have the following:
Entry script:
broker.enterLongOnStop(stopPrice, protectStop)

Exit script:
'here we have no other stop out mechanism
'only hard stops
hardStop = instrument.unitexitstop
broker.ExitAllUnitsOnStop(hardStop)

However the hard stop doesn't work at all, what am I missing?

Thanks again.
Regards.
cryder
Roundtable Knight
Roundtable Knight
Posts: 101
Joined: Tue Jul 22, 2008 5:02 am
Location: Melbourne, Australia

Post by cryder »

Are you setting a new stop loss value ?

instrument.SetExitStop( new_stop_loss )

Rgds

Craig
Tim Arnold
Site Admin
Site Admin
Posts: 9021
Joined: Tue Apr 06, 2004 1:41 pm
Location: Boston, MA
Contact:

Post by Tim Arnold »

For a single unit system your code should work fine. For multiple units it would not.

Perhaps some PRINT statements would clarify so you can see what is going on. Also a check of the Filtered Trade Log might help as well in case the exits are being rejected.
Post Reply