我无法在绘图()和浮点变量上克服的基本问题
我在这里要问的是太简单了,但我在编程和pinescript上的新手不太好。 我试图编写一种基本策略,以便准备好算法,然后在编写整个策略之前查看其是否有效,以将其编写为指标。 我有几个问题。首先是系列浮动和整数。为了过来,我尝试了一些愚蠢的想法将我的var定义为已经定义的浮子,就像这里:
Sar = ta.sar(0.02, 0.02, 0.2)
[BBmiddle, BBupper, BBlower] = ta.bb(close, 20, 2)
SarMid = BBmiddle-BBmiddle
SarMidH = SarMid
stopP = SarMid
然后在我的if上使用它们:
if Sar[2] > close[2] and Sar[1] < close[1]
stopP := BBlower,
takeP1 := open - BBlower
然后更好地可视化,我使用了这样的绘图形状:
plotshape(stopP, color=color.red, style=shape.triangleup, text="Stop Point", location=location.absolute)
plotshape(takeP1, color=color.green, style=shape.triangledown, text="Take Profit Point 1", location=location.absolute)
到目前为止, '但是在这个阶段,主要问题是图表也将这些图也放在图表的底部。我猜这是因为我之前已经定义了stopp和takep1,但是我无法在if中创建它们。什么会帮助我克服这一点?预先感谢您
most probably what im going to ask here is too simple but im not that much good on programming and total newbie on pinescript.
im trying to write a basic strategy, in order to ger algo ready and see if its working before writing whole strategy im writing it as an indicator.
im having a couple of issues. first, series float and integer. in order to over come this i tried some silly idea to define my vars to tw already defined floats, like here:
Sar = ta.sar(0.02, 0.02, 0.2)
[BBmiddle, BBupper, BBlower] = ta.bb(close, 20, 2)
SarMid = BBmiddle-BBmiddle
SarMidH = SarMid
stopP = SarMid
then used them on my if's like:
if Sar[2] > close[2] and Sar[1] < close[1]
stopP := BBlower,
takeP1 := open - BBlower
and then to better visualize this i used plotshapes like this:
plotshape(stopP, color=color.red, style=shape.triangleup, text="Stop Point", location=location.absolute)
plotshape(takeP1, color=color.green, style=shape.triangledown, text="Take Profit Point 1", location=location.absolute)
so far so good'ish' but at this stage main problem im having is chart puts these plots to the very bottom of chart as well. im guessing its because i've already defined stopP and takeP1 before but i cant create them inside the if. what would help me to overcome this? thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
sarmid
始终是零(bbmiddle-bbmiddle
),除非您在其他地方修改其值。您仅修改
stopp
当您的条件为true
时。否则,它将保留零
。由于您使用的
location = location.absolute
在基于stopp
绘制形状时,它将这些形状绘制为零
SarMid
is always zero (BBmiddle-BBmiddle
) at the beginning unless you modify its value somewhere else.You only modify
stopP
when your condition istrue
. Otherwise, it will remainzero
.Since you are using
location=location.absolute
when plotting your shape based onstopP
, it plots those shapes atzero