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

Re: [amibroker] Re: Pyramiding: buy a 2nd time if buy cryteria is reached,



PureBytes Links

Trading Reference Links

Thanks for the note Graham.  To follow up.  Here's what worked for me.
   
  Buy= (Buyconditions) * sigscalein;
  Sell=Sellconditions
   
  InTrade = Flip( Buy, Sell ); // seems to work with OR without
  ScaleIn = ExRem( InTrade AND Buy, Sell );
  Buy = Buy + sigScaleIn * Scalein;
  SetPositionSize( 200, spsPercentOfPosition *( Buy == sigScaleIn ) ); 
   
  I had left out the "ExRem" and "Buy=Buy+sigScaleIn * Scalein".  Definately need those two items.  Curious though, Seems to work fine with or without "Flip".  Is there any reason I should leave it in?
   
  Thanks!
   
  Wade
  

Graham <kavemanperth@xxxxxxxxx> wrote:
          Buy=sigscalein means you are adding to your existing trade
Buy=sigscaleout means you are reducing your existing trade size

Sell will exit the total trade and cannot be used as pyramid exit. Only Buy can be used to scale in and out 


-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com 


  On 15/12/06, wadebullock <wadebullock@xxxxxxxxx> wrote:  Hi there,

I'm also having trouble with this.  So far what works it this:

SetPositionSize( 100/PosQty, spsPercentOfEquity );//original position
buy = ( buyconditions ) * sigscalein;
sell = sellconditions; 

However, as is, this will use the original positionsize formula.  I
want to change that, so I've tried using the SetPositionSize function
to scale in every time I get a buy condition true.  Here's what I've
tried.

SetPositionSize( 50, IIf( Buy == sigScaleIn, spsPercentOfPosition,
spsNoChange ) );

SetPositionSize( 50, spsPercentOfPosition * ( Buy == sigScaleIn ) );

Both of these of course have been changed to sigscalein from 
sigscaleout.  I read in message # 103762 that sigscaleout only
applies to buy.  Does that mean sigscalein only applies to sell?  I
want to increase my position for every time I get a buy signal not
scale out. 

Any help here will be greatly appreciated.

Thanks!

Wade


--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
>
> supistarde 
>
> maxopenpositions limits the number of stocks that can have trades
open
> duiring a backtest
>
> scaling into trades is not affected this setting
> How you define the scaling depends on what you wnat to do 
>
> eg to scale in every time you get a buy condtion true you can
simply write
>
> buy = ( buyconditions ) * sigscalein;
> sell = sellconditions;
>
> alternatively something like this could be used 
>
> buy = buyconditions;
> sell = sellconditions;
> inTrade = flip(buy,sell);
> buy = buy and iif( intrade, sigscalein, 1);
>
> to change the positionsixze for the scalein then you use 
setpositionsize
> function, see examples in help for this
>
> there are a number of methods to achieve the scaling and what you
use
> depends on the conditions for the buys and sells. sometimes straight 
> condition statements are enough, other times you may nbeed to place
them
> into a for loop, or in extreme cases when the scaling is dependant
on the
> results of the first pass backtest then the custom backtest code is 
needed
> (as you are a beginner in AFL I suggest you stay with the simpler
methods
> and build your knowledges of AB and the aFL)
>
> Look through the help files and also search on the archives of this 
group
> for information on writing AFL.
>
> --
> Cheers
> Graham
> AB-Write >< Professional AFL Writing Service
> Yes, I write AFL code to your requirements
> http://www.aflwriting.com
>
> On 16/11/06, Mark H <amibroker@xxx> wrote:
> >
> >  You would need to use the custom backtester (CBT) to do the
position
> > sizing. See amibroker knowledge base for some examples. 
> >
> >
> > ----- Original Message -----
> > *From:* supistarde <supistarde@xxx>
> > *To:* amibroker@xxxxxxxxxxxxxxx
> > *Sent:* Wednesday, November 15, 2006 1:22 PM 
> > *Subject:* [amibroker] Re: Pyramiding: buy a 2nd time if buy
cryteria is
> > reached,
> >
> >  does it not work at amibroker?
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "supistarde" <supistarde@>
wrote:
> > >
> > > Hello community,
> > >
> > > I know how to minimize open positions:
> > > SetOption("maxopenpositions",2); 
> > >
> > > but how does this sigScaleIn work?
> > > I want to buy further stocks if my buy conditions are met a
second
> > > time. The second position should have half the size of the first 
> > > position.
> > > How do I do this?
> > >
> > > Buy = Buy + sigScaleIn * DoScaleIn
> > > How do I link sigscalein to my buy signal?
> > >
> > > Regards, 
> > >
> >
> >
> >
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/ 

For other support material please check also:
http://www.amibroker.com/support.html

Yahoo! Groups Links







  

         

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.20/588 - Release Date: 12/15/2006 10:02 AM