Please convert tradestation code to amibroker

stock

New Member
#1
{
***** Study name: 'TT Trend Bands'
}
{ ***** DLLs Section ***** }
{ ***** INPUTs Section *****}
inputs: BandDays(28), DevConstant(3.500000),DEV2(4.500000);
{ ***** VARs Section ***** }
Variables: keltnerTop(0), keltnerMid(0), keltnerBot(0), expSmoothPrice(0);
Variables: expSmoothRange(0);
Variables: altu(0),altd(0),up(0),down(0),dir(0),n(0),p(0);

{ ***** ARRAYs Section *****}

{ ***** CODE Section ***** }

IF (CURRENTBAR = 1) THEN
BEGIN
expSmoothPrice = CLOSE ;
expSmoothRange = HIGH-LOW ;
END ELSE
BEGIN
expSmoothPrice = (expSmoothPrice*(BandDays-1)+CLOSE)/BandDays ;
expSmoothRange = (expSmoothRange*(BandDays-1)+(HIGH-LOW))/BandDays ;
END ;

keltnerTop = expSmoothPrice+(expSmoothRange*DevConstant) ;
keltnerMid = expSmoothPrice ;
keltnerBot = expSmoothPrice-(expSmoothRange*DevConstant) ;

if close <= KeltnerMid then altd = 1;// else altd = 0;
if altd = 1 and high[1] <= KeltnerMid and close < Low[1] then begin
dir = -1 ;
end;

if close >= KeltnerMid then altu = 1 else altu = 0;
if altu = 1 and low[1] >= KeltnerMid and close > high[1] then begin
dir = 1;
end;

if dir = -1 then setplotcolor(2,red);
if dir = 1 then setplotcolor(2,blue);


PLOT1 (keltnerTop, "TBand Top") ;
PLOT2 (keltnerMid, "TBand Mid") ;
PLOT3 (keltnerBot, "TBand Bot") ;

Thank You
 

Similar threads