Thx Graham, I'll give them a try. Just a bit confused on why you use BuyPrice
with sigscale out but if you look further down in the code they use SellPrice
when just closing all remaining positions. Can you explain?
What does the Sell[i]=1 suppose to do? Is this just for the long section of
the code? Would you use Buy[i] = 1 for the Short side?
thx again,
Fred
----- Original Message -----
From: Graham
To: [email protected]
Sent: Wednesday, May 16, 2007 5:52 PM
Subject: Re: [amibroker] Re: Scale Out Question
These may not be all the errors, but just a couple in quick look
At the sigscale you should use BuyPrice
Buy[i] = sigScaleOut;
BuyPrice[i] = FirstProfitTarget + PriceAtBuy;
and at teh exit you need to use Sell
if(Exit == 2)
{
Sell[i] = 1;
In your short section make sure you use Short and Cover, not Buy and Sell
--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com
On 17/05/07, jjj_98 <[EMAIL PROTECTED]> wrote:
> Spent another day on this problem. Very frustrated at this point.
> Even when I reduce the whole thing down to just the trailing stop
> portion on the buy side only it still does not work. Has anyone been
> able to get this code from the Pyramiding section of the website to
> work? Are there things missing in the code or has it been updated
> recently? Does this code need to follow or precede the
> normal "Buy", "Sell", "Short", "Cover" instructions in the code?
>
> Any tidbit of advice on this would be very appreciated.
>
> thx,
>
> Fred
>
>
>
>
> --- In [email protected], "jjj_98" <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> > Trying to scale out of a position in my code and used the code from
> > one of the articles on the AB website. What is happening is that
> the
> > program does not recognize the profit targets or trailing stops
> that
> > have been set up in the code. At one point it was recognizing it,
> > but not correctly and when it scaled out it scaled out 100% rather
> > than 50%.
> >
> > I've spent a few hours trying to make this work. I'd really
> > appreciate it if anyone could take a look at the portion of the
> code
> > in question below and let me know if they see any obvious
> problems.
> > Yes, I have defined TrailingStop and FirstProfitTarget parameters.
> >
> > thx,
> >
> > PriceatBuy = 0;
> > PriceatShort = 0;
> > HighSinceBuy = 0;
> > LowSinceShort = 0;
> > Exit = 0;
> >
> > for( i = 0; i < BarCount; i++)
> > {
> > if(PriceAtBuy == 0 AND Buy[i])
> > {
> > PriceAtBuy = BuyPrice[i];
> > }
> > if(PriceAtBuy > 0)
> > {
> > HighSinceBuy = Max(High[i] , HighSinceBuy);
> > if(Exit == 0 AND High[i] >= (FirstProfitTarget +
> > PriceAtBuy))
> > {
> > // first profit target hit - Scale Out
> > Exit = 1;
> > Buy[i] = sigScaleOut;
> > SellPrice[i] = FirstProfitTarget + PriceAtBuy;
> >
> > }
> > if(Low[i] <= (HighSinceBuy - TrailingStop))
> > {
> > // trailing stop hit - exit
> > Exit = 2;
> > SellPrice[i] = (HighSinceBuy - TrailingStop);
> > }
> > if(Exit == 2)
> > {
> > Buy[i] = 0;
> > Exit = 0;
> > PriceAtBuy = 0;
> > HighSinceBuy = 0;
> > }
> > }
> >
> > if(PriceatShort == 0 AND Short[i])
> > {
> > PriceatShort = ShortPrice[i];
> > }
> > if(PriceatShort > 0)
> > {
> > LowSinceShort = Min(Low[i] , LowSinceShort);
> > if(Exit == 0 AND Low[i] <= (PriceatShort -
> > FirstProfitTarget))
> > {
> > // first profit target hit - Scale Out
> > Exit = 1;
> > Short[i] = sigScaleOut;
> > }
> > if(High[i] >= (LowSinceShort + TrailingStop))
> > {
> > // trailing stop hit - exit
> > Exit = 2;
> > BuyPrice[i] = (LowSinceShort + TrailingStop);
> > }
> > if(Exit == 2)
> > {
> > Short[i] = 0;
> > Exit = 0;
> > PriceatShort = 0;
> > LowSinceShort = 0;
> > }
> >
> > }
> >
> > }
> > SetPositionSize(50,spsPercentOfPosition*((Buy == sigScaleOut)+
> (Short
> > == sigScaleOut)));
> > //scale out of 50% of position
> >
>
>
>
>
> 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
>
>
>
>
#ygrp-mlmsg { FONT-SIZE: small; FONT-FAMILY:
arial,helvetica,clean,sans-serif}#ygrp-mlmsg TABLE { }#ygrp-mlmsg SELECT {
FONT: 99% arial,helvetica,clean,sans-serif}INPUT { FONT: 99%
arial,helvetica,clean,sans-serif}TEXTAREA { FONT: 99%
arial,helvetica,clean,sans-serif}#ygrp-mlmsg PRE { FONT: 100% monospace}CODE
{ FONT: 100% monospace}#ygrp-mlmsg * { LINE-HEIGHT: 1.22em}#ygrp-text {
FONT-FAMILY: Georgia}#ygrp-text P { MARGIN: 0px 0px 1em}#ygrp-tpmsgs
{ CLEAR: both; FONT-FAMILY: Arial}#ygrp-vitnav { FONT-SIZE: 77%; MARGIN:
0px; PADDING-TOP: 10px; FONT-FAMILY: Verdana}#ygrp-vitnav A { PADDING-RIGHT:
1px; PADDING-LEFT: 1px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px}#ygrp-actbar {
CLEAR: both; MARGIN: 25px 0px; COLOR: #666; WHITE-SPACE: nowrap; TEXT-ALIGN:
right}#ygrp-actbar .left { FLOAT: left; WHITE-SPACE: nowrap}..bld {
FONT-WEIGHT: bold}#ygrp-grft { PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
FONT-SIZE: 77%; PADDING-BOTTOM: 15px; PADDING-TOP: 15px; FONT-FAMILY:
Verdana}#ygrp-ft { PADDING-RIGHT: 0px; BORDER-TOP: #666 1px solid;
PADDING-LEFT: 0px; FONT-SIZE: 77%; PADDING-BOTTOM: 5px; PADDING-TOP: 5px;
FONT-FAMILY: verdana}#ygrp-mlmsg #logo { PADDING-BOTTOM: 10px}#ygrp-vital
{ PADDING-RIGHT: 0px; PADDING-LEFT: 8px; MARGIN-BOTTOM: 20px;
PADDING-BOTTOM: 8px; PADDING-TOP: 2px; BACKGROUND-COLOR: #e0ecee}#ygrp-vital
#vithd { FONT-WEIGHT: bold; FONT-SIZE: 77%; TEXT-TRANSFORM: uppercase;
COLOR: #333; FONT-FAMILY: Verdana}#ygrp-vital UL { PADDING-RIGHT: 0px;
PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 2px 0px; PADDING-TOP:
0px}#ygrp-vital UL LI { CLEAR: both; BORDER-RIGHT: #e0ecee 1px solid;
BORDER-TOP: #e0ecee 1px solid; BORDER-LEFT: #e0ecee 1px solid; BORDER-BOTTOM:
#e0ecee 1px solid; LIST-STYLE-TYPE: none}#ygrp-vital UL LI .ct {
PADDING-RIGHT: 0.5em; FONT-WEIGHT: bold; FLOAT: right; WIDTH: 2em; COLOR:
#ff7900; TEXT-ALIGN: right}#ygrp-vital UL LI .cat { FONT-WEIGHT:
bold}#ygrp-vital A { TEXT-DECORATION: none}#ygrp-vital A:hover {
TEXT-DECORATION: underline}#ygrp-sponsor #hd { FONT-SIZE: 77%; COLOR:
#999}#ygrp-sponsor #ov { PADDING-RIGHT: 13px; PADDING-LEFT: 13px;
MARGIN-BOTTOM: 20px; PADDING-BOTTOM: 6px; PADDING-TOP: 6px; BACKGROUND-COLOR:
#e0ecee}#ygrp-sponsor #ov UL { PADDING-RIGHT: 0px; PADDING-LEFT: 8px;
PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px}#ygrp-sponsor #ov LI {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 77%; PADDING-BOTTOM: 6px;
PADDING-TOP: 6px; LIST-STYLE-TYPE: square}#ygrp-sponsor #ov LI A { FONT-SIZE:
130%; TEXT-DECORATION: none}#ygrp-sponsor #nc { PADDING-RIGHT: 8px;
PADDING-LEFT: 8px; MARGIN-BOTTOM: 20px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px;
BACKGROUND-COLOR: #eee}#ygrp-sponsor .ad { PADDING-RIGHT: 0px; PADDING-LEFT:
0px; PADDING-BOTTOM: 8px; PADDING-TOP: 8px}#ygrp-sponsor .ad #hd1 {
FONT-WEIGHT: bold; FONT-SIZE: 100%; COLOR: #628c2a; LINE-HEIGHT: 122%;
FONT-FAMILY: Arial}#ygrp-sponsor .ad A { TEXT-DECORATION: none}#ygrp-sponsor
.ad A:hover { TEXT-DECORATION:
underline}#ygrp-sponsor .ad P { MARGIN: 0px}o { FONT-SIZE:
0px}..MsoNormal { MARGIN: 0px}#ygrp-text TT { FONT-SIZE: 120%}BLOCKQUOTE
{ MARGIN: 0px 0px 0px 4px}..replbq { }
---------------------------------
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.