How To Create A Simple Trading Strategy With TradingView

//@version=4
study("My Script")
swmaClose = swma(close)plot(close)
study(“My Script”, overlay = true)
plot(swmaClose)
//@version=4
study(“My Script”, overlay = true)
swmaClose = swma(close)plot(swmaClose)
plot(swmaClose, color = color.red, linewidth = 4, transp = 0)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
bgcolor(swmaLong ? color.blue : na)
bgcolor(vwapLong ? color.orange : na)
//@version=4
study(“My Script”, overlay = true)
swmaClose = swma(close)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
bgcolor(swmaLong ? color.blue : na)
bgcolor(vwapLong ? color.orange : na)
triggerLong = vwapLong and not vwapLong[1] and not swmaLong and not swmaLong[1]
bgcolor(triggerLong ? color.purple : na)
saveLong = false, saveLong := triggerLong ? true : not vwapLong ? false : saveLong[1]
//@version=4
study(“My Script”, overlay = false)
swmaClose = swma(close)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
triggerLong = vwapLong and not vwapLong[1] and not swmaLong and not swmaLong[1]
saveLong = false, saveLong := triggerLong ? true : not vwapLong ? false : saveLong[1]
// bgcolor(swmaLong ? color.blue : na)
// bgcolor(vwapLong ? color.orange : na)
// bgcolor(triggerLong ? color.purple : na)
bgcolor(saveLong ? color.yellow : na)
startLong = saveLong and swmaLong
//@version=4
study(“My Script”, overlay = false)
swmaClose = swma(close)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
triggerLong = vwapLong and not vwapLong[1] and not swmaLong and not swmaLong[1]
saveLong = false, saveLong := triggerLong ? true : not vwapLong ? false : saveLong[1]
startLong = saveLong and swmaLong// bgcolor(swmaLong ? color.blue : na)
// bgcolor(vwapLong ? color.orange : na)
// bgcolor(triggerLong ? color.purple : na)
// bgcolor(saveLong ? color.yellow : na)
bgcolor(startLong ? color.green : na)
//@version=4
strategy(“My Script”, overlay = true)
swmaClose = swma(close)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
triggerLong = vwapLong and not vwapLong[1] and not swmaLong and not swmaLong[1]
saveLong = false, saveLong := triggerLong ? true : not vwapLong ? false : saveLong[1]
startLong = saveLong and swmaLongstrategy.entry(“Open Long”, strategy.long, when = startLong)// bgcolor(swmaLong ? color.blue : na)
// bgcolor(vwapLong ? color.orange : na)
// bgcolor(triggerLong ? color.purple : na)
// bgcolor(saveLong ? color.yellow : na)
bgcolor(startLong ? color.green : na)
strategy.exit(“Exit Long”, “Open Long”, profit = stopLoss, loss = takeProfit)
stopLoss = input(250, “Stop Loss”, step = 50)
takeProfit = input(10, “Reward/Risk”) * stopLoss
//@version=4
strategy("My Script", overlay = true)
swmaClose = swma(close)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
triggerLong = vwapLong and not vwapLong[1] and not swmaLong and not swmaLong[1]
saveLong = false, saveLong := triggerLong ? true : not vwapLong ? false : saveLong[1]
startLong = saveLong and swmaLongstopLoss = input(250, "Stop Loss", step = 50)
takeProfit = input(10, "Reward/Risk") * stopLoss
strategy.entry("Open Long", strategy.long, when = startLong)
strategy.exit("Exit Long", "Open Long", profit = stopLoss, loss = takeProfit)
// bgcolor(swmaLong ? color.blue : na)
// bgcolor(vwapLong ? color.orange : na)
// bgcolor(triggerLong ? color.purple : na)
// bgcolor(saveLong ? color.yellow : na)
bgcolor(startLong ? color.green : na)
//@version=4
strategy(title = "Simple Price Momentum", shorttitle = "SPM", overlay = true, initial_capital = 20000, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_value = 0.025)
bgcolor(startLong[1] ? color.green : na)
startLong = saveLong and swmaLong
startLong := startLong and not startLong[1]
startLong := input(false, "Consecutive Orders") ? startLong : startLong and not startLong[1]
//@version=4
strategy(title = "Simple Price Momentum", shorttitle = "SPM", overlay = true, initial_capital = 20000, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_value = 0.025)
swmaClose = swma(close)
vwapClose = vwap(close)
swmaLong = close > swmaClose
vwapLong = close > vwapClose
triggerLong = vwapLong and not vwapLong[1] and not swmaLong and not swmaLong[1]
saveLong = false, saveLong := triggerLong ? true : not vwapLong ? false : saveLong[1]
startLong = saveLong and swmaLong
startLong := input(false, "Consecutive Orders") ? startLong : startLong and not startLong[1]
stopLoss = input(250, "Stop Loss", step = 50)
takeProfit = input(10, "Reward/Risk") * stopLoss
strategy.entry("Open Long", strategy.long, when = startLong)
strategy.exit("Exit Long", "Open Long", profit = stopLoss, loss = takeProfit)
// bgcolor(swmaLong ? color.blue : na)
// bgcolor(vwapLong ? color.orange : na)
// bgcolor(triggerLong ? color.purple : na)
// bgcolor(saveLong ? color.yellow : na)
bgcolor(startLong[1] ? color.green : na)

--

--

--

Hard core trader/programmer, not fully either of both, yet a new breed of thinker that solves outside problems to find his own purpose on this world.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Vocabulary Game in Python

Before you use Kustomize

How companies benefit of real-time data streaming

Locked In and Busy: Week 1

How to Achieve Mental Awareness

OnePlus Nord à Vivo V20 Pro: Meilleurs smartphones de moins de

Contribution of SOLID principle to low coupling and high cohesion pattern

Avoid repetitive dependency declarations with Gradle Kotlin DSL

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
QS

QS

Hard core trader/programmer, not fully either of both, yet a new breed of thinker that solves outside problems to find his own purpose on this world.

More from Medium

How to build crypto trading bot for binance futures in python

Automated trading is here with Alpaca

AIO Indicator — How to use Statistic Panel

How to decide to buy cryptocurrency using Python?