删除价格一旦价格越过

发布于 2025-02-06 03:10:48 字数 4263 浏览 1 评论 0原文

问题在于,我不理解我必须执行的命令,直到线与蜡烛相交,

leftLenL = leftLenH
rightLenL = leftLenH

atr1 = ta.atr(10)

atr2 = ta.atr(10)

atr3 = ta.atr(10)

atr4 = ta.atr(10)

atr5 = ta.atr(10)

atr6 = ta.atr(10)

pos1 = close + close * (0.48 /100)
pos2 = close + close * (1.66 /100)
pos3 = close + close * (3.71 /100)

pos4 = close - close * (0.49 /100)
pos5 = close - close * (1.66 /100)
pos6 = close - close * (3.71 /100)

c = ta.pivothigh(leftLenH,rightLenH)
b = ta.pivotlow(leftLenL, rightLenL)

plotshape(c ? pos1: na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(c ? pos2: na , "50х Ликвилации Лонг", shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(c ? pos3: na , "25х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

plotshape(b ? pos4: na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(b ? pos5: na , "50х Ликвилации Лонг", shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(b ? pos6: na , "25х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

//////Lines//////////

bars = +500
n = 1

var line[]  highs = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs2 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs3 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs4 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs5 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs6 = array.new_line()  // declare an empty array to store our lines in 
//Lines
bull = b
bear = c
highestHigh = pos1
highestHigh2 = pos2
highestHigh3 = pos3
lowerlow1 = pos4
lowerlow2 = pos5
lowerlow3 = pos6
if bear     // instead of just drawing a line, we push it into an array, a list of lines so we can loop through the list and perform actions on all lines 
    array.unshift(highs, line.new(bar_index, highestHigh, bar_index + bars, highestHigh, style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs2, line.new(bar_index, highestHigh2, bar_index + bars, highestHigh2, style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs3, line.new(bar_index, highestHigh3, bar_index + bars, highestHigh3, style = line.style_dotted, extend=extend.none, color=color.red))
if bull
    array.unshift(highs4, line.new(bar_index, lowerlow1, bar_index + bars, lowerlow1,style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs5, line.new(bar_index, lowerlow2, bar_index + bars, lowerlow2,style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs6, line.new(bar_index, lowerlow3, bar_index + bars, lowerlow3,style = line.style_dotted, extend=extend.none, color=color.red))



for x = (array.size(highs) > 0 ? array.size(highs)-1 : na) to 0                        
    line.set_x2(array.get(highs, x), bar_index+bars) 

for x2 = (array.size(highs2) > 0 ? array.size(highs2)-1 : na) to 0                        
    line.set_x2(array.get(highs2, x2), bar_index+bars)  

for x3 = (array.size(highs3) > 0 ? array.size(highs3)-1 : na) to 0                        
    line.set_x2(array.get(highs3, x3), bar_index+bars)  

for x4 = (array.size(highs4) > 0 ? array.size(highs4)-1 : na) to 0                        
    line.set_x2(array.get(highs4, x4), bar_index+bars)  

for x5 = (array.size(highs5) > 0 ? array.size(highs5)-1 : na) to 0                        
    line.set_x2(array.get(highs5, x5), bar_index+bars)  

for x6 = (array.size(highs6) > 0 ? array.size(highs6)-1 : na) to 0                        
    line.set_x2(array.get(highs6, x6), bar_index+bars)  

如果线不相交,则必须继续向右继续直到相交。

我能够通过命令绘制行,

 for i2 = (array.size(highs2) > 0 ? array.size(highs2)-1 : na) to 0  

但是有了这个命令,我显示了一些行,有些则不显示,我不明白为什么

The problem is that I do not understand what command I have to make the line go until it intersects with a candle

leftLenL = leftLenH
rightLenL = leftLenH

atr1 = ta.atr(10)

atr2 = ta.atr(10)

atr3 = ta.atr(10)

atr4 = ta.atr(10)

atr5 = ta.atr(10)

atr6 = ta.atr(10)

pos1 = close + close * (0.48 /100)
pos2 = close + close * (1.66 /100)
pos3 = close + close * (3.71 /100)

pos4 = close - close * (0.49 /100)
pos5 = close - close * (1.66 /100)
pos6 = close - close * (3.71 /100)

c = ta.pivothigh(leftLenH,rightLenH)
b = ta.pivotlow(leftLenL, rightLenL)

plotshape(c ? pos1: na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(c ? pos2: na , "50х Ликвилации Лонг", shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(c ? pos3: na , "25х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

plotshape(b ? pos4: na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(b ? pos5: na , "50х Ликвилации Лонг", shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(b ? pos6: na , "25х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

//////Lines//////////

bars = +500
n = 1

var line[]  highs = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs2 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs3 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs4 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs5 = array.new_line()  // declare an empty array to store our lines in 
var line[]  highs6 = array.new_line()  // declare an empty array to store our lines in 
//Lines
bull = b
bear = c
highestHigh = pos1
highestHigh2 = pos2
highestHigh3 = pos3
lowerlow1 = pos4
lowerlow2 = pos5
lowerlow3 = pos6
if bear     // instead of just drawing a line, we push it into an array, a list of lines so we can loop through the list and perform actions on all lines 
    array.unshift(highs, line.new(bar_index, highestHigh, bar_index + bars, highestHigh, style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs2, line.new(bar_index, highestHigh2, bar_index + bars, highestHigh2, style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs3, line.new(bar_index, highestHigh3, bar_index + bars, highestHigh3, style = line.style_dotted, extend=extend.none, color=color.red))
if bull
    array.unshift(highs4, line.new(bar_index, lowerlow1, bar_index + bars, lowerlow1,style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs5, line.new(bar_index, lowerlow2, bar_index + bars, lowerlow2,style = line.style_dotted, extend=extend.none, color=color.red))
    array.unshift(highs6, line.new(bar_index, lowerlow3, bar_index + bars, lowerlow3,style = line.style_dotted, extend=extend.none, color=color.red))



for x = (array.size(highs) > 0 ? array.size(highs)-1 : na) to 0                        
    line.set_x2(array.get(highs, x), bar_index+bars) 

for x2 = (array.size(highs2) > 0 ? array.size(highs2)-1 : na) to 0                        
    line.set_x2(array.get(highs2, x2), bar_index+bars)  

for x3 = (array.size(highs3) > 0 ? array.size(highs3)-1 : na) to 0                        
    line.set_x2(array.get(highs3, x3), bar_index+bars)  

for x4 = (array.size(highs4) > 0 ? array.size(highs4)-1 : na) to 0                        
    line.set_x2(array.get(highs4, x4), bar_index+bars)  

for x5 = (array.size(highs5) > 0 ? array.size(highs5)-1 : na) to 0                        
    line.set_x2(array.get(highs5, x5), bar_index+bars)  

for x6 = (array.size(highs6) > 0 ? array.size(highs6)-1 : na) to 0                        
    line.set_x2(array.get(highs6, x6), bar_index+bars)  

If the line does not intersect, then it must continue to the right until it intersects.

I was able to draw lines through the command

 for i2 = (array.size(highs2) > 0 ? array.size(highs2)-1 : na) to 0  

But with this command I had some of the lines displayed and some not, and I don't understand why

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2025-02-13 03:10:48

要检查价格是否与线路相交,我们需要循环一系列线以检查每个线路,并在每个栏上进行此操作。枢轴高点在当前价格之上形成 - 我们可以检查这组与Bar High的线路,因为我们知道我们最初将在线以下。枢轴最低始终在低点下形成,因此我们需要按照最初的比例检查针对条低的线条。所以我们有2组; 2个线条。我们可以制作一个函数来扩展行 - 这很容易。我们循环每个数组并正确扩展线路。但是,我们如何排除价格相交的呢?我们需要从数组中删除它们。因此,我们检查每个栏高还是低,以查看它是否损坏了每条线,如果有的话,我们将x2设置为当前条并将其从数组中删除。这样,我们就不会继续扩展它。我已经在以下代码中包括了更多注释:

//@version=5
indicator("Lines", overlay=true, max_lines_count = 500)

leftLenH  = 20 
rightLenH = 20

leftLenL  = leftLenH
rightLenL = rightLenH

highestHigh  = close + close * (0.48 /100)
highestHigh2 = close + close * (1.66 /100)
highestHigh3 = close + close * (3.71 /100)

lowerlow1 = close - close * (0.49 /100)
lowerlow2 = close - close * (1.66 /100)
lowerlow3 = close - close * (3.71 /100)

bear = ta.pivothigh(leftLenH,rightLenH)
bull = ta.pivotlow(leftLenL, rightLenL)

plotshape(bear ? highestHigh : na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(bear ? highestHigh2: na , "50х Ликвилации Лонг",  shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(bear ? highestHigh3: na , "25х Ликвидации Лонг",  shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

plotshape(bull ? lowerlow1: na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(bull ? lowerlow2: na , "50х Ликвилации Лонг",  shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(bull ? lowerlow3: na , "25х Ликвидации Лонг",  shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

//////Lines//////////

bars = +500
n = 1

var line[]  highs = array.new_line()  // declare an empty array to store our lines in 
var line[]  lows  = array.new_line()  // declare an empty array to store our lines in 

// Function to add same line type to an array at a given level
addLine(arr, y) =>
    array.unshift(arr, line.new(bar_index, y, bar_index + bars, y, style = line.style_dotted, extend=extend.none, color=color.red))

// Function to loop line array extending right 
extend(arr, len) =>
    for l in arr                 
        line.set_x2(l, len)

// Function to end lines on current bar if significant point breaks line price
// m is used as a multiplier to inverse the bool condition allowing the same function to be used to check for highs or lows 
// a multiplier of 1 is used for highs and -1 for lows to take the inverse of the condition 
// We run the loop backwards to avoid indexing errors when removing elements 
// we remove the line from the array after setting the x2 at the current bar so that we do not continue to extend it to the right 
endLine(arr, m) =>
    p = m > 0 ? high : low // check high or low depending on inverse or not 
    if array.size(arr) > 0
        for i  = array.size(arr)-1 to 0
            l  = array.get(arr, i) 
            lp = line.get_price(l, bar_index)
            if p * m > lp * m // check price against line price. multiply by 1 or -1 for inverse operation 
                line.set_x2(l, bar_index)
                array.remove(arr, i)

if bear     // instead of just drawing a line, we push it into an array, a list of lines so we can loop through the list and perform actions on all lines 
    addLine(highs, highestHigh)
    addLine(highs, highestHigh2)
    addLine(highs, highestHigh3)

if bull
    addLine(lows, lowerlow1)
    addLine(lows, lowerlow2)
    addLine(lows, lowerlow3)

// check highs against pivot highs
// check lows against pivot lows 
// set line at current bar if broken 
// remove from arrays 
endLine(highs, 1)
endLine(lows, -1)

// extend lines in both arrays to the right
extend(highs, bar_index + bars)
extend(lows,  bar_index + bars)

**注意**最大线计数可以在指示器()标题

欢呼声中调整,并在您的编码和交易中运气最好。

To check if price intersects the lines we need to loop an array of lines to check each against the current bar and do this on each bar. Pivot highs are formed above the current price - we can check this group of lines against bar highs as we know we will be below the line initially. Pivot lows are always formed under the low, so we need to check this group of lines against bar lows as we were above initially. So we have 2 groups; 2 arrays of lines. We can make one function to extend the lines - this is easier. We loop each array and extend the lines right. But how do we exclude ones that price has intersected? We need to remove them from the array. So we check each bar high or low to see if it has broke each line, if it has we set the x2 to the current bar and remove it from the array. This way we do not continue to extend it. I have included further notes in the following code:

//@version=5
indicator("Lines", overlay=true, max_lines_count = 500)

leftLenH  = 20 
rightLenH = 20

leftLenL  = leftLenH
rightLenL = rightLenH

highestHigh  = close + close * (0.48 /100)
highestHigh2 = close + close * (1.66 /100)
highestHigh3 = close + close * (3.71 /100)

lowerlow1 = close - close * (0.49 /100)
lowerlow2 = close - close * (1.66 /100)
lowerlow3 = close - close * (3.71 /100)

bear = ta.pivothigh(leftLenH,rightLenH)
bull = ta.pivotlow(leftLenL, rightLenL)

plotshape(bear ? highestHigh : na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(bear ? highestHigh2: na , "50х Ликвилации Лонг",  shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(bear ? highestHigh3: na , "25х Ликвидации Лонг",  shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

plotshape(bull ? lowerlow1: na , "100х Ликвидации Лонг", shape.circle, location.absolute, color.black, 0, "100х Ликвидации", (color.black), size=size.tiny)
plotshape(bull ? lowerlow2: na , "50х Ликвилации Лонг",  shape.circle, location.absolute, color.black, 0, "50х Ликвидации", (color.black), size=size.tiny)
plotshape(bull ? lowerlow3: na , "25х Ликвидации Лонг",  shape.circle, location.absolute, color.black, 0, "25х Ликвидации", (color.black), size=size.tiny)

//////Lines//////////

bars = +500
n = 1

var line[]  highs = array.new_line()  // declare an empty array to store our lines in 
var line[]  lows  = array.new_line()  // declare an empty array to store our lines in 

// Function to add same line type to an array at a given level
addLine(arr, y) =>
    array.unshift(arr, line.new(bar_index, y, bar_index + bars, y, style = line.style_dotted, extend=extend.none, color=color.red))

// Function to loop line array extending right 
extend(arr, len) =>
    for l in arr                 
        line.set_x2(l, len)

// Function to end lines on current bar if significant point breaks line price
// m is used as a multiplier to inverse the bool condition allowing the same function to be used to check for highs or lows 
// a multiplier of 1 is used for highs and -1 for lows to take the inverse of the condition 
// We run the loop backwards to avoid indexing errors when removing elements 
// we remove the line from the array after setting the x2 at the current bar so that we do not continue to extend it to the right 
endLine(arr, m) =>
    p = m > 0 ? high : low // check high or low depending on inverse or not 
    if array.size(arr) > 0
        for i  = array.size(arr)-1 to 0
            l  = array.get(arr, i) 
            lp = line.get_price(l, bar_index)
            if p * m > lp * m // check price against line price. multiply by 1 or -1 for inverse operation 
                line.set_x2(l, bar_index)
                array.remove(arr, i)

if bear     // instead of just drawing a line, we push it into an array, a list of lines so we can loop through the list and perform actions on all lines 
    addLine(highs, highestHigh)
    addLine(highs, highestHigh2)
    addLine(highs, highestHigh3)

if bull
    addLine(lows, lowerlow1)
    addLine(lows, lowerlow2)
    addLine(lows, lowerlow3)

// check highs against pivot highs
// check lows against pivot lows 
// set line at current bar if broken 
// remove from arrays 
endLine(highs, 1)
endLine(lows, -1)

// extend lines in both arrays to the right
extend(highs, bar_index + bars)
extend(lows,  bar_index + bars)

** note ** max line count can be adjusted in the indicator() header

Cheers and best of luck with your coding and trading

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文