Hello, I also had the same issue and I found that if you choose SetBacktestMode( backtestRegularRawMulti ) AB allows you to do what you want, without using Custom backtester. By doing this, as the previous user said "you can never be sure of the order of the trades", but if you are willing to accept this assumption it'll do what you want.
--- In [email protected], "ang_60" <ima_c...@...> wrote: > > > Yes, it is possible, but I had the very same need some time ago and after > some trials I hired a professional programmer (which used to be quite active > on this list) to get the job done. > > Based on my level of AFL skill (not very good, I fear), I found the code > rather complex, requiring extensive use of the Custom Backtester. > It also involves the creation of four "add to composite" files for every > symbol tested, so if you are working with a portfolio, they add up very > quicky. > > If you look backward in the list, you will find other thread on this subject. > The most common answer was to shorten the timeframe of the data(eg use > intraday instead of daily), because when you get two trades on the same bar, > you can never be sure of the order of the trades. > > I tried to make a point, saying that I was perfectly satisfied of the way > Tradestation handles this matter, but - at the end of the day - I had to face > the fact that Amibroker has not coded the same assumption. > > > > > > > --- In [email protected], "rob.d101" <rob.d101@> wrote: > > > > I have a very simple set of rules where I go long (and cover if short) > > above the high of the previous bar and I go short (and sell if long) below > > the low of the previous bar. The problem is when I have a outside bar, I > > need to take two trades inside of one bar. So far I have not found anyway > > inside AB AFL that will allow me to do this. Is it possible? > > > > Buy = Sell = Short = Cover = 0; > > MP = 0; > > > > for (i=1; i < BarCount; i++) > > { > > SetBacktestMode(backtestregularraw); > > > > if ( BarType[i] < 3 ) // Normal bar or outside bar with down close > > { > > > > if ( BuySignal[i] ) > > { > > if (MP == -1) { Cover[i] = 1; } else Cover[i] = 0; > > Buy[i] = True; > > MP = 1; > > } > > if ( SellSignal[i] ) > > { > > if (MP == 1) { Sell[i] = 1; } else Sell[i] = 0; > > Short[i] = True; > > MP = -1; > > } > > } > > else if (BarType[i] == 3) // Outside up bar > > { > > if ( SellSignal[i] ) > > { > > if (MP == 1) { Sell[i] = 1; } else Sell[i] = 0; > > Short[i] = True; > > MP = -1; > > } > > if ( BuySignal[i] ) > > { > > if (MP == -1) { Cover[i] = 1; } else Cover[i] = 0; > > Buy[i] = True; > > MP = 1; > > } > > } > > } > > >
