我试图在当前价格 EMA200 的交叉点而不是在柱收盘价处入仓。我不在乎价格是否缩回。有什么办法可以做到这一点?
strategy('EMA200 5 min', overlay=true, process_orders_on_close=true)
ema_200 = ta.ema(close, 200)
// For LONG check if previous bar crossed over EMA200 and set order when current bar crosses EMA200
cross_over = ta.crossover(close[1], ema_200)
cross_over_touch = ta.cross(close, ema_200)
// Long Take Profit
long_tp_inp = input.float(1, title='Long Take Profit %', step=0.1, group='Set Take Profit %') / 100
long_take_level = strategy.position_avg_price * (1 + long_tp_inp)
// Long Stop Loss
long_sl_inp = input.float(0.5, title='Long Stop Loss %', step=0.1, group='Set Take Profit %') / 100
long_stop_level = strategy.position_avg_price * (1 - long_sl_inp)
// Strategy Execution
entry_long = cross_over and cross_over_touch and inDateRange
entry_price = ta.valuewhen(ta.cross(close, ema_200), close , 1)
strategy.entry(id='Long', direction=strategy.long, when=entry_long, limit=entry_price)
strategy.exit('Take Profit/ Stop Loss', 'Long', stop=entry_price, limit=long_take_level)
我设置的线limit=entry_price
似乎没有做任何事情。