提问人:euam23 提问时间:11/17/2023 最后编辑:TylerHeuam23 更新时间:11/17/2023 访问量:36
需要帮助在柱上方绘制/显示多个价格
Need help to plot / display multiple prices above bar
问:
我创建了这个指标,它向我显示我的 1.5:1、2:1 和 3:1 RR 线。这些线基于之前的蜡烛最高价和最低价。高是我的长线,低是我的SL。我想在 1.5:1、2:1 和 3:1 线旁边显示价格。 我在栏下方有一个简单的标签,已经向我显示了高、低和半范围。我只是无法弄清楚如何根据我的行只显示价格。
理想情况下,我希望价格标签看起来像这样
我不是程序员,但我可以阅读手册。有时我只需要朝着正确的方向推动它来解决问题。任何帮助将不胜感激
//@version=5
indicator(title="RR lines", overlay=true,max_labels_count=500)
//Input Options Full Range
fullRangeLong = input.bool(false, "FR Long")
fullRangeShort = input.bool(false, "FR Short")
//Time Options Input
i_hour = input.int(1, "Time (HH:mm)",0, 23, 1, inline = "A")
i_minute = input.int(0, ":",0, 59, 1, inline = "A")
// create options for the different days of the week.
i_sunday = input.bool(true, "Sunday")
i_monday = input.bool(true, "Monday")
i_tuesday = input.bool(true, "Tuesday")
i_wednesday = input.bool(true, "Wednesday")
i_thursday = input.bool(true, "Thursday")
i_friday = input.bool(true, "Friday")
i_saturday = input.bool(true, "Saturday")
start = input.time(timestamp("01 Nov 2023 12:00 UTC+0"), "Start")
end = input.time(timestamp("16 Nov 2023 12:00 UTC+0"), "End")
// Parameters
candleRange = (high-low)
halfRange = (candleRange / 2)
//@variable Checks the time of the candle and gets the day of the week as represented by numbers 1-7, starting on Sunday.
todayDay = dayofweek(time)
// Define Time for Candle
candleTime(_hour, _mins) =>
// Created 2 variables that need to be true in order to return true.
isTimeMatch = hour == _hour and minute == _mins
isTodayShown = switch todayDay
1 => i_sunday
2 => i_monday
3 => i_tuesday
4 => i_wednesday
5 => i_thursday
6 => i_friday
7 => i_saturday
isTimeMatch and isTodayShown
// Full Range RR Lines Long//
if time >= start and time <= end and candleTime(i_hour, i_minute) and (fullRangeLong == true)
//Buy Price
line.new(x1=time, y1=high, x2=time + 86400000, y2= high, xloc=xloc.bar_time, color = color.yellow),
// Stop Loss
line.new(x1=time, y1= low, x2=time + 86400000, y2= low,xloc=xloc.bar_time, color = color.white)
//1:1
line.new(x1=time, y1= high + (candleRange*1.5), x2=time + 86400000, y2=high + (candleRange*1.5), xloc=xloc.bar_time, color = color.green)
//2:1
line.new(x1=time, y1= high+ (candleRange*2), x2=time + 86400000, y2= high + (candleRange*2), xloc=xloc.bar_time)
//Take Profit 3:1
line.new(x1=time, y1= high + (candleRange*3), x2=time + 86400000, y2= high + (candleRange*3), xloc=xloc.bar_time, color = color.orange),
myLabel = label.new(x=bar_index, y=high, color=color.white,
style=label.style_label_up, size=size.small,
text =
"H: "+ str.tostring(high) +
"\nL: " + str.tostring(low) +
"\nR: " + str.tostring(candleRange))
// Modify the label's y-axis behaviour; show it below the price bar
label.set_yloc(id=myLabel, yloc=yloc.belowbar)
// Full Range RR Lines Short//
if time >= start and time <= end and candleTime(i_hour, i_minute) and (fullRangeShort == true)
// Buy Price
line.new(x1 = time, y1 = low, x2 = time + 86400000, y2 = low, xloc = xloc.bar_time, color = color.yellow)
//Stop Loss
line.new(x1 = time, y1 = high, x2 = time + 86400000, y2 = high, xloc = xloc.bar_time, color = color.white)
// 1:1
line.new(x1 = time, y1 = low - (candleRange*1.5), x2 = time + 86400000, y2 = low - (candleRange*1.5), xloc = xloc.bar_time, color = color.green)
//2:1
line.new(x1 = time, y1 = low - (candleRange*2), x2 = time + 86400000, y2 = low - (candleRange*2), xloc = xloc.bar_time)
// 3:1 Take Profit
line.new(x1 = time, y1 = low - (candleRange*3), x2 = time + 86400000, y2 = low - (candleRange*3), xloc = xloc.bar_time, color = color.orange),
myLabel = label.new(x=bar_index, y=high, color=color.white,
style=label.style_label_down, size=size.small,
text =
"H: "+ str.tostring(high) +
"\nL: " + str.tostring(low) +
"\nR: " + str.tostring(candleRange))
// Modify the label's y-axis behaviour; show it above the price bar
label.set_yloc(id=myLabel, yloc=yloc.abovebar)
我试图在myLabel中实现yloc = yloc.price,但似乎无法让它工作。当我定义 x 和 y 时,就像我在条形图下方的简单标签上所做的那样,当我添加 xloc = 和 yloc = yloc.price 时,它不会显示任何内容。
答: 暂无答案
评论