Code to put Text on chart: possible to have it permanent?

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

Code to put Text on chart: possible to have it permanent?

Postby arjfca » 26 Dec 2015

Hello

A small code is putting text number on charts using a mouse click. This is done manually, a click at a given location and a number is installed

How can I have these numbers be permanent on the screen. Each time I recalculate, reload, re-scale, they disappear.

Code to show a reference number on screen

Code: Select all

if (MouseClickCtrlPressed and MouseClickShiftPressed) then begin
ClickTime = MouseClickDateTime;
BN = MouseClickBarNumber;
PriceVal = MouseClickPrice;

ValToShow = GVGetNamedInt("Filename_B",0);
GVSetNamedInt("Filename_B",ValtoShow + 1);
TextVal = text_new_BN(BN, PriceVal, numtostr(ValtoShow,0));
Text_SetBorder(TextVal, True);
text_SetColor(textVal,Black);
text_setsize(TextVal,14);

end;
reference numbers.png
(101.68 KiB) Downloaded 752 times

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

Re: Code to put Text on chart: possible to have it permanent

Postby TJ » 26 Dec 2015

Hello

A small code is putting text number on charts using a mouse click. This is done manually, a click at a given location and a number is installed

How can I have these numbers be permanent on the screen. Each time I recalculate, reload, re-scale, they disappear.

Code to show a reference number on screen
::
If the text is created by a logic in an indicator, the text will change every time the indicator is recalculated.

The only way to make the text permanent is to type the text manually.

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

Re: Code to put Text on chart: possible to have it permanent

Postby arjfca » 26 Dec 2015

Hello

A small code is putting text number on charts using a mouse click. This is done manually, a click at a given location and a number is installed

How can I have these numbers be permanent on the screen. Each time I recalculate, reload, re-scale, they disappear.

Code to show a reference number on screen
::
If the text is created by a logic in an indicator, the text will change every time the indicator is recalculated.

The only way to make the text permanent is to type the text manually.
I understand that but the only logic in use here is the click event. That would be nice that MC add a text permanent option.

I will work to add a subroutine to scroll trough the installed number, save them and recall whenever the indicator is recalculated

Happy New Year TJ

Martin

OZ Trade
Posts: 39
Joined: 08 Nov 2013
Has thanked: 11 times
Been thanked: 18 times

Re: Code to put Text on chart: possible to have it permanent

Postby OZ Trade » 29 Dec 2015

Basic indicator to redraw txt objects whose bardate, bartime, pricevalue and "text" have been stored in a txt file "List of Lists" using ELCollections

Code: Select all

Vars: LoopVar (0), Length (0), list_ids (0), txt_ids (0);

If lastbaronchart then begin

list_ids= ListC.New;

If ELC.PathExists("C:\Users\xxxx\xxxx\xxxx\xxxx\"
+getsymbolname+"-"+text(bartype_ex:1:0)+"."+text(barinterval:1:0)+".txt")= False
then
Value1 = ListC.WriteFile(list_ids, "C:\Users\xxxx\xxxx\xxxx\xxxx\"
+getsymbolname+"-"+text(bartype_ex:1:0)+"."+text(barinterval:1:0)+".txt");

Value1 = ListC.ReadFile(list_ids, "C:\Users\xxxx\xxxx\xxxx\xxxx\"
+getsymbolname+"-"+text(bartype_ex:1:0)+"."+text(barinterval:1:0)+".txt");

Length= ListC.Count(list_ids);

If Length > 0 then for LoopVar= 1 to Length begin

txt_ids= ListC.Get(list_ids, LoopVar);

text_new(ListN.Get(txt_ids,1),ListN.Get(txt_ids,2),ListN.Get(txt_ids,3),text(ListN.Get(txt_ids,4)));

End;

End;
Of course your indicator would first need to store these values to the relevant txt file as you click the mouse and they appear on the screen.

Merry christmas and happy new year to all.


Return to “MultiCharts”