pine-script - EMA 200 的买卖条件
问题描述
我在策略中针对以下条件写的内容:1)如果价格高于 200 EMA,请不要做空 2)如果价格低于 200 EMA,请不要做多 ----- 策略的哪个点这些条件应该写吗?
解决方案
strategy("200ema", overlay=true)
ema1=ema(close,1)
ema2=ema(close,200)
buy= crossover(ema1,ema2)
sell=crossunder(ema1,ema2)
if (buy)
strategy.entry("Buy", strategy.long)
if (sell)
strategy.entry("Sell", strategy.short)
这是一个简单的脚本,当 ema1 与 ema2 交叉时将显示买入/卖出。
如果您想做类似“价格必须高于 200 才能触发买入,低于 200 才能触发卖出”之类的操作
只需添加这个
strategy("200ema", overlay=true)
ema1=ema(close,1)
ema2=ema(close,200)
bf=ema1>ema2
sf=ema1<ema2
buy= (your strategy) and bf
sell=(your strategy) and sf
if (buy)
strategy.entry("Buy", strategy.long)
if (sell)
strategy.entry("Sell", strategy.short)
推荐阅读
- azure-eventhub - Azure 事件中心 - 增加吞吐量单位和 IEventProcessor 实例后,传出消息/字节不会增加
- postgresql - 在 Knex 中插入具有显式模式的内容?
- docker - Grafana 发送带有错误图表图像的警报
- android - 在Android中绘制损坏的路径
- python - 如何冻结pygame窗口?
- opengl - OpenGL 中的 Bresenham 算法
- python - 类似于列表框的树视图的诅咒选择
- python - python中的分布式读写锁
- c++ - BOOT-INF/lib/*.jar 下的 Spring Boot fat/uber jar 中的 JNI C++ findClass()
- python - Visual Studio 代码 python