charvo wrote:Hi, Kelvin:
I updated my code as below, [ObjectExists()] return true, which confused me a lot. From log, i keep getting "OBJ EXISTS??????!!!!!!" as a result of [objectexists()].
anyway, i tried everything i can think of, my code just don't display anything......
please help,
Code: Select all
procedure HUDprojector1(note:string; colorcode: Tcolor; timecoord: integer; pricecoord: integer);
var
ObjHUDline1: string;
begin
if SetCurrencyAndTimeframe(sym[1], 60) then print(sym[1] + ' is set for HUD().')
else print('sym[1] is NOT set!');
ObjHUDline1 := 'happy';
if (not ObjectExists(ObjHUDline1)) then
begin
if ObjectCreate(ObjHUDline1, OBJ_TEXT, 0, Time(0), High(0)) then print('obj created')
else print('obj NOT created');
if ObjectSetText(ObjHUDline1, 'nima', 9, 'Arial', colorcode) then print('text set')
else print('text NOT set');
if ObjectSet(ObjHUDline1, OBJPROP_SCREENCOORDS,3) then print('corner set')
else print('corner NOT set');
if ObjectSet(ObjHUDline1, OBJPROP_TIME1, timecoord) then print('timecorrd set')
else print('timecorrd NOT set');
if ObjectSet(ObjHUDline1, OBJPROP_PRICE1,pricecoord) then print('pricecorrd set')
else print('pricecorrd NOT set');
end
else
print('OBJ EXISTS??????!!!!!!');
end;
//----------------------------------------------------------
change to HUDprojector1(..., TDatetime, double)
Use HUDprojector1(..., Time(0), High(0)) to call again and verify the
procedure is working.
Looking into the following to see how to set label.
http://forextester.com/forum/viewtopic. ... ht=objtextObjectSet(ObjName,OBJPROP_SCREENCOORDS,1);
to change to screen coordinate (X,Y) instead of time/price coordinate
Code: Select all
procedure HUDprojector1(note:string; colorcode: Tcolor; X,Y: integer);
var
ObjHUDline1: string;
begin
SetCurrencyAndTimeframe(sym[1], 60);
ObjHUDline1 := 'happy';
if not(ObjectExists(ObjHUDline1)) then
ObjectCreate(ObjHUDline1, obj_Text, 0, 0, 0);
ObjectSetText(ObjHUDline1, note, 9, 'Arial', colorcode);
ObjectSet(ObjHUDline1, OBJPROP_SCREENCOORDS, 1);
ObjectSet(ObjHUDline1, OBJPROP_TIME1, X);
ObjectSet(ObjHUDline1, OBJPROP_PRICE1,Y);
{=============
// text alignment
tlTop = 0;
tlCenter = 1;
tlBottom = 2;
============}
ObjectSet(ObjHUDline1, OBJPROP_VALIGNMENT, tlBottom);
{===============
taLeftJustify = 0;
taRightJustify = 1;
taCenter = 2;
===============}
ObjectSet(ObjHUDline1, OBJPROP_HALIGNMENT, taRightJustify);
{====================================
OBJPROP_SCRVALIGNMENT = 0 – no vertical alignment
OBJPROP_SCRVALIGNMENT = 1 –align to bottom
OBJPROP_SCRVALIGNMENT = 2 –align to top
====================================}
ObjectSet(ObjHUDline1, OBJPROP_SCRVALIGNMENT, 1);
{====================================
OBJPROP_SCRHALIGNMENT = 0 – no horizontal alignment
OBJPROP_SCRHALIGNMENT = 1 –align to right
OBJPROP_SCRHALIGNMENT = 2 –align to left
====================================}
ObjectSet(ObjHUDline1, OBJPROP_SCRHALIGNMENT, 1);
On the call to HUDprojector1(infonote1, clGreen, 1000, 90);
Try to set the X & Y to 20,20 to top left so that visible then adjust X, Y value to move the label to the extreme top right visible position.