坚持交易视图策略

时间:2021-02-26 16:40:05

标签: pine-script

我是松树脚本的新手,我需要帮助来制定我试图创建但没有成功的策略。规则如下:

入场 - RSI(2) < 50

退出 - OpenCandlePrice > EMA(3) 或 CloseCandlePrice >= EMA(3)

入场不会在蜡烛收盘时发生,退出也不会在蜡烛开盘或收盘时发生。有人可以帮我弄清楚我做错了什么吗?当我使用“process_orders_on_close”时,在蜡烛关闭时输入正确发生,但退出仍然错误。

代码

//@version=4
strategy("IFR2", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

//RSI

vrsi = rsi(close, 2)

//Moving Averages

shortema = ema(close,3)

//Strategy

`if (strategy.position_size == 0)`

`if (vrsi<50)`

`strategy.entry(id="EL", long=true, stop=close, comment="Open")`

`else if (strategy.position_size > 0)`

`if (open>shortema)`

`strategy.exit(id="ES", stop=open, comment="Close")`

`if (close>=shortema)`

`strategy.exit(id="ES", stop=close, comment="Close")`

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试在策略函数的第一行使用 process_orders_on_close=true。您可以选择 reference of this link Help needed with strategy - 入场时间为 2 根蜡烛。即使问题没有解决,那么可能的解决方案是在学习中制定完全相同的策略。