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

[amibroker] Chandelier Exit in Amibroker



PureBytes Links

Trading Reference Links


Salve a tutti 
avendo usato per parecchio tempo in Metastock le DLL di Richard Dale 
per il Chandelier Exit (vedi il sito 
http://www.tradernexus.com/advanced...vancedstop.html) 
ed essendo passato da qualche mese ad Amibroker, ho cercato in giro 
su Internet qualcosa che si avvicinasse a quel metodo, ma non ho 
trovato niente. 

Allora mi sono messo a studiare il linguaggio di Amibroker e mi sono 
scritto le istruzioni in AFL per ottenere lo stesso risultato. 

Con due differenze : 
1) Richard Dale calcola il trailing con un ritardo di un giorno io ho 
preferito calcolarlo senza ritardo; 
2) Non ho implementato l'uso della variabile Transition to breakeven 
stop perchè non l'ho mai usata. 

La variabile Opt2 moltiplicata per ATR(10) è quella che gestisce
lo 
Stop loss iniziale e anche i vari trailing stop. 

Il primo trailing stop è dato da (Opt2 + 0.5), poi appena
raggiunto 
il primo Pyramidpoint (fisso a 4 * ATR(10)) si passa a (Opt2 - 0.5), 
per finire raggiunto il secondo Pyramidpoint (fisso a 6 * ATR(10)) si 
passa a (Opt2 -1). 

Ecco qua a disposizione di tutti quelli interessati il listato in AFL 

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=............; Qui inserite le vostre regole di buy 

// 
// SHORT 
// 
Short=............; Qui inserite le vostre regole di short 

// 
// SELL 
// 
Sell=0; 

// 
// COVER 
// 
Cover=0; 

priceatbuy=0; 
priceatshort=0; 
exit=0; 
myATR=ATR(10); // io uso fisso ATR(10) volendo lo potete ottimizzare 

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; 
} 
} 
}





------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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/

<*> 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/