有人能解释一下Flip和ExRem的区别吗

Discussion in 'AmiBroker' started by 小也z, Oct 31, 2012.

  1. RT.....

    guide里的muliple singles are back again是什么意思

    我对比了一下 两个chart 一个用ExRem 一个用Flip 结果是完全一样的
     
  2. 问题是,你要实现什么功能?
    带着实际问题去学某个函数是最容易学的,
    如果两个函数结果都实现你的想法,那也是可能的。
    我从来没用过这两。 :)
     
  3. Espresso兄 我是想去除buy和sell之前的重复信号
    但是这两个函数都能实现 官网的解释看不明白 但我想两者一定是有区别的
    敢问你如果处理重复的信号
     
  4. 简单地说,我没有用到这这两个函数,因为我是用 SetBacktestMode(),
    估计Flip和ExRem是AB的backtester功能还不强的时候(或者说初期)提供的函数,
    看了一下文档,ExRem是去除重复信号(估计是你要的功能),但是Flip却是把去除的信号又恢复(?)

    ExRem - http://www.amibroker.com/guide/afl/exrem.html
    Flip - http://www.amibroker.com/guide/afl/afl_view.php?id=51






    你的最后一个问题,有点复杂,下面详细回答你在回测中的情况。
    你把下面的#1,#2,#3,#4搞懂,就对AB回测得心应手(不过最好准备花至少1,2个月时间吧)
    实战的话,则是另外一回事,在此就省略,不想把战线拉得太长.....

    这涉及到AB的Backtester的三个工作模式(见下面),这3种我都用过,最后发现还是mid-level比较适合,能应付大多数回测要求。除非万不得已,最好不要去碰low-level,控制太灵活,有些东西文档里面都没有说,你要去yahoo groups里面刨,甚至问AB的技术支持或TJ本人。 :)

    这是几篇详细介绍AB回测接口的文章(不过,我建议先把基本的两篇#1,#2看懂了再看#3)
    #1: Back-testing your trading ideas (回测入门)
    http://www.amibroker.com/guide/h_backtest.html

    #2: Back-testing systems for futures contracts(回测进阶,杠杆帐号,点值,保证金)
    http://www.amibroker.com/guide/h_futbacktest.html

    #3: AmiBroker Custom Backtester Interface(定制回测接口,介绍了下面的3个工作模式)
    http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/

    high level : (高层,简单)
    The high-level interface doesn’t allow any customising of the backtest procedure itself. It simply allows custom metrics to be defined for the backtester results display, and trade statistics and metrics to be calculated and examined.

    mid-level level : (中间,提供一定灵活性)
    With the mid-level interface, each trading signal at each bar can be examined and the properties of the signals changed, based on the value of other Signal or Backtester object properties, before any trades are executed for that bar.

    low level : (底层,高级,非常详细地控制)
    The low-level interface provides the most flexibility to control backtester operation. As well as allowing signal properties to be modified, it also allows the entering, exiting, and scaling of trades even if no signal exists.

    处理重复信号,其实是用 SetBacktestMode()比较好,一般第一参数就可以:
    SetBacktestMode( backtestRegular );
    backtestRegular - regular, signal-based backtest, redundant signals are removed as shown in this picture
    [​IMG]

    至于更复杂的,需要使用冗余信号的情况,要仔细看这个:
    #4 - Portfolio-level backtesting (投资组合回测)
    http://www.amibroker.com/guide/h_portfolio.html
     
  5. 多谢 espresso兄的资料

    之前我在yahoo group 里搜到了关于ExRem和Flip的区别 意思大致是说flip是在ExRem的基本上扩展了一个回写的功能 也就是说出现了buy的信号之后如果出现了sell的信号 会把buy到sell之前都填上1 sell的位置填上0

    所以ExRem可以说是去除arr1到attr2之前arr1里面所有重复出现的1

    b n n b n n n s n n b
    1 0 0 0 0 0 0 0 0 1 0 exRem
    1 1 1 1 1 1 1 0 0 0 1 flip

    另外就在刚刚我把stopTypeTrailing的值设为了ATR函数的值 提示我不能用在backtestRegularRawMulti模式上 不知道为何?? 我去掉这个模式就好了
    我一直都是用这个backtest Mode 应该我要保留重复的信号
     
  6. ExRem 只是消除重复信号。
    flip显示当前处于的状态,buy 到下一个sell之间都为1, 从而表明这段时间一直是持仓状态。
     
  7. This is the AFL equivalent to ExRem given by Tomasz Janeczko
    http://finance.groups.yahoo.com/group/amibroker/message/158274

    Code:
    /*ExRem is *very* simple function it just matches Buy with corresponding Sell
    and removes extra signals between. It is NOT necessary for backtesting because
    backtester takes care of it by itself, see
    http://www.amibroker.com/guide/h_portfolio.html
    
    Here is how ExRem is internally coded (note that this is AFL equivalent,
    internal function is written in C++ )*/
    
    function ExRemAFL( BuyTable, SellTable )
    {
    	up = False;
    	result = False;
    
    	for( i = 0; i < BarCount; i++ )
    	{
    		result[ i ] = False
    
    		if( ! up && BuyTable[ i ] )
    		{
    			up = True;
    			result [ i ] = True; // generate True (1) impulse on buy
    		}
    
    		if( up && SellTable [ i ] )
    		{
    			up = False; // reset the flag on first matching sell
    		}
    	}
    
    	return result;
    }