如何根据最新的“n”根蜡烛的最高点绘制一条水平直线?

时间:2021-01-07 21:34:57

标签: pine-script algorithmic-trading trading

我想在最新的“n”支蜡烛的最高处绘制一条水平直线。不是基于 'n' 根蜡烛中最高的,而是基于所有这些 'n' 根蜡烛中最高的。请检查屏幕截图。

我知道情节从过去开始,并在“未来”发生某些事情时发生变化,但由于数据全部存在,我认为这种逻辑也可以实现。

以下是通常的“highesthigh”代码,但当然不适用于此。

<form>
  <label for="cpuOption">Desired CPU Configuration</label>
  <select id="cpuOption" onchange="fn1()">
    <option value="none" selected>select</option>
    <option value="cpu_1">cpu-1</option>
    <option value="cpu_2">cpu-2</option>
    <option value="cpu_3">cpu-3</option>
  </select>
</form>

<h2>Check it out!</h2>
<button onclick="fn1()">Click me</button>
<div id="test"></div>

任何帮助将不胜感激!

enter image description here

1 个答案:

答案 0 :(得分:1)

//@version=4
study("Help (line back)", overlay=true)

bars_back=input(5,"Bars back")
n        =input(10, "High back")

highestHigh = highest(high, n)
line.new(bar_index-bars_back, highestHigh, bar_index, highestHigh, extend=extend.none) // draws a line to the next high