TMO Arrows
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// TMO (T)rue (M)omentum (O)scillator) Arrows
//
// TMO calculates momentum using the DELTA of price. Giving a much better picture of trend, reversals and divergences than momentum oscillators using price. 
//
// TMO Arrows are working on the same principle as the TMO oscillator, but they are ploted directly on the chart. Advantageos especially for those who want 
// to combine TMO with other studies but have no space on the chart.
//
// Created by L&L Capital
// 

indicator("TMO Arrows", shorttitle="TMO Arrows", overlay=true)

// Inputs

TimeFrame = input.timeframe('D', "TimeFrame", options=['1','2','3','5','10','15','20','30','45',"60","120","180","240",'D','2D','3D','4D','W','2W','3W','M','2M','3M'])
tmolength = input.int(14,title="Length")
calcLength = input(5, title="Calc Length")
smoothLength = input(3, title="Smooth Length")

// TMO Calculations

srcc = request.security(syminfo.tickerid, TimeFrame, close)
srco = request.security(syminfo.tickerid, TimeFrame, open)
o =  srco
c =  srcc

data = 0
for i = 1 to tmolength -1
    if c > o[i]
        data := data + 1
    if c < o[i]
        data := data - 1


EMA5 = ta.ema(data,calcLength)
Main = request.security(syminfo.tickerid, TimeFrame, ta.ema(EMA5, smoothLength))
Signal = request.security(syminfo.tickerid, TimeFrame, ta.ema(Main, smoothLength))

mainLine = (15*Main/tmolength)
signalLine = (15*Signal/tmolength)

// TMO Arrow Up
TMOArrowUp = ta.crossover(mainLine,signalLine)
plotshape(TMOArrowUp,title='TMO Up',style=shape.triangleup,location=location.belowbar,color=(#009900),size=size.small)    

//TMO Arrow Dn
TMOArrowDn = ta.crossover(signalLine, mainLine)
plotshape(TMOArrowDn,title='TMO Down',style=shape.triangledown,location=location.abovebar,color=(#cc0000),size=size.small)    

// TMO Arrow Up (Oversold Extremes Only)
TMOArrowUpEx = (mainLine < -9) and ta.crossover(mainLine,signalLine)
plotshape(TMOArrowUpEx,title='TMO Up (Oversolds Only)',style=shape.triangleup,location=location.belowbar,color=(#27c22e),size=size.small,display=display.none)

// TMO Arrow Dn (Overbought Extremes Only)
TMOArrowDnEx = (mainLine > 9) and ta.crossover(signalLine, mainLine)
plotshape(TMOArrowDnEx,title='TMO Down (Overboughts Only)',style=shape.triangledown,location=location.abovebar,color=(#ff0000),size=size.small,display=display.none)    
