Welcome to the Traders Laboratory Forums.
TradeStation Custom Programming Discuss projects, ideas, obstacles in programming with TradeStation.

Reply
Old 10-25-2011, 06:26 PM   #1

Join Date: Oct 2011
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Dynamic Text Box

I am new in this forum, hope to contribute and learn here.

I am dealing with plotting a text on the chart at a fixed position (i.e. upper left corner), based on date/time/price visible on the chart. I am using getappinfo, with aiLeftDispDateTime and aiHighestDispValue, but only the last one works with text_new and set_textlocation. Basically I cant understand how to pass date&time info to text_new separatly as date and time. Any clue? thanks a lot
eros1973ms is offline  
Reply With Quote
Old 10-26-2011, 05:21 AM   #2

Join Date: Oct 2011
Posts: 2
Ignore this user

Thanks: 0
Thanked 0 Times in 0 Posts

Re: Dynamic Text Box

I clarify a little what I mean with "only aiHighestDispValue works".

Code:
vars:
IntrabarPersist date_1(0),
IntrabarPersist time_1(0),
IntrabarPersist price_1(0);

date_1 = getappinfo(aiLeftDispDate Time);
time_1 = getappinfo(aiLeftDispDate Time);
price_1 = getappinfo(aiHighestDispV alue)-offset_points*2;

if symbol = "GS:EUR A0-FX" and (time_1<>time_1[1] or price_1<>price_1[1]) then
print(
symbol,
"data-> ",
StringToDate(DateTimeToSt ring(getappinfo(aiLeftDis pDateTime))),
"string data->",
datetostring(StringToDate (DateTimeToString(getappi nfo(aiLeftDispDateTime))) ),
"ora-> ",
StringTotime(DateTimeToSt ring(getappinfo(aiLeftDis pDateTime)))," ",
"string time->",
timetostring(StringTotime (DateTimeToString(getappi nfo(aiLeftDispDateTime))) ), " ",
getappinfo(aiHighestDispV alue):0:4,
setup_count_buy," ",
setup_count_sell,
" ",
getappinfo(aiLeftDispDate Time)
);

if date_1<>date_1[1] or time_1>time_1[1] or price_1<>price_1[1] then
begin
id_3=text_new(
date_1,
time_1,
price_1,
"test test test test"
);
value2=text_setlocation(i d_3, date_1, time_1, price_1);
end;

I inserted also the print command to verify that the calculated values are the one desired, and I can confirm this.
But what I get from text_new is the text is plotted at the correct price level [getappinfo(aiHighestDispV alue)-offset_points*2] but at the wrong date/time combination (the text is actually positioned on the first bar of the entire series, not on the first bar displayed).
I have also tried converting the date&time to string and then back to value, but it makes no difference:
date_1 = StringToDate(DateTimeToSt ring(getappinfo(aiLeftDis pDateTime)));
time_1 = StringTotime(DateTimeToSt ring(getappinfo(aiLeftDis pDateTime)));

thanks
eros1973ms is offline  
Reply With Quote
Old 10-26-2011, 07:00 PM   #3

Tradewinds's Avatar

Join Date: Nov 2008
Location: Northeast U.S.
Posts: 891
Ignore this user

Thanks: 373
Thanked 231 Times in 164 Posts
Blog Entries: 6

Re: Dynamic Text Box

aiLeftDispDateTime = Identifies date and time of the first (leftmost) bar displayed on the chart. Returns a DateTime(double) value when called from a chart otherwise returns 0.

Here is some simple code that displays the output on the chart. I suggest that you separate out things into small sections of code that you can get to work, with some way of seeing what the output is. This indicator shows what the output of the code is in the upper right hand corner of the screen. In the upper right hand corner, it shows the date and time of the first bar on the chart.

Code:
var: DateString(" ");

Once 
	begin  
	Value1 = Text_New( D, T, getappinfo(aiHighestDispValue), "  Begin" );
	end;

DateString = DateTimeToString(getappinfo(aiLeftDispDateTime));

Text_SetString(Value1, DateString);
Text_SetLocation(Value1, D, T, getappinfo(aiHighestDispValue) - 0.5);
Text_SetStyle(Value1, 0, 2);
__________________
Precise, "dialed-in", targeted combination setups, like opening a combination lock; is the experience you should be having while trading. Dial left, right, left, . . . click - the lock opens.
Tradewinds is offline  
Reply With Quote
Old 10-31-2011, 03:34 AM   #4

Join Date: May 2010
Posts: 181
Ignore this user

Thanks: 0
Thanked 49 Times in 38 Posts

Re: Dynamic Text Box

// dynamically adjusts text to upper left corner of chart

var: id(text_new(d,t,c,"hello world")), x(text_setstyle(id,0,0)),
intrabarpersist xd(0), intrabarpersist xt(0), intrabarpersist xp(0);

xd=juliantodate(intPortio n(getappinfo(aiLeftDispDa teTime)));
xt=minutesToTime(fracport ion(getappinfo(aiLeftDisp DateTime))*24*60);
xp=getappinfo(aiHighestDi spValue);
text_setlocation(id,xd,xt ,xp);
onesmith is offline  
Reply With Quote

Reply

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Stop Loss bdlagno55 Automated Trading 0 03-05-2011 10:08 AM
Dynamic VWAP with StdDevs for SC Hlm Trading Indicators 5 05-08-2010 02:04 AM
Robert Miner--Dynamic Trader pandion Swing Trading and Position Trading 8 03-28-2010 04:12 PM
Tro Dynamic Fibs Sr TheRumpledOne Trading Indicators 16 09-03-2009 05:43 PM
Dynamic Risk to Reward AbeSmith Trading and the Markets 4 08-17-2009 03:32 AM

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