//@version=4 strategy("Close Price Strategy", overlay=true) var bool longCondition = false var bool shortCondition = false // Calculate the close price of the previous day prevClose = security(syminfo.tickerid, "D", close[1]) // Check if the current close price is higher than the previous day's close price buySignal = close > prevClose and time >= timestamp("2022-06-06") and time < timestamp("2023-06-07") // Check if the current close price is lower than the previous day's close price shortSignal = close < prevClose and time >= timestamp("2022-06-06") and time < timestamp("2023-06-07") // Set long condition if buySignal longCondition := true else if close < prevClose longCondition := false // Set short condition if shortSignal shortCondition := true else if close > prevClose shortCondition := false // Buy signal condition if longCondition if strategy.position_size <= 0 strategy.entry("Buy", strategy.long) // Short signal condition if shortCondition if strategy.position_size >= 0 strategy.entry("Short", strategy.short)