简体   繁体   English

坚持交易视图策略

[英]Stuck with Trading View strategy

I'm new to pine script and I need a help with a strategy I'm trying to create without success.我是 pine 脚本的新手,我需要帮助我尝试创建但没有成功的策略。 The rule is as follows:规则如下:

Entry - RSI(2) < 50入场 - RSI(2) < 50

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

The entries are not occurring at the closing of the candle and the exits are also not occurring at the opening or closing of the candle.蜡烛收盘时不会出现进场,蜡烛开盘或收盘时也不会出现退出。 Could someone help me figure out what I'm doing wrong?有人可以帮我弄清楚我做错了什么吗? When I use "process_orders_on_close" the entries occur correctly in the closing of candle, but the exits remain wrong.当我使用“process_orders_on_close”时,条目在蜡烛关闭时正确出现,但出口仍然错误。

CODE代码

//@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在此处输入图像描述

Try using process_orders_on_close=true in the first line of the strategy function.尝试在策略 function 的第一行中使用process_orders_on_close=true You can take reference of this link Help needed with strategy - Entry is off by 2 candles.您可以参考此链接 策略所需的帮助- 入场点差 2 根蜡烛。 Even if problem not resolved then the possible solution is to make the exact same strategy in study.即使问题没有解决,那么可能的解决方案是在研究中制定完全相同的策略。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM