Результаты тестирования стратегии Pine Script варьируются от V2 до V4

результаты обратного тестирования сценария pine варьируются от V2 до V4

Я попытался преобразовать скрипт Pine V2 в V4. Я думаю, что есть много изменений в функции ценных бумаг от V2 до V4. изменения в результатах обратного тестирования. Если кто-нибудь знает решение, пожалуйста, помогите мне

Это стратегия сценария pine V2

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © suryaobulareddy
//@version=2
strategy("Strategy1", overlay=true)
tim=input('50')
//160

isSession  = input(defval = true, title = "Apply Trading Session", type = bool)
sess = input(defval = "0935-1500", title="Trading Session")
t = time(period, sess)
sessionOpen = isSession ? (na(t) ? false : true):false
startYear   = input(defval = 2020, title = "From Year",     type = integer)
startMonth  = input(defval = 1,    title = "From Month",    type = integer )
startDay    = input(defval = 1,    title = "From Day",      type = integer)
endYear     = input(defval = 2112, title = "To Year",       type = integer)
endMonth    = input(defval = 1,    title = "To Month",      type = integer)
endDay      = input(defval = 1,    title = "To Day",        type = integer)
showDate  = input(defval = true, title = "Show Date Range", type = bool)
start     = timestamp(startYear, startMonth, startDay, 00, 00)        // backtest start window
finish    = timestamp(endYear, endMonth, endDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false       // create function "within window of time"
out1 = security(tickerid, tim, open)
out2 = security(tickerid, tim, close)
//plot(out1,color=color.red)
//plot(out2,color=color.green)
longCondition = (crossover(security(tickerid, tim, close),security(tickerid, tim, open)) and sessionOpen and window())
shortCondition = (crossunder(security(tickerid, tim, close),security(tickerid, tim, open)) and sessionOpen and window())
val = 0
if (longCondition)
    val := 1
    strategy.entry("long", strategy.long)
if (shortCondition)
    val := -1
    strategy.entry("short", strategy.short)
if(not sessionOpen)
    val := -3
strategy.close_all(when =  not sessionOpen)
plot_stoploss_short= plot(val, title="type", color=red)

Это стратегия сценария pine V4

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © suryaobulareddy
//@version=4
strategy("Strategy1", overlay=true)
tim=input('50')
timopen=input('50')
//160

isSession  = input(defval = true, title = "Apply Trading Session", type = input.bool)
sess = input(defval = "0935-1500", title="Trading Session")
t = time(timeframe.period, sess)
sessionOpen = isSession ? (na(t) ? false : true):false 
startYear   = input(defval = 2020, title = "From Year",     type = input.integer)
startMonth  = input(defval = 1,    title = "From Month",    type = input.integer )
startDay    = input(defval = 1,    title = "From Day",      type = input.integer)
endYear     = input(defval = 2112, title = "To Year",       type = input.integer)
endMonth    = input(defval = 1,    title = "To Month",      type = input.integer)
endDay      = input(defval = 1,    title = "To Day",        type = input.integer)
showDate  = input(defval = true, title = "Show Date Range", type = input.bool)
start     = timestamp(startYear, startMonth, startDay, 00, 00)        // backtest start window
finish    = timestamp(endYear, endMonth, endDay, 23, 59)        // backtest finish window
window()  => time >= start and time <= finish ? true : false       // create function "within window of time"
out1 = security(syminfo.tickerid, tim, open)
out2 = security(syminfo.tickerid, tim, close)
longCondition = (crossover(security(syminfo.tickerid, tim, close),security(syminfo.tickerid, timopen, open)) and sessionOpen and window())
shortCondition = (crossunder(security(syminfo.tickerid, tim, close),security(syminfo.tickerid, timopen, open)) and sessionOpen and window())
val = 0
if (longCondition)
    val := 1
    strategy.entry("long", strategy.long)
if (shortCondition)
    val := -1
    strategy.entry("short", strategy.short)
if(not sessionOpen)
    val := -3
strategy.close_all(when =  not sessionOpen)
plot_stoploss_short= plot(val, title="type", color=color.red)


person Surya Obulareddy    schedule 08.03.2020    source источник
comment
Вы решили эту проблему? Вы видите мой новый вопрос Изменить с V2 на V3, вопрос по защитной функции   -  person fdsafsdf    schedule 13.11.2020


Ответы (1)


Да, были важные изменения в поведении security(), начиная с версии 3. Он использовал прогноз на будущее до v3, а настройка по умолчанию больше не используется.

Таким образом, результаты, которые вы получите с помощью бэктеста версии 4, будут более надежными.

person PineCoders-LucF    schedule 08.03.2020