If you want to use other timescale, need to change disparity rate and sdv. To display disparity(sma) and standard deviation, and to draw a hline(pine function) a certain valu. And lets think. I thought disparity rate 1~1.3 or -1~-1.3 are able to use constrarian trade (and sdv>600).
In bottom, disparity index is auxiliary. It is different from the multiple in the script to make the value easier to understand.
Sorry if the expiration date of the script has expired.
Versionsinformation
⋅
disparity's multiple, length and sdv are changed.(is it Curve fitting ?)
Versionsinformation
⋅
input_length and timeframe changed.
Versionsinformation
⋅
・add comment ・sdv value changed ・made code easier to read
in addition, sorry to make a mistake title "dipsparity"→"disparity :(
isLongEntry = crossover (vrocma, 0) and dir == -1
isShortEntry = crossover (vrocma, 0) and dir == 1
// Back Test Fnction -----------------------------------------------------------
TestP = input(true,title=" ░░░ Separator░░░ Test Period Parameter ")
startP = timestamp(input(2019, "Start Year"), input(1, "Start Month"), input(1, "Start Day"), 0, 0)
end = timestamp(input(9999, "End Year"), input(1, "End Month"), input(1, "End Day"), 0, 0)
_testPeriod() =>
iff(time >= startP and time <= end, true, false)
// Position Function
avgg = strategy.position_avg_price
poss = strategy.position_size
if _testPeriod()
if isLongEntry
strategy.entry("L", strategy.long, comment="Long")
if isShortEntry
strategy.entry("S", strategy.short, comment="Short")
// Plot Long and Short Position
input_isShowLongShort = input(true, title="[DISP] Long / Short")
bgcolor(input_isShowLongShort ? #000000cc : na, title="Dark Background")
bgcolor(input_isShowLongShort and poss<0 ? color.new(#DF00FF, 80) : input_isShowLongShort and poss>0 ? color.new(#0892D0, 80) : na, editable=false)
// Plot Wining or Losing
input_isShowWinOrLose = input(true, title="[DSIP] Winning / Losing")
isProfitShapePlus = false
isProfitShapeMinus = false
//if _bLongEntry or _bShortClose or _bShortEntry or _bLongClose ----------------
if avgg > 0 or poss==0
if strategy.openprofit > 0 and input_isShowWinOrLose
isProfitShapePlus := true
isProfitShapePlus
if strategy.openprofit < 0 and input_isShowWinOrLose
isProfitShapeMinus := true
isProfitShapeMinus