资源加载中... loading...

Exit from specific entries

Author: Zer3192, Date: 2023-01-07 21:19:04
Tags:


//@version=4
strategy(title="Exit from specific entries", overlay=true,
     pyramiding=2, close_entries_rule="ANY")

// Determine trading conditions
newDay = (dayofmonth != dayofmonth[1])

firstEntry  = newDay and (dayofweek == dayofweek.monday)
secondEntry = newDay and (dayofweek == dayofweek.tuesday)

firstExit  = newDay and (dayofweek == dayofweek.thursday)
secondExit = newDay and (dayofweek == dayofweek.friday)

// Submit entry orders
if (firstEntry)
    strategy.entry(id="EL 1", long=true)

if (secondEntry)
    strategy.entry(id="EL 2", long=true)

// Generate exit orders
if (firstExit)
    strategy.close(id="EL 2")

if (secondExit)
    strategy.close(id="EL 1")
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6