【发布时间】:2021-11-08 20:06:49
【问题描述】:
我一直在尝试研究如何在没有运气的情况下在我的回测逻辑中从交叉和高于安全性的价格触发 LONG 和 EXIT,现在就我的回测 pine 编辑器代码寻求帮助。
我将包含我的代码的某些部分,以便您了解我要做什么。
// add trading pair outside chart data
btc_price = security("BINANCE:BTCUSDT", "D", close)
// compute the indicators ( main chart ETH/USDT )
smaInput = input(title="SMA", type=input.integer, defval=1)
indicator1 = sma(close,smaInput)
// compute the indicators BTC
btcsmaInput = input(title="SMABTC", type=input.integer, defval=1)
indicatorbtc = sma(btc_price,btcsmaInput)
// plot the indicators
plot(indicator1, title="Indicator1", color=color.red, linewidth=2)
plot(indicatorbtc, title="Indicator1", color=color.blue, linewidth=2)
我试图用伪代码实现的目标: 如果收盘价高于指标1(ETH/USDT) 且 BTC/USDT 价格高于指标btc,则做多 如果收盘价低于指标1(ETH/USDT) 或 BTC/USDT 收盘价低于指标btc,则退出
这是我需要帮助的代码,下面的代码不起作用,因为我在上面的伪代码中描述了它。
// Backtesting Logic
EnterLong = crossover(close,indicator1) and crossover(btc_price, indicatorbtc)//
ExitLong = crossunder(close,indicator1) or crossunder(btc_price, indicatorbtc) //
请指教。
【问题讨论】:
标签: pine-script algorithmic-trading trading back-testing