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

[amibroker] Trailing Stop S & C tips 1-2008



PureBytes Links

Trading Reference Links

Hello all

I am looking at the code that TJ provided in AmiBroker S&C Traders' Tips monthly. Issue 1/2008.

I have applied it to some charts and it seems that the trailing stop "TL" in the code which appears to be correct does not plot as shown in the example. I get a horizontal line above the channel and price data in every case.

Can anyone see what could be the issue in the code below?

//PROFIT LOCKING AND THE RELATIVE PRICE CHANNEL
//"Profit Locking and The Relative Price Channel" article 
//AmiBroker S&C Traders' Tips monthly. Issue 1/2008
//http://www.amibroker.com/members/traders/01-2008.html
//http://www.traders.com/documentation/FEEDbk_docs/2008/01/TradersTips/TradersTips.html#amibroker

dt = ParamDate("Date of the trend", "2008-11-20" ); 
Value1 = Param("Bearish Periods", 21, 3, 55 ); 
Value2 = Param("Multiplication Factor", 3.8, 1, 10 ); 
Value3 = Param("Initial Stop", 19, 0, 1e6 ); 
Value4 = Param("Channel Periods", 21, 3, 55 ); // Channel Periods 
Value5 = Param("Overbought region", 75, 1, 100 ); // Overbought region 
Value6 = Param("Channel Smoothing", 1, 1, 10 ); 

HoldingDays = BarsSince( DateNum() < dt ); 

Index = RSI( Value4 ); 
OB = EMA( Index - Value5, Value6 ); 
Bullish = Close - ( Close * OB/100 ); 

Bearish = Sum( abs( Low - Ref( Low, -1 ) ), Value1 ) / Value1; 
RangeA = Sum( Close - Low, Value1 ) / Value1; 
Stop = Close - ( ( Bearish + RangeA ) * Value2 ); 

TL = Null; 

for( i = 1; i < BarCount; i++ ) 
{ 
 Prev = TL[ i - 1 ]; 
 Cond1 = Stop[ i ] > Prev; 

 TL[ i ] = IIf( Cond1 AND Stop[ i ] > Value3, Stop[ i ], 
           IIf( Cond1 AND Stop[ i ] < Value3, Value3, 
           IIf( NOT Cond1, Prev, Stop[ i ] * HoldingDays[ i ] ) ) ); 
} 

TL = IIf( HoldingDays == 0, Null, TL ); 
Bullish = IIf( HoldingDays == 0, Null, Bullish ); 

Plot( C, "Price",  IIf( C > O, colorGreen, colorRed ), styleBar ); 
Plot( TL, "TL", colorBlue ); 
Plot( Bullish, "Bullish", colorLightGrey ); 
PlotOHLC( TL, TL, Bullish, Bullish, "", ColorRGB( 230, 230, 230), styleCloud | styleNoLabel ); 
Title = "{{NAME}} - {{DATE}} - {{VALUES}}";




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

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