PineScript:如何通过价格线在 y 轴上平移价格线?保持平坦෴ -> _____

发布于 2025-01-13 19:04:02 字数 2227 浏览 3 评论 0原文

如何获取 Pine Script 的最新价格?

输入图片此处描述

该号码。

我需要它作为浮动而不是串联浮动。

这样做:

//@version=5
indicator(title="EURUSD")
inputEURUSD = input.symbol("EURUSD")
EURUSDprice = request.security(inputEURUSD, timeframe.period, close)
lastPriceEURUSD = EURUSDprice[0] 
EURUSDtoZero = EURUSDprice - 1.09107 // translate on y-axis manually
EURUSDminusLastPrice = EURUSDprice - lastPriceEURUSD // attempt to translate on y-axis automatically
plot(series=EURUSDprice, color=color.red, title="EURUSD", linewidth=1, style=plot.style_line, trackprice=false) 
plot(series=lastPriceEURUSD, color=color.green, title="EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 
plot(series=EURUSDtoZero, color=color.blue, title="EURUSD-1.09107", linewidth=1, style=plot.style_line, trackprice=false) 
plot(series=EURUSDminusLastPrice, color=color.white, title="EURUSD-EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 

给你一条平坦的线。正如它应该: 输入图片此处描述输入图片此处描述但是如果:

priceEURUSD[0]

给你一个系列,那么我怎样才能得到这个数字作为浮点数而不是系列浮点数,并用它来将价格线在 y 轴上向下平移这么多单位?


更新:

基本上,我需要它来表示单个图表中不同程度的运动。 以这些无聊的行为例:

在此处输入图像描述

它们毫无意义。但通过在 y 轴上进行一些手动平移,它们开始呈现有意义的形状:

在此处输入图像描述

因此,必须在某个地方找到一种自动方法来按最后价格翻译它们。

更重要的是——你能让它们越趋同,它们就会变得越明显和有意义。


答案:

在此处输入图像描述

ta.tsi(USDEURprice, 10, 10)

上图显示,上面的线是手动翻译的,下面的线是用 ta.tsi() 完成的。

分辨率可以用“10, 10”(较小的,越好 解决)

How can I get the last price in Pine Script?

enter image description here

That number.

I need it as a float instead of series float.

Doing this:

//@version=5
indicator(title="EURUSD")
inputEURUSD = input.symbol("EURUSD")
EURUSDprice = request.security(inputEURUSD, timeframe.period, close)
lastPriceEURUSD = EURUSDprice[0] 
EURUSDtoZero = EURUSDprice - 1.09107 // translate on y-axis manually
EURUSDminusLastPrice = EURUSDprice - lastPriceEURUSD // attempt to translate on y-axis automatically
plot(series=EURUSDprice, color=color.red, title="EURUSD", linewidth=1, style=plot.style_line, trackprice=false) 
plot(series=lastPriceEURUSD, color=color.green, title="EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 
plot(series=EURUSDtoZero, color=color.blue, title="EURUSD-1.09107", linewidth=1, style=plot.style_line, trackprice=false) 
plot(series=EURUSDminusLastPrice, color=color.white, title="EURUSD-EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 

Gives you a flat line. As it should:
enter image description here
enter image description here
But if:

priceEURUSD[0]

gives you a series, than, how can I get that number as a float instead of series float, and use it to translate the priceline downwards by that many units on y-axis?


UPDATE:

I need it, basically, to represent varying degrees of movement in a single graph.
Take these boring lines, for example:

enter image description here

They're meaningless. But with a bit of manual translation on the y-axis, they start to take a meaningful shape:

enter image description here

So an automatic way to translate them by their last price, has to be found somewhere.

Even more so - the more converging you can get them, the more pronounced and meaningful they become.


ANSWER:

enter image description here

ta.tsi(USDEURprice, 10, 10)

Above graph shows, the upper lines, been translated manually and the bottom lines, been done with ta.tsi()

The resolution can be controlled with the "10, 10" (the smaller, the better resolution)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

驱逐舰岛风号 2025-01-20 19:04:03

欧元兑美元价格是数字。 [0] 是不需要的并且不添加任何内容。您可以在其他计算中使用 EURUSDprice。最后价格为 [1],如一栏前所示...

EURUSDprice is the number. [0] is not needed and adds nothing. You can use EURUSDprice in other calculations. Last price is [1] as in one bar ago...

浊酒尽余欢 2025-01-20 19:04:02

我希望我理解你的想法,你可以使用ta.tsi真实强度指数。它使用金融工具潜在动量的移动平均线。
真实强度指数指标图表

//@version=5
indicator(title="EURUSD")

fast=9
slow=9

inputEURUSD = input.symbol("EURUSD")
price = request.security(inputEURUSD, timeframe.period, close)
EURUSDtoZero = price - 1.09107 // translate on y-axis manually
EURUSDminusLastPrice = price - price[close] // attempt to translate on y-axis automatically



EURUSDprice_tsi = ta.tsi(price, slow, fast)
lastPriceEURUSD_tsi = ta.tsi(price[close], slow, fast)
EURUSDtoZero_tsi = ta.tsi(EURUSDtoZero, slow, fast)
EURUSDminusLastPrice_tsi = ta.tsi(EURUSDminusLastPrice, slow, fast)

plot(EURUSDprice_tsi,color=color.red, title="EURUSD", linewidth=1, style=plot.style_line, trackprice=false) 
plot(lastPriceEURUSD_tsi, color=color.green, title="EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 
plot(EURUSDtoZero_tsi, color=color.blue, title="EURUSD-1.09107", linewidth=1, style=plot.style_line, trackprice=false) 
plot(EURUSDminusLastPrice_tsi,color=color.red, color=color.white, title="EURUSD-EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 

I hope I understood your idea, You can use ta.tsi true strength index. It uses moving averages of the underlying momentum of a financial instrument.
chart for true strength index indicator

//@version=5
indicator(title="EURUSD")

fast=9
slow=9

inputEURUSD = input.symbol("EURUSD")
price = request.security(inputEURUSD, timeframe.period, close)
EURUSDtoZero = price - 1.09107 // translate on y-axis manually
EURUSDminusLastPrice = price - price[close] // attempt to translate on y-axis automatically



EURUSDprice_tsi = ta.tsi(price, slow, fast)
lastPriceEURUSD_tsi = ta.tsi(price[close], slow, fast)
EURUSDtoZero_tsi = ta.tsi(EURUSDtoZero, slow, fast)
EURUSDminusLastPrice_tsi = ta.tsi(EURUSDminusLastPrice, slow, fast)

plot(EURUSDprice_tsi,color=color.red, title="EURUSD", linewidth=1, style=plot.style_line, trackprice=false) 
plot(lastPriceEURUSD_tsi, color=color.green, title="EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 
plot(EURUSDtoZero_tsi, color=color.blue, title="EURUSD-1.09107", linewidth=1, style=plot.style_line, trackprice=false) 
plot(EURUSDminusLastPrice_tsi,color=color.red, color=color.white, title="EURUSD-EURUSD[0]", linewidth=1, style=plot.style_line, trackprice=false) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文