How to create a text/info box on the chart

Questions about MultiCharts and user contributed studies.
User avatar
BB123
Posts: 68
Joined: 24 Nov 2023
Has thanked: 22 times
Been thanked: 10 times

How to create a text/info box on the chart

Postby BB123 » 24 Jan 2024

Anyone know how to place a text/data box on the chart.. When im testing my scripts-- i like to see that the data im getting from some of my vars is correct... In MT4 i use a comments box which updates the values each bar and shows the value inside the box i have on the chart.. .. I havnt been able to see how i can do that in MC .. :roll:

Here is what im trying to achieve..
mt4 text window.JPG
(51.27 KiB) Not downloaded yet

I tried using the "expert commentary window"... But it wouldn't update the values as i did a back test using the "jump to bar"-- and if i clicked on the last bar trying to get a value-- all the trades would just be removed from the chart and id end up with no values......

User avatar
Polly MultiCharts
Posts: 203
Joined: 20 Jul 2022
Has thanked: 1 time
Been thanked: 55 times

Re: How to create a text/info box on the chart

Postby Polly MultiCharts » 25 Jan 2024

Hello BB123,

You might use the Chart Hint (View → Show Chart Hint) or Data Window (View → Show Data Window) for that.
You might also use the text drawings to output the desired info.

User avatar
BB123
Posts: 68
Joined: 24 Nov 2023
Has thanked: 22 times
Been thanked: 10 times

Re: How to create a text/info box on the chart

Postby BB123 » 04 Feb 2024

Hi Polly

Data window isnt what i was looking for..Im wanting to see what my current var values are... Vs the data window which is just showing high/open/low/close and a few other things.. But none of my own vars that are being used..

I tried the expert commentary-- but it wasnt quite what i was looking for.. Since to get the values i have to click on the chart and have my signal fire off and update var values.. (though i think i read that doing that will show var values and not update them)... Ill explore Text drawings more.. Im thinking i can put a box on the chart and just write text into the box with my current var values...

For those wondering why i want to see my current var values-- its just to make 10000% sure im working off the correct data in my coding.. Can't even say how many times Ive been calculating a result with some wrong var value in there.. (hitting head against the wall)..

User avatar
Polly MultiCharts
Posts: 203
Joined: 20 Jul 2022
Has thanked: 1 time
Been thanked: 55 times

Re: How to create a text/info box on the chart

Postby Polly MultiCharts » 06 Feb 2024

BB123,

You can use Text Drawings for that purpose.
Text Drawings can display any information, including variable values. The info they display depends on how you specify that in your script.

User avatar
BB123
Posts: 68
Joined: 24 Nov 2023
Has thanked: 22 times
Been thanked: 10 times

Re: How to create a text/info box on the chart

Postby BB123 » 08 Feb 2024

Hi Polly.. We were on the same page.. I had looked into text drawing from your advice at the top... and realized i can place the text anywhere on the chart.. Easy enough..

Thanks for your help..

User avatar
BB123
Posts: 68
Joined: 24 Nov 2023
Has thanked: 22 times
Been thanked: 10 times

Re: How to create a text/info box on the chart

Postby BB123 » 15 Mar 2024

So here is a pic of what i ended up coming up with..
text_On_screen_example.JPG
(29.21 KiB) Not downloaded yet
If its something that anyone wants-- then here is the code..

Code: Select all

//this puts text on chart Inputs: ShowText(true),TextSize(11),BackGroundColor(black),TextColor(White),PlaceABorder(false),BarsInFromLeft(1); vars: forBar(0), count(0),LastCandleTime(datetime),TextBox(0), jDateTime(datetime),jDateTimeNew(datetime),FirstBarDate(datetime),FirstBarTime(datetime),TextNumber(0),lastdate(0); jDateTimeNew = GetAppInfo(aiLeftDispDateTime); if jDateTimeNew <> jDateTime then begin Text_delete(TextBox); jDateTime = GetAppInfo(aiLeftDispDateTime); FirstBarDate = JulianToDate( IntPortion(jDateTime ) ) ; FirstBarTime = MinutesToTime( FracPortion(jDateTime ) * 60 * 24 ) ; TextBox=Text_New(FirstBarDate , FirstBarTime + BarsInFromLeft, GetAppInfo(aiHighestDispValue ) ,""); Text_SetString(TextBox,"ask " + " : " + NumToStr(insideask,2) + NewLine + "bid " + " : " + NumToStr(insidebid,2) + NewLine + "close " + " : " + NumToStr(Close,2) + NewLine + "marketposition " + " : " + NumToStr(marketposition ,0) //add new line here + NewLine + "" );//this is the end line.. so just put new lines above this line Text_SetStyle(TextBox, 0, 0); Text_SetColor(TextBox, TextColor); Text_SetSize(TextBox, TextSize); Text_SetFontName(TextBox, "Arial Black"); Text_Setattribute(TextBox,0,true); Text_SetBorder(TextBox,PlaceABorder); Text_SetBGColor(TextBox, BackGroundColor); count = 0; LastCandleTime= GetAppInfo(aileftdispdatetime); end; { // this puts text in print output area Inputs:showVars(true); if LastBarOnChart_s and showVars then begin print ( "ask " + " : " + NumToStr(insideask,2) + NewLine + "bid " + " : " + NumToStr(insidebid,2) + NewLine + "close " + " : " + NumToStr(Close,2) + NewLine + "marketpos " + " : " + NumToStr(marketposition ,0) + NewLine + "" ); End; }

Lupomanu32
Posts: 7
Joined: 20 Nov 2023

Re: How to create a text/info box on the chart

Postby Lupomanu32 » 26 Mar 2024

Thanks

Lupomanu32
Posts: 7
Joined: 20 Nov 2023

Re: How to create a text/info box on the chart

Postby Lupomanu32 » 26 Mar 2024

This is my code and all is ok.
Someone could advise me to make more beauty this box?
How can I change, for example, the colour of close if this value is greater than the max of last 5 session?
How Can I make "interactive" this box?


Code: Select all

//this puts text on chart Inputs: ShowText(true),TextSize(11),BackGroundColor(black),TextColor(White),PlaceABorder(false),BarsInFromLeft(1); vars: forBar(0), count(0),LastCandleTime(datetime),TextBox(0), jDateTime(datetime),jDateTimeNew(datetime),FirstBarDate(datetime),FirstBarTime(datetime),TextNumber(0),lastdate(0); If LastBarOnChart then begin jDateTimeNew = GetAppInfo(aiLeftDispDateTime); if jDateTimeNew <> jDateTime then begin Text_delete(TextBox); jDateTime = GetAppInfo(aiLeftDispDateTime); FirstBarDate = JulianToDate( IntPortion(jDateTime ) ) ; FirstBarTime = MinutesToTime( FracPortion(jDateTime ) * 60 * 24 ) ; TextBox=Text_New(FirstBarDate , FirstBarTime + BarsInFromLeft, GetAppInfo(aiHighestDispValue ) ,""); Text_SetString(TextBox," --------------- INFO BOX --------------- " + NewLine + "Account " + " : " + GetAccountID() + NewLine + "DateTime " + " : " + datetimetostring(datetime) + NewLine + "Exchange " + " : " + exchlisted + NewLine + "Symbol " + " : " + description + NewLine + "Ticker " + " : " + rtsymbolname + NewLine + "Big Point Value " + " : " + NumToStr(BigPointvalue ,2) + NewLine + "Price Scale " + " : " + NumToStr(PriceScale, 2) + NewLine + "Min Move " + " : " + NumToStr(Minmove, 2) + NewLine + "Point " + " : " + NumToStr((1/Pricescale), 2) + NewLine + "Point Value " + " : " + NumToStr(Pointvalue ,2) //+ NewLine + "ask " + " : " + NumToStr(insideask,2) //+ NewLine + "bid " + " : " + NumToStr(insidebid,2) + NewLine + "Total Market Position " + " : " + NumToStr(marketposition_at_broker, 0) + NewLine + "Strategy Market Position " + " : " + NumToStr(marketposition_at_broker_for_the_Strategy, 0) + NewLine + "OpenS0 " + " : " + NumToStr(OpenS(0),2) + NewLine + "HighS0 " + " : " + NumToStr(HighS(0),2) + NewLine + "LowS0 " + " : " + NumToStr(LowS(0),2) + NewLine + "close " + " : " + NumToStr(Close,2) + NewLine + "Max Last 5 Session " + " : " + NumToStr(Maxlist(HighS(1), HighS(2), HighS(3), HighS(4), HighS(5)),2) + NewLine + "Min Last 5 Session " + " : " + NumToStr(Minlist(LowS(1), LowS(2), LowS(3), LowS(4), LowS(5)),2) + NewLine + "Max Last 4 Weeks " + " : " + NumToStr(Maxlist(HighW(1), HighW(2), HighW(3), HighW(4)),2) + NewLine + "Min Last 4 Weeks " + " : " + NumToStr(Minlist(LowW(1), LowW(2), LowW(3), LowW(4)),2) //+ NewLine + "marketposition " + " : " + NumToStr(marketposition ,0) //+ NewLine + "Margine " + " : " + NumToStr(Margin ,2) //add new line here + NewLine + "" );//this is the end line.. so just put new lines above this line Text_SetStyle(TextBox, 0, 0); Text_SetColor(TextBox, TextColor); Text_SetSize(TextBox, TextSize); Text_SetFontName(TextBox, "Arial Black"); Text_Setattribute(TextBox,0,true); Text_SetBorder(TextBox,PlaceABorder); Text_SetBGColor(TextBox, BackGroundColor); count = 0; LastCandleTime= GetAppInfo(aileftdispdatetime); end; end; { // this puts text in print output area Inputs:showVars(true); if LastBarOnChart_s and showVars then begin print ( "ask " + " : " + NumToStr(insideask,2) + NewLine + "bid " + " : " + NumToStr(insidebid,2) + NewLine + "close " + " : " + NumToStr(Close,2) + NewLine + "marketpos " + " : " + NumToStr(marketposition ,0) + NewLine + "" ); End; }


Return to “MultiCharts”