NexusFi: Find Your Edge


Home Menu

 





Easylanguage: Dynamic Text Box


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one eros1973ms with 13 posts (5 thanks)
    2. looks_two Jura with 4 posts (4 thanks)
    3. looks_3 Big Mike with 3 posts (1 thanks)
    4. looks_4 futat with 2 posts (0 thanks)
    1. trending_up 12,101 views
    2. thumb_up 10 thanks given
    3. group 3 followers
    1. forum 21 posts
    2. attach_file 6 attachments




 
Search this Thread

Easylanguage: Dynamic Text Box

  #1 (permalink)
eros1973ms
florence
 
Posts: 25 since Oct 2011
Thanks Given: 2
Thanks Received: 6

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

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.

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

//D = StringToDate(DateTimeToString(getappinfo(aiLeftDispDateTime)));
//t = StringTotime(DateTimeToString(getappinfo(aiLeftDispDateTime)));


date_1 = getappinfo(aiLeftDispDateTime);
time_1 = getappinfo(aiLeftDispDateTime);
price_1 = getappinfo(aiHighestDispValue)-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(DateTimeToString(getappinfo(aiLeftDispDateTime))),
"string data->",
datetostring(StringToDate(DateTimeToString(getappinfo(aiLeftDispDateTime)))),
"ora-> ",
StringTotime(DateTimeToString(getappinfo(aiLeftDispDateTime)))," ",
"string time->",
timetostring(StringTotime(DateTimeToString(getappinfo(aiLeftDispDateTime)))), " ",
getappinfo(aiHighestDispValue):0:4,
setup_count_buy," ",
setup_count_sell,
" ",
getappinfo(aiLeftDispDateTime)
);

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(id_3, date_1, time_1, price_1);
end;

I have inserted both the text_new command and the print command, to check the variables values.
What I can understand is that the print command correctly gets the date/time values of the DISPLAYED series, while the text_new command seems to disregard and continue to plot on the first bar of the entire series, even if not visible.
I have also tried to convert the date&time resulting from the getappinfo to string and then back to values separating date and time (exactly as in the print command) but this make no difference:

date_1 = stringtodate(DateTimeToString(getappinfo(aiLeftDispDateTime)));
time_1 = stringtotime(DateTimeToString(getappinfo(aiLeftDispDateTime)));

any advice?

thank you for your help

Attached Thumbnails
Click image for larger version

Name:	1.jpg
Views:	441
Size:	394.1 KB
ID:	53151   Click image for larger version

Name:	2.jpg
Views:	350
Size:	361.9 KB
ID:	53152  
Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Deepmoney LLM
Elite Quantitative GenAI/LLM
Exit Strategy
NinjaTrader
 
  #3 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



eros1973ms View Post
(..)Basically I cant understand how to pass date&time info to text_new separatly as date and time. (..)

You mean something like ...
 
Code
backtestTimeGV         = el_datetodatetime(CurrentDate) + el_timetodatetime_s(CurrentTime_s);
backtestTimeDate     = Text(FormatTime("HHmm", backtestTimeGV), ".", FormatDate("ddMMyy", backtestTimeGV));
(where the DateTime numeric value is split in a time with 'HHmm' format (so 0815 for fifteen minutes pas eight in the morning), and date in 'ddMMyy' format (so 261011 for October 26th 2011)).

Reply With Quote
Thanked by:
  #4 (permalink)
eros1973ms
florence
 
Posts: 25 since Oct 2011
Thanks Given: 2
Thanks Received: 6


Jura View Post
You mean something like ...
 
Code
backtestTimeGV         = el_datetodatetime(CurrentDate) + el_timetodatetime_s(CurrentTime_s);
backtestTimeDate     = Text(FormatTime("HHmm", backtestTimeGV), ".", FormatDate("ddMMyy", backtestTimeGV));
(where the DateTime numeric value is split in a time with 'HHmm' format (so 0815 for fifteen minutes pas eight in the morning), and date in 'ddMMyy' format (so 261011 for October 26th 2011)).

Hi Jura, thanks for your reply.
are those formats readable by the text_new function?
I mean, can I write:

text_new(formatDate("ddMMyy", getappinfo(aiLeftDispDateTime)), FormatTime("ddMMyy", getappinfo(aiLeftDispDateTime)), getappinfo(aiHighestDispValue), "test text")

Reply With Quote
  #5 (permalink)
eros1973ms
florence
 
Posts: 25 since Oct 2011
Thanks Given: 2
Thanks Received: 6


eros1973ms View Post
Hi Jura, thanks for your reply.
are those formats readable by the text_new function?
I mean, can I write:

text_new(formatDate("ddMMyy", getappinfo(aiLeftDispDateTime)), FormatTime("ddMMyy", getappinfo(aiLeftDispDateTime)), getappinfo(aiHighestDispValue), "test text")

no, I have tried, but this values cannot be entered in the text_new function, it is expecting easylanguage format of date and time... looking at my print results, it should be accomplished by

date_1 = stringtodate(DatetimeToString(getappinfo(aiLeftDispDateTime));
time_1 = stringtotime(DatetimeToString(getappinfo(aiLeftDispDateTime));

but this does not work...I mean, the code is ok, but the text is not printed on the first bar of the displayed values..

Reply With Quote
  #6 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


eros1973ms View Post
no, I have tried, but this values cannot be entered in the text_new function (..)

Really? Works fine here:

 
Code
variables: textStr("");

if LastBarOnChart_s = true then begin

    // Generate text string
    textStr = Text("Leftmost time & date: ", FormatTime("HH:mm", getappinfo(aiLeftDispDateTime)), Spaces(3),        
        formatDate("dd-MM-yyyy", getappinfo(aiLeftDispDateTime)), NewLine,
        "Rightmost time & date: ", FormatTime("HH:mm", getappinfo(airightdispdatetime)), Spaces(3),
        formatDate("dd-MM-yyyy", getappinfo(airightdispdatetime)));
        
    value1 = Text_new_s(Date, Time_s, Low -0.02, textStr);
    value2 = Text_SetStyle(value1, 1, 0);

end;
(See attached screenshot)

Note that the Text_new requires a string input.

Attached Thumbnails
Click image for larger version

Name:	textNew.PNG
Views:	386
Size:	28.0 KB
ID:	53155  
Reply With Quote
  #7 (permalink)
eros1973ms
florence
 
Posts: 25 since Oct 2011
Thanks Given: 2
Thanks Received: 6


Jura View Post
Really? Works fine here:

 
Code
variables: textStr("");

if LastBarOnChart_s = true then begin

    // Generate text string
    textStr = Text("Leftmost time & date: ", FormatTime("HH:mm", getappinfo(aiLeftDispDateTime)), Spaces(3),        
        formatDate("dd-MM-yyyy", getappinfo(aiLeftDispDateTime)), NewLine,
        "Rightmost time & date: ", FormatTime("HH:mm", getappinfo(airightdispdatetime)), Spaces(3),
        formatDate("dd-MM-yyyy", getappinfo(airightdispdatetime)));
        
    value1 = Text_new_s(Date, Time_s, Low -0.02, textStr);
    value2 = Text_SetStyle(value1, 1, 0);

end;
(See attached screenshot)

Note that the Text_new requires a string input.

Actually in your example your are passing the formatted values to the string, while text_new gets the normal Date input (I dont know how time_s is defined, but again it is not the formatted time that you use to compose the text).
Am I wrong?

Reply With Quote
  #8 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


eros1973ms View Post
Actually in your example your are passing the formatted values to the string, while text_new gets the normal Date input (I dont know how time_s is defined, but again it is not the formatted time that you use to compose the text).
Am I wrong?

So, you want to use the aiLeftDispDateTime and aiRightDispDateTime to plot the text, using them as coordinates for that? In that case, my apologies, then I mistakenly assumed that you wanted to convert them to strings, and use them in the plotted text.

Try this to use aiLeftDispDateTime and aiRightDispDateTime to use as "coordinates" for the placement of Text_New_s:
 
Code
variables: leftDate(0), leftTime(0), rightDate(0), rightTime(0);

if LastBarOnChart_s = true then begin

    leftDate = JulianToDate(GetAppInfo(aiLeftDispDateTime));
    leftTime = datetime2eltime_s(GetAppInfo(aiLeftDispDateTime));

    value10 = Text_new_s(leftDate, leftTime, Low - 0.02, "Hello");
    value11 = Text_SetStyle(value10, 0, 2);
    
    rightDate = JulianToDate(GetAppInfo(aiRightDispDateTime));
    rightTime = datetime2eltime_s(GetAppInfo(aiRightDispDateTime));
    
    value15 = Text_new_s(rightDate, rightTime, High + 0.02, "GoodBye");
    value16 = Text_SetStyle(value15, 1, 2);
    
end;
(see attached screenshot)

If this is also not what you mean, please be extremely clear and brief on what you want to achieve, because in that case I don't follow what you want to do.

Attached Thumbnails
Click image for larger version

Name:	placementWithDisp.PNG
Views:	337
Size:	24.2 KB
ID:	53157  
Reply With Quote
Thanked by:
  #9 (permalink)
eros1973ms
florence
 
Posts: 25 since Oct 2011
Thanks Given: 2
Thanks Received: 6


Jura View Post
Really? Works fine here:

 
Code
variables: textStr("");

if LastBarOnChart_s = true then begin

    // Generate text string
    textStr = Text("Leftmost time & date: ", FormatTime("HH:mm", getappinfo(aiLeftDispDateTime)), Spaces(3),        
        formatDate("dd-MM-yyyy", getappinfo(aiLeftDispDateTime)), NewLine,
        "Rightmost time & date: ", FormatTime("HH:mm", getappinfo(airightdispdatetime)), Spaces(3),
        formatDate("dd-MM-yyyy", getappinfo(airightdispdatetime)));
        
    value1 = Text_new_s(Date, Time_s, Low -0.02, textStr);
    value2 = Text_SetStyle(value1, 1, 0);

end;
(See attached screenshot)

Note that the Text_new requires a string input.


Jura View Post
So, you want to use the aiLeftDispDateTime and aiRightDispDateTime to plot the text, using them as coordinates for that? In that case, my apologies, then I mistakenly assumed that you wanted to convert them to strings, and use them in the plotted text.

Try this to use aiLeftDispDateTime and aiRightDispDateTime to use as "coordinates" for the placement of Text_New_s:
 
Code
variables: leftDate(0), leftTime(0), rightDate(0), rightTime(0);

if LastBarOnChart_s = true then begin

    leftDate = JulianToDate(GetAppInfo(aiLeftDispDateTime));
    leftTime = datetime2eltime_s(GetAppInfo(aiLeftDispDateTime));

    value10 = Text_new_s(leftDate, leftTime, Low - 0.02, "Hello");
    value11 = Text_SetStyle(value10, 0, 2);
    
    rightDate = JulianToDate(GetAppInfo(aiRightDispDateTime));
    rightTime = datetime2eltime_s(GetAppInfo(aiRightDispDateTime));
    
    value15 = Text_new_s(rightDate, rightTime, High + 0.02, "GoodBye");
    value16 = Text_SetStyle(value15, 1, 2);
    
end;
(see attached screenshot)

If this is also not what you mean, please be extremely clear and brief on what you want to achieve, because in that case I don't follow what you want to do.

Thanks for your patience Jura!
it is exactly what I want to do.
the date now is working perfectly, thank you.
Only problem with this is that I don't have a DatetimetoEltime function! I am on v8.7...maybe this is why?
I only have the datetimetostring and the stringtodate, but does not seem to work.

Reply With Quote
Thanked by:
  #10 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



eros1973ms View Post
Only problem with this is that I don't have a DatetimetoEltime function! I am on v8.7...maybe this is why?
I only have the datetimetostring and the stringtodate, but does not seem to work.

Hm, true, TradeStation doesn't have that word (I'm a MultiCharts user). I've just scanned through the TradeStation 8.3 EasyLanguage manual, and using the reserved words that I found there, something like this should work..

 
Code
variables: leftDate(0), leftTime(0), rightDate(0), rightTime(0);

if LastBarOnChart_s = true then begin

    leftDate = JulianToDate(GetAppInfo(aiLeftDispDateTime));
    leftTime = (HoursFromDateTime(GetAppInfo(aiLeftDispDateTime)) * 10000) + 
        (MinutesFromDateTime(GetAppInfo(aiLeftDispDateTime)) * 100) +
        SecondsFromDateTime(GetAppInfo(aiLeftDispDateTime));

    value10 = Text_new_s(leftDate, leftTime, Low - 0.02, "Hello");
    value11 = Text_SetStyle(value10, 0, 2);
    
    rightDate = JulianToDate(GetAppInfo(aiRightDispDateTime));
    rightTime = (HoursFromDateTime(GetAppInfo(aiRightDispDateTime)) * 10000) + 
        (MinutesFromDateTime(GetAppInfo(aiRightDispDateTime)) * 100) +
        SecondsFromDateTime(GetAppInfo(aiRightDispDateTime));
    
    value15 = Text_new_s(rightDate, rightTime, High + 0.02, "GoodBye");
    value16 = Text_SetStyle(value15, 1, 2);
    
end;
Since I don't use TradeStation, I don't know if it would work, but it contains a workaround for not using DateTime2ELTime_s and thus (in theory) should work for TradeStation (it works here on MultiCharts fine).

Good luck.

Reply With Quote
Thanked by:




Last Updated on May 9, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts