策略总结:
下面是我写的代码,它目前不产生任何数据。 我是 Pinescript 的新手,任何帮助正确格式化和工作的帮助将不胜感激!
//@version=4
strategy("Closing Range Breakdown")
//I want the lowest price from this time period.
lastPremarketCandle = time(timeframe.period, "0915-0930:23456")
//I only want a trade to trigger short during the first 15 minutes of the trading day.
firstFifteenMinutes = time(timeframe.period, "0930-0945:23456")
//grabbing the low price of the last 15 minute candle of the premarket.
lowestValue = lastPremarketCandle ? low : na
//I want to be triggered into the trade 10 cents below the low of the lastPremarketCandle once the market is open.
tradeTriggerPrice = lowestValue - 0.10
//Here I'm creating a stop loss as well as a profit target.
profitTarget = tradeTriggerPrice - 0.80
stopLoss = tradeTriggerPrice + 0.40
//I want my backtest to cover this period of time.
var start = timestamp(2016, 1, 1, 0, 0)
var end = timestamp(2021, 3, 31, 0, 0)
//checking conditions to make sure we are backtesting the right time frame and incorporating the right price levels
if (time >= start and time <= end and firstFifteenMinutes)
strategy.entry("short", strategy.short, 1250, when = tradeTriggerPrice)
//closing out the position if we hit the stop loss or the take profit target
strategy.close("closePosition", when = stopLoss or profitTarget)