ゆとり世代の自由研究

勉強が一生終わりません

Pinescript:クローズ時に注文を生成

//@version=4
strategy(title="Process orders on close - example",
     overlay=true, process_orders_on_close=true)

// Enter long conditions
isFlat    = (strategy.position_size == 0)
enterLong = isFlat and (dayofmonth != dayofmonth[1])

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

// Determine exit conditions
isLong       = (strategy.position_size > 0)
lastBarOfDay = (hour(time) == 17) and (minute(time) == 0)
exitLong     = isLong and lastBarOfDay

// Generate exit long trades
if (exitLong)
	strategy.order(id="XL", long=false, qty=1)