以每天特定时间的5分钟柱高价绘制图表

huangapple go评论70阅读模式
英文:

Plot high price of specific 5-minute bar at certain time of each day

问题

我想要在Pinescript中绘制每天2045时的5分钟柱高价。

让我通过一个示例来澄清。

假设今天是6月28日。在6月28日的2045时,将绘制一个水平线,该线位于2045时的5分钟柱的高价,并保持在此值直到第二天。第二天是6月29日,水平线将移至6月29日的2045时的5分钟柱的高价。同样的过程会每天重复一次。

我正在使用Pinescript v5

谢谢。

英文:

I would like to plot the high price of the 5-minute bar at 2045hrs of each day in pinescript.

Let me clarify with an example.

Suppose today is 28 June. At 2045hrs on 28June, a horizontal line at high price of the 5-minute bar at 2045hrs will be plotted and remains at this value until the next day. On the next day 29 June, the horizontal line will shift to the high price of the 5-minute bar at 2045hrs on 29June. The same process repeats for each day.

I am using pinescript v5

Thank you.

答案1

得分: 2

I see the Pine Script request.security() function is used to request data from other contexts than the chart's. In particular, from other timeframes.

But in your case, you can create a script designed to be applied directly to a 5-minute chart. The script operates on the 5-minute timeframe and captures the high price of the 5-minute bar at 20:45 each day.

Combine that with plot(), and you can try, daily:

//@version=5
indicator("20:45 High Price Plotter", overlay=true, shorttitle="HP@2045")

var float highPriceAt2045 = na

if (hour == 20) and (minute == 45)
    highPriceAt2045 := high

plot(highPriceAt2045[1], color=color.red, linewidth=2, title="High Price at 20:45", trackprice=true)

This script should be applied to a 5-minute chart in TradingView. It checks if the current 5-minute bar is at 20:45, and if so, captures the high price of that bar and plots it as a horizontal line. The line remains at this value until 20:45 the next day, at which point it will update to the new high price of that day's 20:45 bar.

英文:

I see the Pine Script request.security() function is used to request data from other contexts than the chart's. In particular, from other timeframes.
But in your case, you can create a script designed to be applied directly to a 5-minute chart. The script operates on the 5-minute timeframe and captures the high price of the 5-minute bar at 20:45 each day.

Combine that with plot(), and you can try, daily:

//@version=5
indicator("20:45 High Price Plotter", overlay=true, shorttitle="HP@2045")

var float highPriceAt2045 = na

if (hour == 20) and (minute == 45)
    highPriceAt2045 := high

plot(highPriceAt2045[1], color=color.red, linewidth=2, title="High Price at 20:45", trackprice=true)

This script should be applied to a 5-minute chart in TradingView. It checks if the current 5-minute bar is at 20:45, and if so, captures the high price of that bar and plots it as a horizontal line. The line remains at this value until 20:45 the next day, at which point it will update to the new high price of that day's 20:45 bar.

答案2

得分: 1

我想回答自己的问题以供将来参考,因为这更适合我的需求。 答案基于@Vonc的答案,已被标记为正确答案。

var float highPriceAt2045 = na

if (hour(time, timezone="Asia/Singapore") == 20 and minute(time, timezone="Asia/Singapore") == 45)
    highPriceAt2045 := high

plot(highPriceAt2045[1], color=color.red, linewidth=2, title="20:45的最高价格", trackprice=true)

主要区别是我添加了本地时区。

英文:

I would like to answer my own question for future reference since it's more suitable for my needs. The answer is based on the answer from @Vonc which has been marked as the right answer.

var float highPriceAt2045 = na

if ( hour(time, timezone="Asia/Singapore") == 20 and minute(time, timezone="Asia/Singapore") == 45)
    highPriceAt2045 := high

plot(highPriceAt2045[1], color=color.red, linewidth=2, title="High Price at 20:45", trackprice=true)

The main difference is I added local timezone.

huangapple
  • 本文由 发表于 2023年6月29日 17:20:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76579741.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定