[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: SetTradeDelay & exploration-backtesting different results



PureBytes Links

Trading Reference Links

TJ:

What you say is exactly correct, and I agree 100%. However, what 
about those systems in which you cannot place an order the night 
before? For example, I've been playing around with a stop-based 
system lately that calculates the entry signal based on today's 
opening price. Parameter values are calculated in the evening but for 
application to the next day's opening. In such a case, for 
backtesting purposes, you need to set trade delays to 0 in order to 
accommodate a stop-based system (which means you have to be at your 
computer screen at the open to know what to do). For backtesting, the 
backtester evaluates whether or not the price would have met the 
target criterion based on today's opening price and acts accordingly. 
For example, if the target price is today's opening plus some 
fraction multiplier of a volatility measure based on, say, 
yesterday's range, how else can you backtest it other than with trade 
delays set to 0? 

Al Venosa

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
wrote:
> Hello,
> 
> 1. SetTradeDelay is FOR BACKTESTER, not for exploration.
> 2. Also you must not delay PRICES. Ref( buyprice, something ) is 
wrong. Only signal can be delayed.
> 3. Ref( ) with positive shift references FUTURE not past. The delay 
can be coded usign Ref( array, -1 ).
> Ref( array, 1 ) is incorrect.
> 
> The intention is as follows:
> your EOD system generates signals using close price.
> You run this after trading session close. Via SCAN/EXPLORATION you 
get signals TODAYs evening so you can
> place it for tommorrows open.
> 
> BUT...
> for the BACKTESTING you need to SetTradeDelays( 1, 1, 1, 1)
> so backtester trades on next bar OPEN price (as you trade in 
reality).
> 
> This way SINGLE formula can work BOTH for scan and backtest without 
need to modify anything.
> Just run SCAN / EXPLORE and you get SIGNALS TODAY to place order 
FOR TOMMORROW.
> and you run BACKTEST and it trades next bar (as in reality)
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
>   ----- Original Message ----- 
>   From: Antonio Marra 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Tuesday, March 11, 2003 5:21 PM
>   Subject: [amibroker] SetTradeDelay & exploration-backtesting 
different results
> 
> 
>   Hello,
> 
> 
> 
>   I found useful the code posted by Graham with the message 30344, 
so I have used a part of it for testing and verify how "SetTradeDelay
() function" works.
> 
>   Well, starting an exploration it give me a right buy and sell 
price in the "results" window, but the backtesting don't give the 
same results: the buy and sell prices don't correspond.  
> 
>   This is the code I used (tested on one single stock [BRCM], from 
01/01/2003 to 31/01/2003):
> 
> 
> 
>   //Filter= Buy=Cross(C,EMA(C,10)) OR Cross(EMA(C,10),C);
> 
>   Filter= Buy=DayOfWeek()==1 OR Sell=DayOfWeek()==1;
> 
> 
> 
>   AddColumn(O,"Open",1.2);
> 
>   AddColumn(C,"Close",1.2);
> 
>   AddColumn(O,"Buy",1.2);
> 
>   AddColumn(C,"Sell",1.2);
> 
> 
> 
>   //DELAY manual setting
> 
>   Buy_Delay   = 1;
> 
>   Sell_Delay  = 2;
> 
>   Short_Delay = 1;
> 
>   Cover_Delay = 1;
> 
>   SetTradeDelays(Buy_Delay, Sell_Delay, Short_Delay, Cover_Delay);
> 
> 
> 
>   //Buy=Cross(C,EMA(C,10)); 
> 
>   //Sell=Cross(EMA(C,10),C); 
> 
>   Buy=DayOfWeek()==1;
> 
>   Sell=DayOfWeek()==1;
> 
> 
> 
>   BuyPrice = Ref(O,Buy_Delay);
> 
>   SellPrice = Ref(C,Sell_Delay);
> 
> 
> 
>   AddColumn(Buy_Delay,"Buy Delay",1.0);
> 
>   AddColumn(IIf(Buy==1,BuyPrice,0),"Delayed Buy Price",1.2);
> 
>   AddColumn(Sell_Delay,"Sell Delay",1.0);
> 
>   AddColumn(IIf(Sell==1,SellPrice,0),"Delayed Sell Price",1.2);
> 
> 
> 
> 
> 
>   Then, if I change these conditions
> 
> 
> 
>         Buy = DayOfWeek()==1;
> 
>         Sell= DayOfWeek()==1;
> 
> 
> 
>   with these ones
> 
> 
> 
>         Buy=Cross(C,EMA(C,10));  
> 
>         Sell=Cross(EMA(C,10),C);
> 
> 
> 
>   both the exploration and the backtesting seem to work.
> 
>   What I'm doing wrong ?
> 
> 
> 
>   Thanks for your valuable help.
> 
> 
> 
>   Best Regards
> 
>   Antonio
> 
> 
> 
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>              
>        
>        
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
>   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>   --------------------------------------------
>   Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/