logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
knorthington  
#1 Posted : Thursday, November 29, 2007 1:04:52 PM(UTC)
knorthington

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 4/30/2006(UTC)
Posts: 15
Location: North Carolina

I want to plot a custom indicator line only a few bars after it initially plotts. The objective is to have the indicator underline a price level but only for a few days. After a few periods go by I want the line to stop plotting, but leave the line that has been plotted in place.
Is this possible? Can you give me a code sample so that I understand the syntax?
Thanks,
K
johnl  
#2 Posted : Saturday, December 1, 2007 7:59:25 PM(UTC)
johnl

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/7/2005(UTC)
Posts: 602

When I have an indicator that switches on and off I use an IF statement to turn it into 1's and 0's so
I can see what I am doing..
To kill a signal I might try BARSSINCE, If(BarsSince(C=A)<4,1,0) should plot a one up to 3 periods
after (C=A) was true and 0 after that.
I am no pro so I would have to play with the code to make sure it all works but that is where I would start.
mstt  
#3 Posted : Saturday, December 1, 2007 11:32:26 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

K

In the August issue of MSTT I explained one method that should allow you to do what you want. The only drawback that I can see is that the line would have to be dotted (bottom of the available Styles list) so as not to create additional clutter. There are two things that my approach would need.

1. Clearly defined events to trigger each line segment.

2. Clearly defined values at which to plot the line.

I envisage a single bar event being used to trigger an alert, thus providing the device to set the length of the line. ValueWhen(1, event, price) could then be used to set the price for the line. These signals could then be combined to plot the line value for the required number of bars and zero for all other bars.

If(Alert( event, {plot} periods), ValueWhen(1, event, line), 0);

What you have at this point is a plot that switches between line value and zero. Unfortunately the signal you now have cannot be scaled to the price chart because it will distort that chart, as well as plot zero many bars. The trick to keeping your plot scaled to price without distortion is to generate an N/A plot as the last indicator output. ValueWhen(1,1=0,0) will do the trick nicely. This expression cannot plot anything because 1=0 is never TRUE and so never provides an event to kick start ValueWhen().

Here's a working example based on a PS Trading System pivot low pattern.

periods:=5;

event:=L<Ref(H,-2) AND Ref(L,-1)>Ref(L,-2) AND

Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2);

line:=ValueWhen(1,event,Ref(L,-2));

If(Alert( event, {plot} periods), ValueWhen(1, event, line), 0);

ValueWhen(1,1=0,0);

I said to start with that you'd need to use a dotted line. This is necessary to blank out the sections of line where it moves from zero to price or price to zero.

If you want to see what happens without the last line of code, just put braces around it. Hope this helps.

Roy

MetaStock Tips & Tools

Patrick  
#4 Posted : Monday, December 3, 2007 8:21:46 AM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
You guys should take a look at the NullPlot DLL I posted on the Tradersconsortium.com ...
I think it will do what you are trying to accomplish and you won't have to use dotted lines ...
wblam  
#5 Posted : Monday, December 3, 2007 9:16:24 AM(UTC)
wblam

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 11/25/2006(UTC)
Posts: 79

Patrick wrote:
You guys should take a look at the NullPlot DLL I posted on the Tradersconsortium.com ...
I think it will do what you are trying to accomplish and you won't have to use dotted lines ...

Hi Patrick,

Can not find your file/post over there. Can you post the link here?

Thanks.

Patrick  
#6 Posted : Monday, December 3, 2007 9:32:39 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Here is the link: http://tradersconsortium...le=downloads&showfile=53

Though I now see you need to be a premium member of the TC forum to be able to download it ... Not sure what that entails you should ask over there :)

George AKA StorkBite will help you out ;)
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.