我正在尝试在我从日期时间选择器中选择的烛形条(必须为 15 分钟的时间范围)的高低绘制 hline(水平线)。到目前为止,我可以选择栏并突出显示其背景颜色以确认日期时间选择器工作正常。但是,我无法在所选柱的高低处绘制水平线。这里的问题是,我不知道如何获得我从日期时间选择器中选择的条形的高低。下面是代码。
//@version=4
study("Price Channel with date range test", overlay=true)
i_startTime = input(defval = timestamp("06 May 2021 04:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("06 May 2021 04:45 +0000"), title = "End Time", type = input.time)
inDateRange = time >= i_startTime and time <= i_endTime
bgcolor(inDateRange ? color.lime : na, 90)
// Need code to get the high and low of this candle stick bar selected from the date time picker
答案 0 :(得分:0)
下面为您提供了将线条设置为:右侧或整个图表(设置中的复选框)的选项。
这就是你所追求的吗?
//@version=4
study("Price Channel with time range", overlay=true)
i_startTime = input(defval = timestamp("07 May 2021 04:30 +0000"), title = "Start Time", type = input.time)
i_endTime = input(defval = timestamp("07 May 2021 04:30 +0000"), title = "End Time", type = input.time)
inDateRange = time >= i_startTime and time <= i_endTime
bgcolor(inDateRange ? color.lime : na, 90)
var highe_01 = 0.0
var lowe_01 = 0.0
if inDateRange
if not inDateRange[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
//plot(not inDateRange ? highe_01 : na, title="High", color=color.purple, linewidth=2, style=plot.style_linebr)
//plot(not inDateRange ? lowe_01: na, title="Low", color=color.purple, linewidth=2, style=plot.style_linebr)
///////////////////////////////
showHigh = input(true, title="High", group="High Line", inline="1")
showLow = input(true, title="Low", group="Low Line", inline="1")
ExtendAxisLine = input(false, title="Extend lines across screen")
ExtendOption = ExtendAxisLine ? extend.both : extend.right
HighDateLine = (not inDateRange ? highe_01 : na)
var line ShowHighLine = na
if showHigh
ShowHighLine := line.new(bar_index[1], HighDateLine, bar_index, HighDateLine, color=color.yellow, style=line.style_dashed, width=1, extend=ExtendOption)
line.delete(ShowHighLine[1])
LowDateLine = (not inDateRange ? lowe_01 : na)
var line ShowLowLine = na
if showLow
ShowLowLine := line.new(bar_index[1], LowDateLine, bar_index, LowDateLine, color=color.yellow, style=line.style_dashed, width=1, extend=ExtendOption)
line.delete(ShowLowLine[1])
答案 1 :(得分:0)
工作代码。
const Container = () =>
{
useEffect(() => {
fetch("http://localhost:5000/user") // could be any rest get url
.then(response => response.json())
.then(result =>
this.setState({
userData: result
})
);
}, []);
changeColor = (params) => {
this.setState({
color: params.target.value
})
}
changeSize = (params) => {
this.setState({
size: params.target.value
})
}
render() {
const dragUrl = React.useRef();
const stageRef = React.useRef();
const [images, setImages] = React.useState([]);
return (
<div className="container">
<div className="tools-section">
<div className="color-picker-container">
Select Brush Color :
<input type="color" value={this.state.color} onChange={this.changeColor.bind(this)}/>
</div>
<div className="brushsize-container">
Select Brush Size :
<select value={this.state.size} onChange={this.changeSize.bind(this)}>
<option> 5 </option>
<option> 10 </option>
<option> 15 </option>
<option> 20 </option>
<option> 25 </option>
<option> 30 </option>
</select>
</div>
</div>
<div className="board-container">
<h4>Select picture!</h4>
<table>
<tbody>
{this.state.userData.map((data, key) => {
return (
<tr key={key}>
<img src={data.picture} class="img" draggable="true"
onDragStart={(e) => {
dragUrl.current = e.target.src;
}}/> // column data received
</tr>
);
})}
</tbody>
</table>
<div onDrop={(e) => {
e.preventDefault();
// register event position
stageRef.current.setPointersPositions(e);
// add image
setImages(
images.concat([
{
...stageRef.current.getPointerPosition(),
src: dragUrl.current,
},
])
);
}}
onDragOver={(e) => e.preventDefault()}
><Board color={this.state.color} size={this.state.size}></Board></div>
</div>
</div>
);
}
}
export default Container;