Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request For True Momentum Oscillator (TMO) #605

Open
azimgiant opened this issue Jul 18, 2023 · 1 comment
Open

Request For True Momentum Oscillator (TMO) #605

azimgiant opened this issue Jul 18, 2023 · 1 comment

Comments

@azimgiant
Copy link

First of all thank you for creating this project. It has been a great help. I wanted to request the TMO indicator as it has helped me a lot in my own personal trading. I just started to learn python to backtest my trading strategies, so my knowledge is at a beginner level. I tried using chatgpt to convert the pinescript to python however that wasn't much help. If this could be added in that would be awesome. Thanks!

[https://www.tradingview.com/script/o9BQyaA4-True-Momentum-Oscillator/]
Pinescript:
// @Version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// True Momentum Oscillator
// by SparkyFlary

study(title="True Momentum Oscillator", overlay=false)

length = input(14, title="Length")
calcLength = input(5, title="Calc length")
smoothLength = input(3, title="Smooth length")
lengthType = input("EMA", title="Length moving average type", options=["EMA", "SMA", "RMA"])
calcLengthType = input("EMA", title="Calc length moving average type", options=["EMA", "SMA", "RMA"])
smoothLengthType = input("EMA", title="Smooth length moving average type", options=["EMA", "SMA", "RMA"])

//function for choosing moving averages
f_ma(type, src, len) =>
float result = 0
if type == "EMA"
result := ema(src, len)
if type == "SMA"
result := sma(src, len)
if type == "RMA"
result := rma(src, len)
result

o = open
c = close
s = 0
for i = 0 to length
s := s + (c > o[i] ? 1 : c < o[i] ? - 1 : 0)
data = s

MA = f_ma(lengthType, data, calcLength)
Main = f_ma(calcLengthType, MA, smoothLength)
Signal = f_ma(smoothLengthType, Main, smoothLength)

ob = hline(round(length * .7), title="overbought cutoff line", color=color.gray, linestyle=hline.style_solid)
os = hline(-round(length * .7), title="oversold cutoff line", color=color.gray, linestyle=hline.style_solid)
upper = hline(length, title="upper line", color=color.red, linestyle=hline.style_solid)
lower = hline(-length, title="lower line", color=color.green, linestyle=hline.style_solid)
zero = hline(0, title="zero line", color=color.gray, linestyle=hline.style_solid)

mainPlot = plot(Main, title="main line", color=Main>Signal?color.green:color.red, linewidth=2)
signalPlot = plot(Signal, title="signal line", color=Main>Signal?color.green:color.red)
crossPlot = plot(cross(Main,Signal)?Main:na, title="crossover dot", color=Main>Signal?color.green:color.red, style=plot.style_circles, linewidth=3)

fill(mainPlot, signalPlot, title="main and signal area", color=Main>Signal?color.green:color.red)
fill(ob, upper, title="overbought zone", color=color.red)
fill(os, lower, title="oversold zone", color=color.green)

@mario4tier
Copy link
Member

Moving forward, all requests and further discussion for new functions should happen on the New TA Functions Board

A reference to this issue has been added to preserve this discussion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants