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

[amibroker] Re: Distorted buy



PureBytes Links

Trading Reference Links

Thanks Steve.  That did the trick. 

A little more digging in the archive yields the following 
interesting code : see message # 34899 done 2/27/03 subject 
line :RE: [amibroker] Exploration and Max Sys DD% Question?

That seems to do it, but is some complicated code which will take a 
bit of sifting through.  I'll leave that for another day.

Stephen




--- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxxx> wrote:
> Hi Stephan,
> 
> The code below will do #'s 1 and 2 - it's getting late now, maybe 
I will try
> to add #3 tomorrow. BTW - on my universe of 1600+ stocks, it only 
returns
> 5 - if you want to be rewarded with a nice long results list, you 
will have
> to lose that "winning attitude"!   : - )
> 
> Steve
> 
> 
> 
> // user defined params
> 
> MinTrades = 10;
> 
> MinPctWinners = 50;
> 
> BestEquity = 0;
> 
> BestRange = 0;
> 
> for( Range = 5; Range < 100; Range++ )
> 
> {
> 
> Buy = Cross( Close, MA( Close, Range ) );
> 
> Sell = Cross( MA( Close, Range ), Close );
> 
> Le = LastValue( Equity() );
> 
> if( Le > BestEquity )
> 
> {
> 
> BestEquity = Le;
> 
> BestRange = Range;
> 
> }
> 
> }
> 
> Buy = Cross( Close, MA( Close, BestRange ) );
> 
> Sell = Cross( MA( Close, BestRange ), Close );
> 
> MyEquity = Equity();
> 
> BuyEquity = IIf( Buy, MyEquity, 0 );
> 
> SellEquity = IIf( Ref( Sell, -1 ), MyEquity, 0 ); // assumes 1 day 
delay
> 
> Profit = IIf( SellEquity, SellEquity - ValueWhen( BuyEquity, 
BuyEquity ),
> 0 );
> 
> Winners = IIf( Profit > 0, 1, 0 );
> 
> Losers = IIf( Profit < 0, 1, 0 );
> 
> NumWinners = Cum( Winners );
> 
> NumLosers = Cum( Losers );
> 
> PctWinners = NumWinners / ( NumWinners + NumLosers ) * 100;
> 
> NumTrades = NumWinners + NumLosers;
> 
> Filter = BarIndex() == BarCount - 1
> 
> AND Equity() > 14000
> 
> AND NumTrades > MinTrades
> 
> AND PctWinners > MinPctWinners;
> 
> AddColumn( BestRange, "Best Range" );
> 
> AddColumn( MyEquity, " My Equity" );
> 
> AddColumn( NumTrades, "Num Trades", 1.0 );
> 
> AddColumn( NumWinners, "Num Winners", 1.0 );
> 
> AddColumn( NumLosers, "Num Losers", 1.0 );
> 
> AddColumn( PctWinners, "Pct Winners" );
> 
> ----- Original Message ----- 
> 
> From: "drsinfla" <drsteph@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, May 18, 2004 10:16 PM
> Subject: [amibroker] Re: Auto optimization
> 
> 
> > Answering my own post here for anyone else who comes along.
> >
> > Regards to question #1 - use the Cum(buy) function to count # of
> > trades.  This works ok for a moving average - may need to use an
> > EXREM(buy) for other systems prone to generating multiple 
signals.
> >
> > Change Filter line to:
> >
> > Filter = (BarIndex() == BarCount - 1) AND Equity()>14000 AND Cum
(buy)
> > >10;
> >
> > & then add a column to see how many trades under the exploration 
at
> > end (last line)
> >
> > AddColumn(Cum(Buy),"number of trades");
> >
> > Jury is still out on #2 -I think it can be done using equity()
> > processing the array itself to get # of up equity trades and # of
> > down equity trades to give me the winners percentage, but haven't
> > figured out how yet.
> >
> > #3, still no clue.
> >
> > Stephen
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "drsinfla" <drsteph@xxxx> 
wrote:
> > > I've been playing around with the for loop optimization done 
under
> > > exploration from a prior 2003 post...
> > >
> > > Wondering how I would add the following criteria to the 
optimized
> > > exploration in this fashion:
> > >
> > > 1.  Only display securities which have >10 trades in the time
> > period
> > > analyzed
> > >
> > > 2.  Only display securities which have >50% winning trades
> > >
> > > 3.  Write a column showing maxDD.
> > >
> > > Any ideas?  Code follows:
> > >
> > > ************************************
> > >
> > > bestequity = 0;
> > > bestrange = 0;
> > >
> > > // optimization loop
> > >
> > > for( range = 5; range < 100; range ++ )
> > > {
> > >
> > >   Buy = Cross( Close, MA( Close, range ) );
> > >
> > >   Sell = Cross( MA( Close, range ), Close );
> > >
> > >  Le = LastValue( Equity() );
> > >
> > >   if( Le > bestequity )
> > >   {
> > >    bestequity = Le;
> > >    bestrange = range;
> > >  }
> > > }
> > >
> > > range = bestrange;
> > >
> > > Buy = Cross( Close, MA( Close, range ) );
> > >
> > > Sell = Cross( MA( Close, range ), Close );
> > >
> > > Filter = (BarIndex() == BarCount - 1) AND Equity()>14000;
> > >
> > > AddColumn( bestrange, "Best range" );
> > >
> > > AddColumn( Equity(), "Best Equity" );
> >
> >
> >
> > 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
> > Yahoo! Groups Links
> >
> >
> >
> >
> >



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 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
     amibroker-unsubscribe@xxxxxxxxxxxxxxx

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