首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当我运行这段代码时,图表中没有发生任何事情。

当我运行这段代码时,图表中没有发生任何事情。
EN

Stack Overflow用户
提问于 2022-07-07 15:43:19
回答 1查看 34关注 0票数 0
代码语言:javascript
运行
复制
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jithuldevaraj01

//@version=5

strategy ("VRD's MA Crossover Strategy v1", overlay = true)
start = timestamp (2007, 1,1,0,0)
end = timestamp (2021,6,1,0,0)
ema1 = ta.ema(close, 20)
ema2 = ta.ema(close, 50)
plot (ema1, title = "EMA20", color = color.blue,)
plot (ema2, title = "EMA50", color = color.green)

//strategy
LongEntry = ta.crossover (ema1, ema2)
LongExit = ta.crossover (ema2, ema1)
ShortEntry = ta.crossover (ema2, ema1)
ShortExit = ta.crossover (ema1, ema2)

if time >= start and time < end
    strategy.entry ("Long", strategy.long, 1, when = LongEntry)
    strategy.close ("Long", when = LongExit)
    strategy.entry ("Short", strategy.short, 1, when = ShortEntry)
    strategy.close ("Short", when = ShortExit)

当我运行这段代码时,这条消息是打印“添加到图表中的脚本研究”,但是没有发生在图表上。

EN

回答 1

Stack Overflow用户

发布于 2022-07-08 07:49:00

在行下面似乎有一个额外的逗号。

代码语言:javascript
运行
复制
plot (ema1, title = "EMA20", color = color.blue,)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72900745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档