问题
I tried to plot a graph based on the signals which are generated from the below strategy. But I observed from the script is signal generation points are differing by a Candle. If anyone will know about this please help me. For reference, I attached below snapshots
1. Buy signal snapshot 2. Sell signal snapshots
//@version=4
strategy("My Strategy", overlay=true)
orderType = 0
longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
orderType := 1
shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
orderType := -1
plot(orderType,"OrderType",color.black)
回答1:
//@version=4
strategy("My Strategy", overlay=true, process_orders_on_close=true)
orderType = 0
longCondition = crossover(sma(close, 14), sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long)
orderType := 1
shortCondition = crossunder(sma(close, 14), sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short)
orderType := -1
plot(orderType,"OrderType",color.black)
来源:https://stackoverflow.com/questions/60693501/buy-and-sell-signals-are-differing-by-a-candle-with-respect-to-plot