Put text on the right top corner: visual fix location  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Put text on the right top corner: visual fix location

Postby arjfca » 06 Nov 2013

Hello

I want to code to show, on the top right corner of my chart the value of the actual spread (bid-ask)

I know I could get the value from GetApiInfo for the time and price

My interrogation is more, How can I calculate to have the string at a visually fix location. A pip does not have the same value depending the pair that i trade or the zoom applied to the charts
Just like the status line, it is always at the same visual location with all charts.

Martin :)

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Put text on the right top corner: visual fix location

Postby ABC » 06 Nov 2013

Hi Martin,

you can accomplish this with aiHighestDispValue and aiLowestDispValue. Take a look at the Text_Float function, that should be build into MC, if not let me know and I will post it here.

Another idea would be to paste the text in the status line using plot from an indicator. Like the --- Market Depth on Chart --- indicator does for example.

Regards,
ABC

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Put text on the right top corner: visual fix location

Postby TJ » 06 Nov 2013

Hello
I want to code to show, on the top right corner of my chart the value of the actual spread (bid-ask)
I know I could get the value from GetApiInfo for the time and price
My interrogation is more, How can I calculate to have the string at a visually fix location. A pip does not have the same value depending the pair that i trade or the zoom applied to the charts
Just like the status line, it is always at the same visual location with all charts.
Martin :)
If you are using sub-minute charts or non-time based charts, you have to use the _s suffix on the text keywords.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Put text on the right top corner: visual fix location

Postby arjfca » 06 Nov 2013

Any idea where could be the error. Nothing is display

** This code section extract from the main indicator

Get the Highest display value
Get the date and time of the last visible bar on the chart

In the text location
Extract the date frim the Date_and_time
Extract time from Date_and_time

The Text_new is created once. The same Text variable is use

Code: Select all

Var:
SpreadTextLine (0),
Spreadtext (""),
Spread (0),
HighLocation (0),
Date_And_Time (0),
HighRoundedup (0),
LowRoundedDown (0),
ID_SpreadTextLine (0);

SpreadtextLine = Text_New_self (date, time, 0, "Text"); // create the Text_New

// this section is the first line that is place at the top of the code...

Highlocation = getappinfo(aiHighestdispValue);
Date_And_Time = getappinfo(aiRightDispDateTime);
Spread = (InsideBid -InsideAsk);
SpreadText = NumtoStr(Spread,5);
text_setLocation(SpreadtextLine,intportion(Date_And_Time),datetime2eltime(Date_And_Time),highlocation);

Text_SetString( SpreadtextLine , ("SPread: " + Spreadtext));
Martin

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Put text on the right top corner: visual fix location

Postby TJ » 06 Nov 2013

look up

TEXT_SETSTYLE

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Put text on the right top corner: visual fix location

Postby arjfca » 06 Nov 2013

Still nothing on the screen

- Tried the setstyle 0,1,2
- Added color
- used the lastbar time

Martin

Code: Select all

once begin
SpreadtextLine = Text_New_self (date, time, 0, "Text");
Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 12);
Text_setcolor(SpreadtextLine, blue);
end;


Highlocation = getappinfo(aiHighestdispValue);
Date_And_Time = getappinfo(aiRightDispDateTime);
Spread = (insideask -insidebid)*10000;
SpreadText = NumtoStr(Spread,5);


text_setLocation(SpreadtextLine,intportion(Date_And_Time),time_s,highlocation);
Text_SetString( SpreadtextLine , ("SPread: " + Spreadtext));
Martin
Attachments
Textline.png
(133.92 KiB) Downloaded 824 times

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Put text on the right top corner: visual fix location

Postby ABC » 06 Nov 2013

At a quick glance you are using text_setLocation with time_s. This will surely create problems. Use text_setLocation_s or text_setLocation_dt.

Regards,
ABC

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Put text on the right top corner: visual fix location  [SOLVED]

Postby ABC » 06 Nov 2013

You should also apply this to Text_New_self. If you are using Text_New_self and having the indicator running in a subchart, shouldn't the text appear in that subchart, too (I am guessing that SetScreenLocation is the name of your indicator)?

Regards,
ABC

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Put text on the right top corner: visual fix location

Postby arjfca » 06 Nov 2013

ABC, TJ

Text_Float was the solution

Code: Select all

If lastbaronchart then begin
Spread = (insideask -insidebid) ;
If jpy_pair = true then spread = spread *1000 else spread = spread *10000;
SpreadText ="Spread: " + NumtoStr(Spread ,2);

SpreadtextLine = Text_New_s (0,0,0, Spreadtext);
Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 10);
Text_setcolor(SpreadtextLine, blue);

value2 =Text_float (SpreadTextLine,25,100);
end;
Attachments
Spread.png
(34.71 KiB) Downloaded 825 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Put text on the right top corner: visual fix location

Postby TJ » 06 Nov 2013

ABC, TJ
Text_Float was the solution
LOL... ABC told you that in post #2. :-)

Glad you made it working,
and thanks for sharing your code.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Put text on the right top corner: visual fix location

Postby arjfca » 07 Nov 2013

LOL... ABC told you that in post #2. :-)

Glad you made it working,
and thanks for sharing your code.
I'M an old old adolescent... Did you follow all your parent advise??....Yo man :)

A little problem remain. The line is unreadable the first time that I the chart is loaded. I need to reload by changing the scale to get it clear. The problem disappear after changing the scale and returning to the original.


Martin
Attachments
spread_2.png
(39.06 KiB) Downloaded 815 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Put text on the right top corner: visual fix location

Postby TJ » 07 Nov 2013

I'M an old old adolescent... Did you follow all your parent advise??....Yo man :)
A little problem remain. The line is unreadable the first time that I the chart is loaded. I need to reload by changing the scale to get it clear. The problem disappear after changing the scale and returning to the original.
Martin
try this:

Code: Select all

once begin
SpreadtextLine = Text_New(0,0,0, "");
end;

If lastbaronchart then begin
Spread = (insideask -insidebid) ;
If jpy_pair = true then spread = spread *1000 else spread = spread *10000;

Text_setString(SpreadtextLine, "Spread: " + NumtoStr(Spread ,2));

Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 10);
Text_setcolor(SpreadtextLine, blue);

value2 =Text_float (SpreadTextLine,25,100);
end;

ps. I have not tested this... will test it as soon as I have MultiCHarts loaded.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Put text on the right top corner: visual fix location

Postby arjfca » 07 Nov 2013

I'M an old old adolescent... Did you follow all your parent advise??....Yo man :)
A little problem remain. The line is unreadable the first time that I the chart is loaded. I need to reload by changing the scale to get it clear. The problem disappear after changing the scale and returning to the original.
Martin
try this:

Code: Select all

once begin
SpreadtextLine = Text_New(0,0,0, "");
end;

If lastbaronchart then begin
Spread = (insideask -insidebid) ;
If jpy_pair = true then spread = spread *1000 else spread = spread *10000;

Text_setString(SpreadtextLine, "Spread: " + NumtoStr(Spread ,2));

Text_setStyle(SpreadtextLine,1,2);
Text_SetSize(SpreadtextLine, 10);
Text_setcolor(SpreadtextLine, blue);

value2 =Text_float (SpreadTextLine,25,100);
end;

ps. I have not tested this... will test it as soon as I have MultiCHarts loaded.
Thanks TJ, Just resolved the problem by rewriting the code to use the GetAppInfo directly instead of using the Text_Float

Coded posted there
See viewtopic.php?f=1&t=45615&p=99649#p99649

Martin


Return to “MultiCharts”