Andrew,

Greetings.

This is based on the chandlier inthe library. So credit goes to G Muhali.

Use valuewhen to get the start value from your buy signal using barindex.
_SECTION_BEGIN("Chandelier Exit");
YourHold_Buy = BarIndex() - ValueWhen(SwingTrade_Strategy3_Buy, BarIndex(), 
1);//Replace <...> with your 'buy' formula

YourHold_Sell = BarIndex() - ValueWhen(SwingTrade_Strategy3_Sell, BarIndex(), 
1);

Multiple = 3; //How many ATR's to be allowed below the highest high since 
latest "buy" bar

ATRPeriods = 20; //How many periods to use for the ATR

Chandelier_TS_FOR_LONGPOSITIONS = HHV(Close,YourHold_Buy) - (Multiple * 
ATR(ATRPeriods)); //Chandelier exit line from highest close

Chandelier_TS_FOR_SHORTPOSITIONS = LLV(Low, YourHold_Sell) + (Multiple * 
ATR(ATRPeriods)); //Chanderlier exit from lowest low (used when going short)

Plot(Chandelier_TS_FOR_LONGPOSITIONS, "ChandClose", ParamColor( "ChandClose 
Color", colorViolet ), ParamStyle("ChandClose Style") );

Plot(Chandelier_TS_FOR_SHORTPOSITIONS, "ChandLow", ParamColor( "ChandLow 
Color", colorAqua ), ParamStyle("ChandLow Style") );

"YourHold_Buy is "+YourHold_Buy;

"ATR20 IS "+ATR(20);

"hhv_buyhold is "+HHV(Close,YourHold_Buy);

_SECTION_END();/////// 

Cheers,Padhu



  ----- Original Message ----- 
  From: amickan1958 
  To: [email protected] 
  Sent: Thursday, November 22, 2007 1:39 AM
  Subject: [amibroker] Plot ATR trailing stop which only increases


  Hi,

  I've been trying to crack this one but can't seem to. What I need is a 
  plot of my trailing stop. The stop is based on a multiplier of todays 
  ATR(30) value. This stop only ever increase.

  Can anyone help me out with some code please?

  Thanks

  Andrew



   

Reply via email to