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

[amibroker] Re: number of bar limit for using for statement



PureBytes Links

Trading Reference Links

I set this up and it is working fine but I have a problem now. 
Sometimes this is giving me too big positions so I need to cap the 
number of stocks my system can buy to for exemple 1% of average 
volume of the stock considered. To do this I need to get the function 
that gives "curent portfolio value".

Equity() gives original portfolio value.

What function should I use?

Regards,
Olivier


--- In amibroker@xxxxxxxxxxxxxxx, "olivier_molongo" 
<olivier_molongo@xxxx> wrote:
> Thank you Al, Thank you Buzz.
> I thought I would never get an answer to this question :) Thanks a 
> lot!
> 
> Olivier
> 
> For those interested in this, you should use:
> PositionSize = Max(PSize,-50);
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Al Venosa" <advenosa@xxxx> wrote:
> > Thanks, Buzz. I do that all the time. Very sloppy.  :-(
> > 
> > AV
> > 
> > 
> > ----- Original Message ----- 
> > From: "buzzmr" <buzzmr@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Monday, July 05, 2004 3:56 PM
> > Subject: [amibroker] Re: Which function gives "current portfolio 
> value"?
> > 
> > 
> > > Al (and Oliver),
> > >
> > > There's a minor (but AFL-compiler killing!) error to correct in 
> the
> > > code line:
> > >
> > > PSize = -1*C/(m*ATR(StopPd);  (--->unbalanced parenthesis error)
> > >
> > >
> > > Here's the corrected line:
> > >
> > > PSize = -1*C/( m*ATR(StopPd) );
> > >
> > >
> > > Buzz
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Al Venosa" <advenosa@xxxx> 
> wrote:
> > > > Olivier:
> > > >
> > > > I don't know what kind of stops you are using to establish 
your
> > > stop level,
> > > > but if it is based on volatility, you could use something 
like 
> this
> > > to limit
> > > > your risk to 1% of current equity:
> > > >
> > > > StopPd = Optimize("StopPd",10,1,20,1); //period for ATR
> > > > m = Optimize("m",2,0.5,3,0.25); // ATR multiplier
> > > > ApplyStop(0, 2, m*ATR(StopPd),1); // max stoploss based on
> > > volatility
> > > > PSize = -1*C/(m*ATR(StopPd); // positionsize equal to 1% of 
> current
> > > equity
> > > > PositionSize = Min(PSize,-50);
> > > >
> > > > Hope this helps.
> > > >
> > > > Al Venosa
> > > >
> > > >
> > > > ----- Original Message ----- 
> > > > From: "olivier_molongo" <olivier_molongo@xxxx>
> > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > Sent: Sunday, July 04, 2004 4:22 PM
> > > > Subject: [amibroker] Re: Which function gives "current 
portfolio
> > > value"?
> > > >
> > > >
> > > > > It is because I want to risk a maximum of 1% of my equity 
on 
> any
> > > > > trade. So I need to calculate Position1. I don't always 
want 
> to
> > > > > invest half of my equity.
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "dingo" <dingo@xxxx> 
wrote:
> > > > > > what's wrong with doing it the way the help file says to 
do 
> it?
> > > > > You're
> > > > > > making it more complicated than necessary.  Positionsize 
= -
> 50;
> > > > > will take
> > > > > > 1/2 of the current equity.
> > > > > >
> > > > > > d
> > > > > >
> > > > > >
> > > > > >   _____
> > > > > >
> > > > > > From: olivier_molongo [mailto:olivier_molongo@x...]
> > > > > > Sent: Sunday, July 04, 2004 3:36 PM
> > > > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > > > Subject: [amibroker] Which function gives "current 
portfolio
> > > value"?
> > > > > >
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > How can I get max position to be half of the portfolio 
> value.
> > > > > > >
> > > > > > > I use the following function:
> > > > > > >
> > > > > > > Position = Min (Position1,Equity()/2) ;   /* position1 
is 
> a
> > > > > > > calculated value
> > > > > > >
> > > > > > > but amibroker will cap my position to half of 
> the "initial"
> > > > > > portfolio
> > > > > > > value and not the current portfolio value. So if I 
start 
> with
> > > 10
> > > > > > 000
> > > > > > > in equity and end up with 20 000, I expect to be cap at 
> 10 000
> > > > > but
> > > > > > > Amibroker will always cap my position at 5 000.
> > > > > > >
> > > > > > > Is this a bug? How can I get the current portfolio 
value?
> > > > > > >
> > > > > > > Regards,
> > > > > > > Olivier
> > > > > >
> > > > > >
> > > > > >
> > > > > > Check AmiBroker web page at:
> > > > > > http://www.amibroker.com/
> > > > > >
> > > > > > Check group FAQ at:
> > > > > > 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > > >
> > > > > >
> > > > > >
> > > > > > Yahoo! Groups Sponsor
> > > > > >
> > > > > > ADVERTISEMENT
> > > > > >
> > > > > >
> > > > >
> > > 
> 
<http://us.ard.yahoo.com/SIG=129pk725c/M=295196.4901138.6071305.300117
> > > > > 6/D=gr
> > > > > >
> > > > >
> > > 
> 
oups/S=1705632198:HM/EXP=1089056204/A=2128215/R=0/SIG=10se96mf6/*http:
> > > > > //comp
> > > > > > anion.yahoo.com> click here
> > > > > >
> > > > > > <http://us.adserver.yahoo.com/l?
> > > > > M=295196.4901138.6071305.3001176/D=groups/S=
> > > > > > :HM/A=2128215/rand=301827469>
> > > > > >
> > > > > >
> > > > > >   _____
> > > > > >
> > > > > > 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
> > > > > > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?
> > > subject=Unsubscribe>
> > > > > >
> > > > > >
> > > > > > * Your use of Yahoo! Groups is subject to the Yahoo! 
Terms 
> of
> > > > > Service
> > > > > > <http://docs.yahoo.com/info/terms/> .
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Check AmiBroker web page at:
> > > > > http://www.amibroker.com/
> > > > >
> > > > > Check group FAQ at:
> > > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > > Yahoo! Groups Links
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.713 / Virus Database: 469 - Release Date: 
6/30/2004
> > >
> > >
> > >
> > >
> > > Check AmiBroker web page at:
> > > http://www.amibroker.com/
> > >
> > > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > 
> > 
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.713 / Virus Database: 469 - Release Date: 6/30/2004



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

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/