Tradingview: guide for beginners
Investors very often correctly select stocks using fundamental analysis. However, the strategy suffers from shortcomings from a “momentum” perspective.
This simply system – which I recommend applying on a monthly basis – is simple and very effective: it uses a simple average of the opening, maximum and minimum of the currentmonth’s candle and compares it with the closing of the current month. If prices are higher than this average you enter/stay in the market, otherwise you exit. Since it is designed to support investment, short operations are not foreseen. In this way the performance compared to simple buy & hold is much improved.
If you want no to use strictly the strategy, however you may check week by week how prices are distant from this average.
You may also decide the period for backtesting.

CODE
//@version=5
strategy(title=’Triband_Long Only for Investments’, overlay=true, precision=4, calc_on_order_fills=true, calc_on_every_tick =true, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=100000, currency=currency.EUR, commission_type=strategy.commission.percent, commission_value=0.25)
// by Sauciusfinance
period_ = input.int(1, title=”Length”, minval=1)
halfband = (high[period_]+low[period_]+open[period_])/3
plot(halfband, title=”halfband”, color=color.blue, linewidth = 2, style=plot.style_stepline)
// === INPUT BACKTEST RANGE ===
fromMonth = input.int (defval = 1, title = “From Month”, minval = 1, maxval = 12)
fromDay = input.int (defval = 1, title = “From Day”, minval = 1,maxval = 31)
fromYear = input.int(defval = 2019, title = “From Year”, minval = 1970)
thruMonth = input.int(defval = 1, title = “Thru Month”, minval = 1, maxval = 12)
thruDay = input.int(defval = 1, title = “Thru Day”, minval = 1, maxval = 31)
thruYear = input.int(defval = 2112, title = “Thru Year”, minval = 1970)
// === FUNCTION EXAMPLE limit for backtest ===
start = timestamp(fromYear, fromMonth, fromDay, 00, 00) // backtest start window
finish = timestamp(thruYear, thruMonth, thruDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function “within window of time”
// entries
xentryl = ta.crossover(close, halfband) and window()
xentrys = ta.crossunder(close, halfband) and window()
strategy.entry(‘Long’, strategy.long, when= xentryl, comment=’apri’)
strategy.close(‘Long’, when=xentrys, comment=’chiudi’)
// MONEY MANAGEMENT
lossp = input.float(8, minval=1, step=1)
losspel = strategy.position_avg_price * (1 – lossp / 100)
fixed_stop_long = close < losspel
strategy.close(‘Long’, when=fixed_stop_long, comment = ‘Stop loss’)







