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

[amibroker] Re: Losing Trades in Custom Backtester



PureBytes Links

Trading Reference Links

Mark,

I am doing portfolio level testing. Since I know how many positions, 
I have and my max total positions, all I need to do is find the top 
N (max pos - open pos) positions.

Cey

--- In amibroker@xxxxxxxxxxxxxxx, "Mark H" <amibroker@xxx> wrote:
>
> Cey:
> 
> Are you doing portfolio level testing? If so, how do you sort the 
signals by position score?
> By default, ScaleIn signals are by symbal name.
> Do you have to sort the signal list in your code by the position 
size then? 
> 
> Thanks,
> - Mark
> 
> 
>   ----- Original Message ----- 
>   From: C Alvarez 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Wednesday, August 09, 2006 3:11 PM
>   Subject: [amibroker] Re: Losing Trades in Custom Backtester
> 
> 
>   Mark,
> 
>   I missed the first but saw the second post. I had already coded 
up 
>   Tomasz' suggestion. Since position score is not stored, I stored 
the 
>   information in position size. This seems to work just fine. I am 
>   still checking the code and ouput to make sure it all works fine.
> 
>   Cey
> 
>   --- In amibroker@xxxxxxxxxxxxxxx, "Mark H" <amibroker@> wrote:
>   >
>   > Cey:
>   > 
>   > You may have missed my previous posts. Try:
>   > http://finance.groups.yahoo.com/group/amibroker/message/99788
>   > http://finance.groups.yahoo.com/group/amibroker/message/99785
>   > 
>   > - Mark
>   > ----- Original Message ----- 
>   > From: C Alvarez 
>   > To: amibroker@xxxxxxxxxxxxxxx 
>   > Sent: Tuesday, August 08, 2006 7:16 PM
>   > Subject: [amibroker] Re: Losing Trades in Custom Backtester
>   > 
>   > 
>   > I guess I should read the sample more closely.
>   > From sample page:
>   > "One thing worth mentioning is the fact that since scaling-in 
>   > signals do not store position score this example formula does 
>   not 
>   > support ranking of signals according to user-defined scores."
>   > 
>   > I need the PosScore information, so I will see if I can solve 
>   the 
>   > problem another way.
>   > 
>   > Cey
>   > 
>   > --- In amibroker@xxxxxxxxxxxxxxx, "C Alvarez" <yahoo@> wrote:
>   > >
>   > > More information.
>   > > So the first trade signal has a PosScore but the subsequent 
>   scale 
>   > in 
>   > > signals have PosScore empty.
>   > > 
>   > > Cey
>   > > 
>   > > --- In amibroker@xxxxxxxxxxxxxxx, "C Alvarez" <yahoo@> wrote:
>   > > >
>   > > > Tomasz,
>   > > > 
>   > > > The sample code looks like it will let me do what I want. 
>   The 
>   > > > problem I am now running into is the sig.PosScore is 
empty. 
>   Why 
>   > is 
>   > > > that? I am setting it.
>   > > > 
>   > > > 
>   > > > Thanks,
>   > > > Cey
>   > > > 
>   > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
>   <groups@> 
>   > > > wrote:
>   > > > >
>   > > > > Hello,
>   > > > > 
>   > > > > Answer is here: 
>   http://www.amibroker.com/kb/2006/04/24/using-
>   > > > redundant-signals-for-entries/
>   > > > > 
>   > > > > 
>   > > > > Best regards,
>   > > > > Tomasz Janeczko
>   > > > > amibroker.com
>   > > > > ----- Original Message ----- 
>   > > > > From: C Alvarez 
>   > > > > To: amibroker@xxxxxxxxxxxxxxx 
>   > > > > Sent: Monday, August 07, 2006 10:04 PM
>   > > > > Subject: [amibroker] Losing Trades in Custom Backtester
>   > > > > 
>   > > > > 
>   > > > > I am using the Custom Backtester to iterate through the 
>   > Signal 
>   > > > list. Depending on some additional conditions that I only 
>   can 
>   > know 
>   > > > at this time, I might decide to skip a trade and set the 
>   PosSize 
>   > = 
>   > > > 0. This prevents the trade from happening, as I want.
>   > > > > 
>   > > > > The problem is that if I remove a trade from the Signal 
>   list 
>   > > and 
>   > > > then the Buy array has a buy for the next day, it is not 
>   showing 
>   > > up 
>   > > > the Signal list. And at this time I might want to take the 
>   > trade. 
>   > > > Any suggestions on how I can do this?
>   > > > > 
>   > > > > Here is the simplified code.
>   > > > > 
>   > > > > Thanks,
>   > > > > Cey
>   > > > > 
>   > > > > 
>   > > > > SetCustomBacktestProc("");
>   > > > > 
>   > > > > if( Status("action") == actionPortfolio )
>   > > > > {
>   > > > > bo = GetBacktesterObject();
>   > > > > bo.PreProcess(); // Initialize backtester
>   > > > > 
>   > > > > for(bar=0; bar<BarCount; bar++)
>   > > > > {
>   > > > > 
>   > > > > for( sig = bo.GetFirstSignal(bar); sig; sig 
>   > = 
>   > > > bo.GetNextSignal(bar) )
>   > > > > {
>   > > > > if( sig.IsEntry())
>   > > > > {
>   > > > > if (some_condition) // don't 
>   > > > take trade
>   > > > > {
>   > > > > sig.PosSize = 0;
>   > > > > }
>   > > > > }
>   > > > > }
>   > > > > 
>   > > > > bo.ProcessTradeSignals(bar); // Process current 
>   > bar's 
>   > > > signals
>   > > > > 
>   > > > > }
>   > > > > 
>   > > > > bo.PostProcess();
>   > > > > }
>   > > > >
>   > > >
>   > >
>   >
>