I tried but not getting same results.
After converting strategy to indicator I’m not getting same buy-sell signals as original strategy.
I am not clearly understanding the original code as I’m not a programmer. This is important to me. Can some one please convert this code ? I this this is pretty simple but as I’m not programmer i’m not able to do it.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// buy/sell trial
//@version=5
strategy("buy-sell trail", "buy-sell", overlay=true)
leftBars = input(4, group = "Pivot Point Settings")
rightBars = input(2)
swh = ta.pivothigh(leftBars, rightBars)
swl = ta.pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice[1]
le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])
if (le)
strategy.entry("Buy", strategy.long, comment="Buy", stop=hprice + syminfo.mintick)
swl_cond = not na(swl)
lprice = 0.0
lprice := swl_cond ? swl : lprice[1]
se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])
if (se)
strategy.entry("Sell", strategy.short, comment="Sell", stop=lprice - syminfo.mintick)
New contributor
SmartOwl Team1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.