Tomasz, I think that NEVER is too strong a warning here. The following seems perfectly valid for current day limit order entries and next day open exits:
SetTradeDelays(0, 1, 0, 0); Setup = ...; Limit = Ref(Close, -1) * 0.95; BuyPrice = Min(Open, Limit); Buy = Ref(Setup, -1) AND Low <= BuyPrice; Sell = Cross(Close, ...); SellPrice = Open; I believe that the above will backtest just fine. The advantage is that it can also be run as a nightly exploration for generating a list of next day limit entries and next day open exits, which can then be sent to your broker before the opening bell. e.g. Filter = Setup OR Sell; Your warning about not destroying the sequence is what is important, not whether the values are all the same. Mike --- In [email protected], Tomasz Janeczko <gro...@...> wrote: > > Hello, > > You got it all wrong > 1. You should NEVER use different buy/sell delays in SetTradeDelays. So > either use SetTradeDelays( 0, 0, 0, 0 ) > or use SetTradeDelays( 1, 1, 1, 1 ). > What SetTradeDelays does is internally Ref() the buy or sell array. > If you are using unequal delays (as you did) and buy delay is greater > than sell delay > you could move buy signals AFTER sell signals, destroying original > sequence of events. > 2. trade length includes ENTRY bar, 1st day is ENTRY bar, therefore if > you need to exit at 3rd day > you should use -2 (not -3) in the ref() function call, because bars are > counted: 0, 1, 2. > Then you won't have problem with your "exit date". > 3. Actually the best way to implement n-bar delay is to use ApplyStop > > |ApplyStop( *stopTypeNBar*, *stopModeBars*, 3 );| > > ApplyStop works in ALL BACKTESTER MODES (raw, raw2, rotational) and > regardless of trade delays. > ExRemSpan is *obsolete* and it works only in regular mode, therefore > should be avoided. > > Best regards, > Tomasz Janeczko > amibroker.com > > On 2010-03-09 02:06, Mike wrote: > > > >>> Hi, > >>> > >>> as a workaround it seems that I can cheat AB by setting: > >>> SetTradeDelays(1,1,1,1); > >>> This will move the closing trades to the next bar, but it will result > >>> in a wrong reporting from the backtester, because now the "Exit Date" > >>> for the trade is for instance no longer "day 3" in my example but "day > >>> 4". I still hope anybody has a better idea how to solve this issue ... > >>> > >>> Best regards, > >>> Markus > >>> > >>> --- In [email protected], "markhoff"<markhoff@> wrote: > >>> > >>>> Hi folks, > >>>> > >>>> I have a problem with the backtester. I have a trading system which > >>>> opens all positions on OPEN price and closes all positions CLOSE > >>>> price. Maximum number of positions is set to 1. Now, if I might have > >>>> the situation below: > >>>> > >>>> Day 1 2 3 4 5 > >>>> Trade #1 (A) b...@open------------>s...@close > >>>> Trade #2 (B) b...@open------------>s...@close > >>>> > >>>> Trade #1 with symbol (A) has a SELL signal on day 3 and some other > >>>> symbol (B) has a BUY signal on the same day, and this causes AmiBroker > >>>> to make trade #2 also on day 3. > >>>> But, in fact this is not possible because there is no > >>>> cash available on day 3 to b...@open (because first I must SELL trade > >>>> #1). Therefore, the correct behaviour would be to start trade #2 on > >>>> day 4 after the other position for trade #1 was closed. It seems that > >>>> AB always asumes that the cash for closing positions is available at > >>>> the same bar to start new trades. Please see also the code below. > >>>> > >>>> How can I force AB to consider that cash from a s...@close is not > >>>> available on the same bar? > >>>> > >>>> Thanks in advance and best regards, > >>>> Markus > >>>> > >>>> //--- cut here --- > >>>> Buy = Sell = Short = Cover = False; > >>>> BuyPrice = SellPrice = ShortPrice = CoverPrice = 0; > >>>> SetOption("MaxOpenPositions", 1); > >>>> SetPositionSize(100, spsPercentOfEquity); > >>>> SetTradeDelays(1,0,1,0); > >>>> TradeDays = 3; > >>>> BuyPrice = ShortPrice = Open; > >>>> SellPrice = CoverPrice = Close; > >>>> Buy = ExRemSpan(True, TradeDays); > >>>> Sell = Ref(Buy, -TradeDays); > >>>> //--- cut here --- > >>>> > >>>> > >>> > >> > > > > > > > > ------------------------------------ > > > > **** IMPORTANT PLEASE READ **** > > This group is for the discussion between users only. > > This is *NOT* technical support channel. > > > > TO GET TECHNICAL SUPPORT send an e-mail directly to > > SUPPORT {at} amibroker.com > > > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at > > http://www.amibroker.com/feedback/ > > (submissions sent via other channels won't be considered) > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > http://www.amibroker.com/devlog/ > > > > Yahoo! Groups Links > > > > > > > > > > >
