TL_OpenPosition

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
TJ
Posts: 7395
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 996 times
Been thanked: 2118 times

TL_OpenPosition

Postby TJ » 12 Aug 2009

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;
Attachments
TL_OpenPosition.jpg
TL_OpenPosition
(55.3 KiB) Downloaded 555 times

Return to “User Contributed Studies and Indicator Library”