--- In [email protected], "carlacash26" <[EMAIL PROTECTED]> 
wrote:
>
> --- In [email protected], "zebdez" <robduff@> wrote:
> >
> > Does anyone have the AFL version of the MetaStock plugin for 
> > the "Advanced Trailing Stop" that is based on Chandelier Exit 
> > developed by Chuck Le Beau? I have enough information to develop 
it, 
> > but prefer to not re-invent the wheel.
> > 
> > Thanks,
> > Rob
> >

This is the code I have created starting from the Metastock DLL of 
Richard Dale for the Chandelier Exit (see the site 
http://www.tradernexus.com/advancedstop/advancedstop.html).

Opt2=Optimize("Initstop",2,1.5,2.5,0.5);
Opt6=Optimize("Pyramidpoint1",4,4,4,0.5);
Opt7=Optimize("Pyramidpoint2",6,6,6,0.5);

//
// BUY
//
Buy=............; Insert here yours rule

//
// SHORT
//
Short=............; Insert here yours rule

//
// SELL
//
Sell=0;

//
// COVER
//
Cover=0;

priceatbuy=0;
priceatshort=0;
exit=0;
myATR=ATR(10); 

for( i = 0; i < BarCount; i++ )
{
if( priceatbuy == 0 AND Buy [ i ] )
{
priceatbuy = BuyPrice [ i ];
pricestop=priceatbuy-(Opt2*myATR[i]);
priceattrail=pricestop;
pyramidpoint1=priceatbuy+(Opt6*myATR[i]);
pyramidpoint2=priceatbuy+(Opt7*myATR[i]);
priceatshort=0;
}
if( priceatshort == 0 AND Short [ i ] )
{
priceatshort = ShortPrice [ i ];
pricestop=priceatshort+(Opt2*myATR[i]);
priceattrail=pricestop;
pyramidpoint1=priceatshort-(Opt6*myATR[i]);
pyramidpoint2=priceatshort-(Opt7*myATR[i]);
priceatbuy=0;
}
if( priceatbuy > 0 AND Close[i]<pricestop )
{
exit = 1;
_TRACE(" Exit Stop Loss in Buy");
}
if( priceatshort > 0 AND Close[i]>pricestop )
{
exit = 1;
_TRACE(" Exit Stop Loss in Short");
}
if( priceatbuy > 0 AND exit==0 )
{
if (Close[i] <= pyramidpoint1)
{
mytrail=High[i] - (opt2+0.5) * myATR[i];
}
if (Close[i] > pyramidpoint1 AND Close[i] <=pyramidpoint2)
{
mytrail=High[i] - (opt2-0.5) * myATR[i];
}
if (Close[i] > pyramidpoint2)
{
mytrail=High[i] - (opt2-1) * myATR[i];
}
priceattrail = Max(mytrail,priceattrail);
if (Close[i] < priceattrail)
{
exit = 3;
_TRACE(" Exit Trailing Stop in Buy");
}
}
if( priceatshort > 0 AND exit==0 )
{
if (Close[i] >= pyramidpoint1)
{
mytrail=Low[i] + (opt2+0.5) * myATR[i];
}
if (Close[i] < pyramidpoint1 AND Close[i] >=pyramidpoint2)
{
mytrail=Low[i] + (opt2-0.5) * myATR[i];
}
if (Close[i] < pyramidpoint2)
{
mytrail=Low[i] + (opt2-1) * myATR[i];
}
priceattrail = Min(mytrail,priceattrail);
if (Close[i] > priceattrail)
{
exit = 3;
_TRACE(" Exit Trailing Stop in Short");
}
}
if( priceatbuy > 0 )
{
if( exit > 0 )
{
Buy [ i ] = 0;
Sell [ i ] = exit + 1;
exit = 0;
priceatbuy = 0;
}
}
if( priceatshort > 0 )
{
if( exit > 0 )
{
Short [ i ] = 0;
Cover [ i ] = exit + 1;
exit = 0;
priceatshort = 0;
}
}
}







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 other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

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



Reply via email to