Close Turns Up or Down MA

Optuma Forums Optuma Scripting Close Turns Up or Down MA

This topic contains 3 replies, has 3 voices, and was last updated by Darren Darren 1 month, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #47899

    Mathew
    • Topics: 1
    • Replies: 1
    • Posts: 2

    Hi Matthew, I am trying to find a script that I can use for a Show Plot to identify the first time the Bar closes above or below an MA. I tried using: CLOSE() TurnsDown MA(30) – for the first time the bar closes below MA 30 but it didn’t provide the desired result. It showed plots where the close was still above MA 30. I am assuming the correct script for either a first time turn up or turn down could be used for other indicators eg BB. thanks I appreciate your help.  

    • This topic was modified 1 month, 1 week ago by  Mathew.
    #47907
    Matthew
    Matthew
    • Topics: 3
    • Replies: 69
    • Posts: 72

    Hi Mathew,

    For a Close crossing above a Moving Average use:

    This example uses a 30SMA, you can adjust it as needed.

    For Close crossing below a 30 period Simple Moving Average use:

    The same type of setup can be used for many other functions.  With a Bollinger Band, here is an example of the High crossing above the upper band:

    For more information on scripting i’d recommend checking out the free courses here: https://learn.optuma.com/scripting-courses/

    #47911

    Mathew
    • Topics: 1
    • Replies: 1
    • Posts: 2

    Hi Matthew,

    Thank you. That was helpful. What if I didn’t want the arrows to appear if the MA is turning down in an uptrend and turning up in a downtrend? Is there a way to exclude those arrows?

    #47915
    Darren
    Darren
    • Topics: 28
    • Replies: 131
    • Posts: 159

    Hi Mathew,

    How would you define an uptrend? If it’s when the 30 period MA is sloping up you could use MA(Bars=30) IsUp but you could only include where a short-term MA was also sloping up, eg MA(Bars=5) IsUp, therefore excluding a short-term downtrend.

    So the complete formula would be:

    It would look like the green shaded areas on this chart (created using a Show View tool dragged over the price chart), so when the red line (MA5) is sloping down when the long term trend blue line is up it’s excluded. Is that what you had in mind?

    Capture

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close