简体   繁体   English

Pine 脚本:当它发生时指示所有时间高/低

[英]Pine script: indicating all time high/low when it occurs

I want to indicate the bar at which the absolute all time high/low occurs.我想指出出现绝对历史高点/低点的柱线。 This means that if the previous all time/high low is superseded by a new one, the old one(s) shouldn't be indicated.这意味着如果之前的所有时间/最高低点被新的取代,则不应指示旧的。 Using hints from here , I was able to come up with this:使用这里的提示,我能够想出这个:

//@version=5

// initialization 
indicator(title="test", shorttitle="test", overlay=true)

// functions
allTimetHi(source) =>
    var atHi = source
    atHi := math.max(atHi, source)

allTimetLo(source) =>
    var atLo = source
    atLo := math.min(atLo, source)

plotchar(high == allTimetHi(high), title = "title", char = "*", location = location.abovebar, size = size.normal, color = color.lime)
plotchar(low == allTimetLo(low), title = "title", char = "*", location = location.belowbar, size = size.normal, color = color.red)

However, as can been seen from the image below, every local all time high/low is indicated:但是,从下图中可以看出,每个本地历史高点/低点都被指示: 在此处输入图像描述

Is there a way to achieve the effect that I want?有没有办法达到我想要的效果?

I would just use a label on each new high/low, and delete previous label :我会在每个新的高/低上使用一个label ,并删除以前的label

//@version=5

indicator(title="test", shorttitle="test", overlay=true)

var float allTimetHi = 0
var float allTimetLo = 9999999999999999

allTimetHi := math.max(allTimetHi, high)
allTimetLo := math.min(allTimetLo, low)

if high == allTimetHi
    highLabel = label.new(bar_index, high, text="Highest High!", style=label.style_label_down, color=color.green)
    label.delete(highLabel[1])
    
if low == allTimetLo
    lowLabel = label.new(bar_index, low, text="Lowest Low!", style=label.style_label_up, color=color.red)
    label.delete(lowLabel[1])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Pine Script 中无法正确绘制历史最高记录 - All-time-high not plotting correctly in Pine Script 如何在特定时间内; plot Pine 脚本中的最高高和最低低 - How to within a specific time; plot the highest high and the lowest low in Pine script Pine Script - 如何 select 一个带有日期时间选择器的蜡烛条,并在此条的高点和低点绘制水平线 - Pine Script - How to select a candle stick bar with date time picker and draw horizontal lines at the high and low of this bar 如何 Plot 价格 label 当 Pivot 交叉或前一天高或低交叉发生时松脚本 - How to Plot Price label when Pivot crossover or Previous Day High or Low Crossover Occur-Pine Script Pine Script 中第一根蜡烛的高点和低点之间的点数 - Number of pips between high and low of First Candle in Pine Script 使用松脚本绘制前一天的高/低/收盘价 - Plotting previous day high/low/close using pine script 如何在松树脚本中找到蜡烛的日高/低 - How to find the candle has day high / low in pine script 使用 Pine Script v5 的前一天最高价和最低价 - Previous Day High and Low using Pine Script v5 在松树脚本中填充柱线的低点/高点下方/上方的订单 - Fill order below/above the low/ high of the bar in pine script 如何在 pine 脚本中获取图表 window 的低点和高点? - How to get the low and high of the chart window in pine script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM