Fetch ATR + MA Strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FetchTeam

//@version=5
indicator("Fetch ATR + MA Strategy", overlay=true)
ATR_COLOR                         = input.color(color.red, "ATR COLOR")
MA_COLOR                          = input.color(color.new(#c732b0, 1))
MA_INPUT                          = input(defval=20, title='ATR MA')
SHORT_MA_INPUT                    = input(defval=50, title='Short Ma')
LONG_MA_INPUT                     =  input(defval=200, title='Short Ma')

SHOW_SELL_SIGNALS                 = input.bool(true, "Show Sell Signals")


ATR                               = ta.atr(14)
[DI_PLUS, DI_MINUS, ADX]          = ta.dmi(14, 14)
MOVING_AVERAGE_OF_ATR             = ta.sma(ATR, MA_INPUT)
SHORT_MA                           = ta.sma(close, SHORT_MA_INPUT)
LONG_MA                           = ta.sma(close, LONG_MA_INPUT)

CROSS_OVER                        = ta.crossover(SHORT_MA, LONG_MA)
CROSS_UNDER                       = ta.crossunder(SHORT_MA, LONG_MA)
BUY_SIGNAL                        = 0

if (CROSS_OVER and ATR < MOVING_AVERAGE_OF_ATR)
    if ADX < 30
        BUY_SIGNAL := 1

plotshape(series=BUY_SIGNAL ? BUY_SIGNAL == 1 : na, location=location.abovebar, style=shape.diamond, color=color.green, size=size.small)
plotshape(series=CROSS_UNDER ? SHOW_SELL_SIGNALS == true : na, location=location.abovebar, style=shape.diamond, color=color.red, size=size.small)
