[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EL question regarding text display



PureBytes Links

Trading Reference Links

Kimball,

The following pertains to TS2000i, it *may* also work in TS4.
Although it is a relatively simple matter to place text on the "right
side" of the screen, I am not sure of a practical way of putting it in
the "upper corner", since the verticle location must be specified
relative to price (usually).  Example 1 shows the text at the same
location as the endpoint of the moving average:

Example1
----------------------------  cut here  --------------------------
{	Bob Perry 3/01, **BP Example1	}

Vars:	MA_value(close), MA_location(close), MA_ref(-1) ;

If Date = CurrentDate AND time >= LastCalcTime then begin
	
{----  set variables and conditions  ----}

MA_value = Average(Close,20);
MA_location = MA_value;

{----  write text to screen  ----}

MA_ref = Text_New(Date, Time, MA_location, NumToStr(MA_value, 0));

Text_SetStyle(MA_ref, 1, 2);
Text_SetColor(MA_ref, white);

If MA_ref > 0 then Text_Delete(MA_ref-1);

End;
----------------------------  cut here  --------------------------

Notice that on the first bar of evaluation MA_ref will equal -1. 
Thereafter, MA_ref will have an ID number, probably "text#0".  If there
is a bug, this is probably where I screwed up and you should replace the
appropriate code as it's shown in the Omega Reference Guide (pg80).  You
also have to set the style and color.

Additionally, you might set the location to be above or below the MA
(opposite the side the price bars are.)  See Example 2:

Example2
----------------------------  cut here  --------------------------
{	Bob Perry 3/01, **BP Example2	}

Inputs:	Offset (20);	{ adjust for what market you trade }
Vars:	MA_value(close), MA_location(close), MA_ref(-1) ;

If Date = CurrentDate AND time >= LastCalcTime then begin
	
{----  set variables and conditions  ----}

MA_value = Average(Close,20);

If High < MA_value then
	MA_location = MA_value + Offset
	else MA_location = MA_value - Offset;

{----  write text to screen  ----}

MA_ref = Text_New(Date, Time, MA_location, NumToStr(MA_value, 0));

Text_SetStyle(MA_ref, 1, 2);
Text_SetColor(MA_ref, white);

If MA_ref > 0 then Text_Delete(MA_ref-1);

End;
----------------------------  cut here  --------------------------

you can also change the color of the text depending on whether or not
the MA is going "up" or "down".  see next example:

Example3
----------------------------  cut here  --------------------------
{	Bob Perry 3/01, **BP Example3	}

Inputs:	Offset (20);	{ adjust for what market you trade }
Vars:	MA_value(close), MA_location(close), MA_ref(-1) ;

If Date = CurrentDate AND time >= LastCalcTime then begin
	
{----  set variables and conditions  ----}

MA_value = Average(Close,20);

Condition1 = MA_value >= MA_value[1];
Condition2 = MA_value < MA_value[1];

If High < MA_value then
	MA_location = MA_value + Offset
	else MA_location = MA_value - Offset;

{----  write text to screen  ----}

MA_ref = Text_New(Date, Time, MA_location, NumToStr(MA_value, 0));

Text_SetStyle(MA_ref, 1, 2);

If Condition1 then Text_SetColor(MA_ref, cyan);
If Condition2 then Text_SetColor(MA_ref, magenta);

If MA_ref > -1 then Text_Delete(MA_ref-1);

End;
----------------------------  cut here  --------------------------

Now, sometimes the MA will be at the top (or bottom) of the screen and
you won't be able to see the text because, unlike an indicator, it will
go off the screen.  In this case you will need to plot a line (small
point, color = background) above the text when it's on top, or below it
when it's on the bottom.  see next example:

Example4
----------------------------  cut here  --------------------------
{	Bob Perry 3/01, **BP Example4	}

Inputs:	Offset (20);	  {adjust for what market you trade}
Vars:	MA_value(close), MA_location(close), MA_ref(-1) ;

If Date = CurrentDate AND time >= LastCalcTime then begin
	
{----  set variables and conditions  ----}

MA_value = Average(Close,20);

Condition1 = MA_value >= MA_value[1];
Condition2 = MA_value < MA_value[1];

If High < MA_value then
	MA_location = MA_value + Offset
	else MA_location = MA_value - Offset;

Condition3 = MA_location > MA_value;
Condition4 = MA_location < MA_value;

{----  write text to screen  ----}

MA_ref = Text_New(Date, Time, MA_location, NumToStr(MA_value, 0));

Text_SetStyle(MA_ref, 1, 2);

If MA_ref > -1 then Text_Delete(MA_ref-1);

If Condition1 then Text_SetColor(MA_ref, cyan);
If Condition2 then Text_SetColor(MA_ref, magenta);

If Condition3 then Plot1(MA_location + 2,"upr");  {adjust for what
market you trade}
If Condition4 then Plot2(MA_location - 2,"lwr");  {adjust for what
market you trade}

End;
----------------------------  cut here  --------------------------

I attached example 4.  Hope it came through.  I have not had a chance to
debug this in real time(!) so it might have a bug or two... but the form
should work.  One other hint, to prevent "video blinking", uncheck
"update every tick".
If you find a way to place text in the "upper right corner" please let
me know how!

Hope this helps.
Bob Perry
San Jose, CA



Kimball Morgan <km11@xxxxxxxxxxx> wrote:


After attempting modified versions of the examples in the EL Reference
Guide, I thought I'd ask for some pointers from the List instead of
developing a permanent crease in my forehead.

My goal is to have an updating text display in the upper right corner of
the
chart, showing the price value of a moving average one bar ago.

First, can this be done?  Any ideas or pointers to appropriate study
materials greatly welcomed.

Attachment: Description: "BP EXAMPLE4.ELA"