Page 1 of 1

TL_OpenPosition

Posted: 12 Aug 2009
by TJ
function: TL_OpenPosition

description:
this function will draw a line from the open position entry date/time/price
to the latest close.

usage format:
add this line to the end of your strategy:

value1 = TL_OpenPosition( 1, 0.5, darkgreen, red);


Image

Code: Select all

// function: TL_OpenPosition
// version beta 0.1
// author: TJ
// date: 20090811
// license: public use
// terms of use: this header must be included
// description:
// this function will draw a line from the open position entry date/time/price
// to the latest close.
//
// format:
// add this line to your strategy:
// value1 = TL_OpenPosition( tl.style, tl.size, color.profit, color.loss);
//


input:
tl.style(NumericSimple),
tl.size(NumericSimple),
color.profit(NumericSimple),
color.loss(NumericSimple);

var:
id.tl(-1);

if currentbar = 1 then
id.tl = tl_new( d, t, c, d, t, c);

if marketposition = 0 or entrytime = time then
begin
tl_setbegin( id.tl, entrydate(1), entrytime(1), 0);
tl_setend( id.tl, entrydate(1), entrytime(1), 0);
end
else
begin
tl_setbegin( id.tl, entrydate, entrytime, entryprice);
tl_setend( id.tl, d, t, c);
tl_setstyle(id.tl, tl.style);
tl_setsize(id.tl, tl.size);
if positionprofit > 0 then
tl_setcolor(id.tl, color.profit)
else
tl_setcolor(id.tl, color.loss);
end;

TL_OpenPosition = 1;