OPEN-SOURCE SCRIPT

Custom Strategy TO Spread strategy

//version=5
indicator("Custom Strategy", shorttitle="CustomStrat", overlay=true)

// Configuração das SMAs
smaShort = ta.sma(close, 8)
smaLong = ta.sma(close, 21)

// Configuração da Supertrend
atrPeriod = 10
atrFactor = 2
[superTrend, direction] = ta.supertrend(atrFactor, atrPeriod)

// Cálculo do spread
spread = high - low
spreadThreshold = 0.20 * close // 20% do preço atual

// Condições de entrada
crossOver = ta.crossover(smaShort, smaLong)
crossUnder = ta.crossunder(smaShort, smaLong)
superTrendCross = (close > superTrend) and (close[1] < superTrend[1])
superTrendConfirm = ta.barssince(superTrendCross) <= 6

// Volume
volumeConfirmation = (volume > volume[1]) and (volume[1] > volume[2])
volumeAverage = ta.sma(volume, 15) > ta.sma(volume[1], 15)

// Condição final
entryCondition = (crossOver or crossUnder) and superTrendConfirm and (spread > spreadThreshold) and volumeConfirmation and volumeAverage

// Alertas
if (entryCondition)
alert("Condição de entrada atendida!", alert.freq_once_per_bar_close)
Bands and ChannelsCandlestick analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer