I have tried fixing my code to backtest my strategy and when I try to backtest it, it tells me that my code couldn't complete any trades. Please help I am in dire need.
Here is the code:
//version=4
strategy("backtest #001", overlay=true, initial_capital=100000, currency='USD')
//backtest
fromYear = year > 2010
toYear = year < 2020
//inputs
mystoch = stoch(close, 14, 3, 3) >= 85
myema = ema(close, 200) >= ema(close, 200)
mybbw = bbw(close, 20, 2) >= 0.03
//closing inputs
mystochclose= stoch(close, 14, 3, 3) <= 40
myemaclose = ema(close, 200) <= ema(close, 197)
mybbwclose = bbw(close, 20, 2) <= 0.03
//problems
strategy.entry('buy', true, 1, when = (mystoch and myema and mybbw)? 1 : 0)
strategy.close("buy", when = (mystochclose and myemaclose and mybbwclose)? 1 : 0) , qty_percent = 50
Here is the code:
//version=4
strategy("backtest #001", overlay=true, initial_capital=100000, currency='USD')
//backtest
fromYear = year > 2010
toYear = year < 2020
//inputs
mystoch = stoch(close, 14, 3, 3) >= 85
myema = ema(close, 200) >= ema(close, 200)
mybbw = bbw(close, 20, 2) >= 0.03
//closing inputs
mystochclose= stoch(close, 14, 3, 3) <= 40
myemaclose = ema(close, 200) <= ema(close, 197)
mybbwclose = bbw(close, 20, 2) <= 0.03
//problems
strategy.entry('buy', true, 1, when = (mystoch and myema and mybbw)? 1 : 0)
strategy.close("buy", when = (mystochclose and myemaclose and mybbwclose)? 1 : 0) , qty_percent = 50
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.