Plotting H & L of day problem

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
sptrader
Posts: 633
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 394 times
Been thanked: 236 times
Contact:

Plotting H & L of day problem

Postby sptrader » 15 Nov 2011

I'm just trying to plot the high or low of the day, ONLY plotting from the "current" high or low.. As the study is written, it plots ALL highs and lows of the day, bar by bar.
When a new high or low happens, I'd like it to redraw(erasing previous line), from the new high or low point forward only..
I'm having a "Perry" moment and am stuck..(tried noplot, when H > hod etc) with no luck.


Code: Select all

vars:hod(0),Lod(0);

HOD= highD(0);
LOD = LOWD(0);

plot1(hod,"hi");
plot2(Lod,"Lod");

User avatar
TJ
Posts: 6568
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1898 times

Re: Plotting H & L of day problem

Postby TJ » 15 Nov 2011

sptrader wrote:I'm just trying to plot the high or low of the day, ONLY plotting from the "current" high or low.. As the study is written, it plots ALL highs and lows of the day, bar by bar.
When a new high or low happens, I'd like it to redraw(erasing previous line), from the new high or low point forward only..
I'm having a "Perry" moment and am stuck..(tried noplot, when H > hod etc) with no luck.


Code: Select all

vars:hod(0),Lod(0);

HOD= highD(0);
LOD = LOWD(0);

plot1(hod,"hi");
plot2(Lod,"Lod");

it would be easier to use trendlines.

try this:

Code: Select all

var:
tl.h(-1),
tl.l(-1);

once
begin
   tl.h = tl_new(d, t, 0, d, t, 0);
   tl_setextright(tl.h, true);
   tl_setextleft(tl.h, true);  // <-- comment this out if you want forward only

   tl.l = tl_new(d, t, 0, d, t, 0);
   tl_setextright(tl.l, true);
   tl_setextleft(tl.l, true);  // <-- comment this out if you want forward only
end;

tl_setend(tl.h, d, t, highd(0));
tl_setbegin(tl.h, d[1], t[1], highd(0));

tl_setend(tl.l, d, t, lowd(0));
tl_setbegin(tl.l, d[1], t[1], lowd(0));


[note: code revised 20111115 1330]

User avatar
TJ
Posts: 6568
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1898 times

Re: Plotting H & L of day problem

Postby TJ » 15 Nov 2011

sptrader wrote:I'm just trying to plot the high or low of the day, ONLY plotting from the "current" high or low.. As the study is written, it plots ALL highs and lows of the day, bar by bar.
When a new high or low happens, I'd like it to redraw(erasing previous line), from the new high or low point forward only..
I'm having a "Perry" moment and am stuck..(tried noplot, when H > hod etc) with no luck.


Code: Select all

vars:hod(0),Lod(0);

HOD= highD(0);
LOD = LOWD(0);

plot1(hod,"hi");
plot2(Lod,"Lod");


if you want to use plot,
you have to set up a counter to count how many bars since the beginning of the day.

You then create a loop,
every time a new high or a new low is made,
you have to re-plot the highd or lowd, using the loop, every bar since the beginning of the day.

sptrader
Posts: 633
Joined: 09 Apr 2010
Location: Colorado
Has thanked: 394 times
Been thanked: 236 times
Contact:

Re: Plotting H & L of day problem

Postby sptrader » 15 Nov 2011

Thanks TJ !
It works great with trendlines !

(now I may try it with the loop)


Return to “User Contributed Studies and Indicator Library”