Rank: Newbie
Groups: Registered, Registered Users Joined: 6/14/2012(UTC) Posts: 8
|
Hi, is it possible in an indicator, to not plot result until there is a min number of prices. Eg only plot the difference between an average and close price if there is x number of price data.
regards robert
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/6/2010(UTC) Posts: 113 Location: London
|
Yes it is possible.
If you want the bar number then use Cum(1) in your code.
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/14/2012(UTC) Posts: 8
|
thanks for your reply, Ill give it ago. In the mean time Im using 'If(ref(c,-x),indicator,indicator) which seems to work.
Regards Robert
|
|
|
|
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)
|
Hi Rob
ValueWhen(1, Cum(1)>"X", "Signal") is what I use.
Roy
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/14/2012(UTC) Posts: 8
|
hi, like it, much easier to read and understand. Is it possible to reverse it so signal stops before x points from end?
Regards Robert
|
|
|
|
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)
|
Hi Robert
Yes it's possible but until someone comes up with a better way it requires two Ref() functions. It goes something like this.
{Inhibit right-side plot by "Shift" bars} {LastValue() needed for a calculated number} Shift:=LastValue("number"); Ref(Ref("Signal",-Shift),Shift);
This method makes use of the fact that MetaStock processes innermost functions of an expression first. In this case that's a shift of "Signal" to the right by -Shift bars (delayed if you prefer that terminology), thus discarding "number" bars from "Signal". Then "Signal", now devoid of the rightmost "number" of data bars, is shifted (advanced) to the left. The net effect is that the last "Shift" bars of "Signal" now return N/A rather than the original value. Obviously if the shift value is simply a number then there's no need to wrap it in LastValue().
Hope this helps.
Roy
|
|
|
|
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.