How to prevent trading in Walk Forward

Hello,

In walk forward testing, it will choose the parameters with the highest metrics and trade it in OOS. However, how to prevent trading in OOS if the strategy performs not good .e.g the metrics such as UPI is negative. In other word, I don’t want to trade the strategy if the IS result is loss.

Thank you!!

If your in-sample performance is negative entire trading system should be re-designed in first place.
If even IIS performance is bad no amount of fine tweaking would make it worthwhile.
But answering directly your question you can store any metric from IIS step into static variable and then in OOS step read that variable and decide not to trade at all

if( Nz( StaticVarGet("MyStoredIISMetric") ) < 0 )
{
  Buy = 0; Short = 0; // don't enter any trades
}
1 Like

Hi Tomasz,

Thank you for your reply. My point is that even a profitable strategy there are some periods the strategy fails to identify profitable signal and i don’t want to trade it before showing me again it is still profitable.

Include in optimization a combination that is impossible like Buy when RSI > 100. If all other combinations are negative the impossible one will be 0.

1 Like

@jackcl You want to stop trading your system when it stops working? It sounds like you should read trading literature on “Trading the Equity Curve”.

It is written about all over the internet and in trading books. Some simplistic basic examples
http://www.futuresmag.com/2015/03/16/myths-and-facts-equity-curve-trading

Amibroker specific
https://www.mail-archive.com/amibroker@yahoogroups.com/msg25815.html

1 Like

You may look for global market timing which is better solution to stop trading in bad market times, see this article from KB:
http://www.amibroker.com/kb/2014/09/20/broad-market-timing-in-system-formulas/

1 Like

@quantboy - I think this is has nothing to do with equity curve trading per say. This is just an optimization problem for WFO. Let say you have 5 in-sample periods:

  1. 1000 | Trade System
  2. 900 | Trade System
  3. 800 | Trade System
  4. -100 | DO NOT TRADE
  5. 700 | Trade System

And if we assume that the ‘optimization target’ is the highest net profit (note: -100 in period 4. though negative can still be the highest ) then @jackcl wants to just stop trading for one period and carry on later when the system will generate positive returns ( or any other optimization metric ).
In that case then @Tomasz advise is the way to go - but with few more tweaks.

  1. One has recognized in-sample runs ( search the yahoo forum )
  2. Store the highest opt. target ( in sample ) in static var with a flag x > 0 in the buy statment when the first WF run is being made.
  3. Reset the static variable when a new in-sample run is executed and repeat step 1.

Just my opinion. Hope it helps.

1 Like