Show Bar to get only the last occurrence

Optuma Forums Optuma Scripting Show Bar to get only the last occurrence

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #66009
    Marc
    • Topics: 12
    • Replies: 23
    • Posts: 35

    Hi Guys,

    I would like to create a show bar to signal only the last time 2 MA cross over.

    The below formula with “last (vx)” makes all the signal disappear. Any suggestion?

    v1= MA(BARS=50);
    v2= MA(BARS=200);
    vx= v1 CrossesAbove v2 ;

    last(vx)

    Thanks!
    Marc

    #66021
    Matthew
    • Topics: 5
    • Replies: 421
    • Posts: 426

    Hi,

    The LAST() function won’t work in this case, as the last value the script produced is zero (unless the cross was on the very last bar).

    Instead, we can use a trick of counting the number of times a MA cross has occurred and set the script to show only the last time:

    Here is how it looks on the chart:

    Ex1

    2 users thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest