Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 11-22-2008, 12:47 PM   #1

Join Date: Oct 2008
Location: new york
Posts: 54
Ignore this user

Thanks: 17
Thanked 8 Times in 4 Posts

% atr

how can i plot "live" calculating ATR % in tradestation.

what i want to do is have a lable that shows me % of ATR move in a given stock/future

thanks.
ephi144 is offline  
Reply With Quote
Old 11-23-2008, 10:04 AM   #2

Join Date: Oct 2008
Location: new york
Posts: 54
Ignore this user

Thanks: 17
Thanked 8 Times in 4 Posts

Re: % atr

[LegacyColorValue = true];

input: PeriodValue(7);


vars: HighAtrTxt(-1), LowAtrTxt(-1),Atr(0),HighATR(0),LowA TR(0);



Atr = AvgTrueRange (PeriodValue); //7 day ATR


HighATR = HighD(1) + ATR;
LowATR = LowD(1) - ATR;

if BarType = 2 then
begin

HighAtrTxt = Text_New(Date, Time, HighATR, "High ATR");
LowAtrTxt = Text_New(Date, Time, LowATR, "Low ATR");

text_SetLocation(HighAtrT xt,date, HighATR, HighATR);
text_SetLocation(LowAtrTx t,date, LowATR, LowATR);

text_SetString(HighAtrTxt ,NumToStr(HighATR,0)+" High ATR");
text_SetString(LowAtrTxt, NumToStr(LowATR,0)+" Low ATR");

text_SetColor(HighAtrTxt, Green);
text_SetColor(LowAtrTxt,G reen);
end;
ephi144 is offline  
Reply With Quote
Old 11-23-2008, 10:05 AM   #3

Join Date: Oct 2008
Location: new york
Posts: 54
Ignore this user

Thanks: 17
Thanked 8 Times in 4 Posts

Re: % atr

i have got what i was looking for (i wrote that myself) but i want to add one more feature which that the text is only painted for the yesterday and no other bars.

so i am looking at the atr values of yesterday not before nor today's.

i tried to use if CurrentBar = 1 then but it does not work

thanks
ephi144 is offline  
Reply With Quote
Old 02-08-2009, 10:35 AM   #4

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 3,779
Ignore this user

Thanks: 2,084
Thanked 1,474 Times in 912 Posts

Re: % atr

this should do the trick


HTML Code:
[LegacyColorValue = true];

input: 
PeriodValue(7),
text.color(black),
decimal(2);

vars: 
HighAtrTxt(-1), 
LowAtrTxt(-1),
Atr(0),
HighATR(0),
LowATR(0);

Atr = AvgTrueRange (PeriodValue); //7 day ATR


HighATR = H[1] + ATR[1];  {<-- yestereday's ATR = ATR[1] }
LowATR = L[1] - ATR[1];

if currentbar = 1 then
begin
	HighAtrTxt = Text_New(Date, Time, HighATR, "High ATR");
	LowAtrTxt = Text_New(Date, Time, LowATR, "Low ATR");
	text_Setcolor(HighAtrTxt, text.color);
	text_Setcolor(LowAtrTxt, text.color);
	text_Setstyle(HighAtrTxt, 0, 2);
	text_Setstyle(LowAtrTxt, 0, 2);
end;

text_SetLocation(HighAtrTxt,date, time, HighATR);
text_SetLocation(LowAtrTxt,date, time, LowATR);

text_SetString(HighAtrTxt ," < "+NumToStr(HighATR,decimal)+" High ATR");
text_SetString(LowAtrTxt, " < "+NumToStr(LowATR,decimal)+" Low ATR");

Last edited by Tams; 02-08-2009 at 10:59 AM.
Tams is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


All times are GMT -4. The time now is 12:10 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.