0
votes

I want to convert a TradingView pine script "Price Channel Strategy" to a study. can someone please help?

The code is as given below:

//@version=4
strategy("ChannelBreakOutStrategy", overlay=true)

length = input(title="Length", type=input.integer, minval=1, maxval=1000, defval=5)

upBound = highest(high, length)
downBound = lowest(low, length)

if (not na(close[length]))
    strategy.entry("ChBrkLE", strategy.long, stop=upBound + syminfo.mintick, comment="ChBrkLE")
    strategy.entry("ChBrkSE", strategy.short, stop=downBound - syminfo.mintick, comment="ChBrkSE")
strategy.exit("long_tsl", "ChBrkLE", trail_points = 4000, trail_offset = 1500)
strategy.exit("short_tsl", "ChBrkSE", trail_points = 4000, trail_offset = 1500)
1

1 Answers

0
votes

Mainly, you have to change the word strategy to study at the top of your code. You'll also have to remove the strategy.entry/exit calls since those aren't allowed in a study. See here for some more information: https://marketscripters.com/pine-script-strategy-vs-study/