Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © yereter
- //@version=4
- strategy("My Strategy", overlay=false)
- ///// Backtest Start Date /////
- startDate = input(title="Start Date", type=input.integer, defval=15, minval=1, maxval=31)
- startMonth = input(title="Start Month", type=input.integer, defval=3, minval=1, maxval=12)
- startYear = input(title="Start Year", type=input.integer, defval=2019, minval=1800, maxval=2100)
- startDateEnd = input(title="Start Date", type=input.integer, defval=25, minval=1, maxval=31)
- startMonthEnd = input(title="Start Month", type=input.integer, defval=11, minval=1, maxval=12)
- startYearEnd = input(title="Start Year", type=input.integer, defval=2021, minval=1800, maxval=2100)
- afterStartDate = (time <= timestamp(syminfo.timezone, startYearEnd, startMonthEnd, startDateEnd, 0, 0) and time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0))
- len=input(3,title="length")
- //DI+ and DI-
- upz = change(high)
- down = -change(low)
- trur = rma(tr, len)
- plus = fixnan(100 * rma(upz > down and upz > 0 ? upz : 0, len) / trur)
- minus = fixnan(100 * rma(down > upz and down > 0 ? down : 0, len) / trur)
- sum = plus + minus
- adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), len)
- di=plus-minus
- // o=plot(di,color=color.white,title="Diretion Index color",offset=0)
- df=di>=0? color.lime :color.red
- oo=0
- zs=100
- o=plot(oo,color=color.white,title="Diretion Index color",transp=100)
- wq=plot(zs,color=color.white,title="Diretion Index color",transp=100)
- fill(o,wq,color=df,transp=50)
- longCondition = crossover(di,0)
- // and atr(14)[1]<atr(14)[0]
- if (longCondition and afterStartDate)
- strategy.entry("My Long Entry Id", strategy.long)
- shortCondition = crossunder(di,0)
- if (shortCondition and afterStartDate )
- // strategy.close_all()
- strategy.entry("My Short Entry Id", strategy.short)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement