Page 1 of 1

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

Posted: Dec 26 2015
by arjfca
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

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

Posted: Dec 26 2015
by TJ
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.

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

Posted: Dec 26 2015
by arjfca
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

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

Posted: Dec 29 2015
by OZ Trade
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.