对于 pinescript 策略,在发出信号后延迟进入市场
For pinescript strategy, getting late entries into market after signal raised
我正在使用
pinescript 4.0
在下面的图表中,我正在执行使用以下内容的 strategy
:
if exec_long
// entry condition
if crossover(rsi, ema ) and inDateRange and close > close[1]
strategy.entry("MAN Long Entry Id", strategy.long)
我遇到的问题是入场发生在 下一根蜡烛 的顶部(见指向右侧的箭头)。对我来说,这可能意味着金钱损失(由于迟到)。我该如何解决这个问题,以便在 RSI crosses over the EMA
(对于空头和多头)的确切时间进行入场?
TIA
编辑
@e2e4 - 感谢您的回复。我会尝试设置。出于好奇,在real-time/production的环境下可以运行吗?
我添加了一个简短条目示例。在这个例子中,仓位被“止损”,因为进场发生在蜡烛的底部。如果进场发生在蜡烛的顶部(参见图片 SHORT #1),则不会发生“止损出局” - 或者 - 如果它发生在图片 SHORT #2 的“虚线上”(目标是保持尽可能低的止损金额)。
=> With that being said was wondering if you knew of any code on the Tradingview site that perhaps provides some kind of guidance (or code)
to executing entries (using pinescript) that do not get "stopped out"
due to the situation taking place with the LONG example (sent earlier)
or with the SHORT example (shown in the pictures of SHORT #1 and
SHORT#2)
TIA
策略和学习脚本以不同的逻辑执行。有关经纪人模拟器的更多信息:
https://www.tradingview.com/pine-script-docs/en/v4/essential/Strategies.html#broker-emulator
在TradingView上,策略是根据所有图表可用的历史数据计算(回测),然后在实时数据进来时自动继续计算(前测)。
默认情况下,在历史计算和实时计算期间,代码都是在柱线收盘时计算的。
进行前向测试时,您可以选择将脚本计算配置为在每个实时报价单上发生。要启用此功能,请在策略的 Settings/Properties 中选中 Recalculate On Every Tick 选项,或在脚本的代码中使用:
指定它
strategy(..., calc_on_every_tick = true)
您可以将策略设置为在订单成交后执行一次额外的计算。为此,您需要在策略的 Settings/Properties 中检查订单填写后的重新计算,或者在脚本的代码中使用:
strategy(..., calc_on_order_fills = true)
您可能会发现来自 backtest-rookies 的这篇文章很有用,它解释了信号和订单执行之间的 1 根蜡烛和有时 2 根蜡烛的延迟:https://backtest-rookies.com/2017/11/15/backtesting-101-trades-delayed/
我正在使用
pinescript 4.0
在下面的图表中,我正在执行使用以下内容的 strategy
:
if exec_long
// entry condition
if crossover(rsi, ema ) and inDateRange and close > close[1]
strategy.entry("MAN Long Entry Id", strategy.long)
我遇到的问题是入场发生在 下一根蜡烛 的顶部(见指向右侧的箭头)。对我来说,这可能意味着金钱损失(由于迟到)。我该如何解决这个问题,以便在 RSI crosses over the EMA
(对于空头和多头)的确切时间进行入场?
TIA
编辑
@e2e4 - 感谢您的回复。我会尝试设置。出于好奇,在real-time/production的环境下可以运行吗?
我添加了一个简短条目示例。在这个例子中,仓位被“止损”,因为进场发生在蜡烛的底部。如果进场发生在蜡烛的顶部(参见图片 SHORT #1),则不会发生“止损出局” - 或者 - 如果它发生在图片 SHORT #2 的“虚线上”(目标是保持尽可能低的止损金额)。
=> With that being said was wondering if you knew of any code on the Tradingview site that perhaps provides some kind of guidance (or code) to executing entries (using pinescript) that do not get "stopped out" due to the situation taking place with the LONG example (sent earlier) or with the SHORT example (shown in the pictures of SHORT #1 and SHORT#2)
TIA
策略和学习脚本以不同的逻辑执行。有关经纪人模拟器的更多信息: https://www.tradingview.com/pine-script-docs/en/v4/essential/Strategies.html#broker-emulator
在TradingView上,策略是根据所有图表可用的历史数据计算(回测),然后在实时数据进来时自动继续计算(前测)。 默认情况下,在历史计算和实时计算期间,代码都是在柱线收盘时计算的。 进行前向测试时,您可以选择将脚本计算配置为在每个实时报价单上发生。要启用此功能,请在策略的 Settings/Properties 中选中 Recalculate On Every Tick 选项,或在脚本的代码中使用:
指定它strategy(..., calc_on_every_tick = true)
您可以将策略设置为在订单成交后执行一次额外的计算。为此,您需要在策略的 Settings/Properties 中检查订单填写后的重新计算,或者在脚本的代码中使用:
strategy(..., calc_on_order_fills = true)
您可能会发现来自 backtest-rookies 的这篇文章很有用,它解释了信号和订单执行之间的 1 根蜡烛和有时 2 根蜡烛的延迟:https://backtest-rookies.com/2017/11/15/backtesting-101-trades-delayed/