如何将 plot 语句放入 if 语句中 [英] How to put plot statement inside if statement

查看:98
本文介绍了如何将 plot 语句放入 if 语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在价格上绘制权益曲线,将策略与简单的买入和持有进行比较.为了使图表有用,权益曲线可以从初始权益开始,或者与图表上的第一个价格一致,或者根本没有权益曲线,具体取决于手动输入.

I want to plot the equity curve on the price, to compare the strategy to simple buy and hold. To make the graph useful, the equity curve could either start on the initial equity, or in line with the first price on the graph or no equity curve at all depending on manual input.

使用下面的代码,我得到了这个:

Using the code below, I get this:

  • 第 xx 行:不能在局部范围内使用绘图".

  • line xx: Cannot use 'plot' in local scope.

第 xx 行:不能在局部范围内使用绘图".

line xx: Cannot use 'plot' in local scope.

equitycurvetype = input(defval="No", title='Equity Curve Type', options=["No","Yes","Yes same start"])
if equitycurvetype == "Yes" 
    plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)  
if equitycurvetype == "Yes same start" 
    plot(strategy.equity * close[bar_index]/strategy.initial_capital, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)

推荐答案

plot(Trailingsl, title = "SuperTrend", color = linecolor ,  linewidth = 2, transp = showSuperTrend ? 0 : 100)

解决方法:

transp = showSuperTrend ? 0 : 100

这篇关于如何将 plot 语句放入 if 语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆