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

Notification

Icon
Error

Options
Go to last post Go to first unread
TimX  
#1 Posted : Friday, November 2, 2012 12:40:22 AM(UTC)
TimX

Rank: Member

Groups: Registered, Registered Users
Joined: 10/26/2012(UTC)
Posts: 19

Hi, does anyone know a neat way to do the following? I have an indicator which spikes to a value (my stop loss) when there's a signal, otherwise stays at 0. Then I need a function to hold that level until the next spike (so I can check whether I reach my SL). E.g, [0 0 0 5 0 0 0 7 0 0 9 0 0 0 3 0 0 1 0] goes to [0 0 0 5 5 5 5 7 7 7 9 9 9 9 3 3 3 1 1] I'm thinking maybe the forum.latch could do it, but surely there's a native way in MS? Thanks for any suggestions, TimX
mstt  
#2 Posted : Friday, November 2, 2012 1:18:22 AM(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)

Hi Tim

Try the ValueWhen() function. My example won't generate a plot until the first spike occurs, but that's good because if the initial N/A portion was forced to plot it would probably be zero and severely distort the price chart that it was scaled to.

ValueWhen(1, "spike", "spike value")

Roy
TimX  
#3 Posted : Tuesday, November 6, 2012 1:37:48 AM(UTC)
TimX

Rank: Member

Groups: Registered, Registered Users
Joined: 10/26/2012(UTC)
Posts: 19

Hi Roy, Yes, that does the job perfectly! I can actually use ValueWhen(1, "spikevalue", "spikevalue") as MS seems to interpret a positive value in the second parameter as the trigger. Thanks for the help, cheers, Tim
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.