简体   繁体   English

从最后一个条件到现在 pine 脚本获取最低价格

[英]Get the Lowest price from last condition till now pine script

I want to find the lowest price from yellow candle till white candle ( 75 candles apart )我想找到从黄色蜡烛到白色蜡烛的最低价格(相隔 75 根蜡烛)

yellow bar = last condition黄色条 = 最后条件

white bar = the condition happened now白条 = 情况现在发生了

I used some codes i don't know which are right or wrong.我使用了一些我不知道是对还是错的代码。 please help请帮忙

// The problem with this code (barssince)is when the white bar happens it zeros the plot 
because the Long_Condition happens in that candle so it zeros the amount i want to use


since = barssince(Long_Condition)
lowest_price = lowest(since)

now with the plots there are some problems:现在的地块有一些问题:

problem 1问题1

plot(since, title = "bars back", color = color.blue)

in the picture attached you can see the blue plot zeros the amount that was counting which at the last candle it gave 74 and then when i want to get 75 it gives the zero.(from yellow bar to white bar it is 75 candles) and which basically the below code will be wrong and it doesn't run the script.在所附图片中,您可以看到蓝色 plot 将计数的数量归零,在最后一根蜡烛上它给出了 74,然后当我想得到 75 时它给出零。(从黄色条到白色条是 75 根蜡烛)和基本上下面的代码将是错误的并且它不会运行脚本。

lowest_price = lowest(since)

Now, if i use this code which I don't know if it is right or wrong but here it is:现在,如果我使用这段代码,我不知道它是对还是错,但它是:

index_white = valuewhen(Long_Condition , bar_index , 0)

index_yellow = valuewhen(Long_Condition , bar_index , 1)

int final_index = index_white - index_yellow 

Lowest_price = lowest(final_index)
plot_1 = plot(final_index , color = color.blue)
plot_2 = plot(Lowest_price)

Now the plot_1 works great but when i add plot_2 to the script, it doesn't run it.现在plot_1工作得很好,但是当我将plot_2添加到脚本时,它不会运行它。

Isn't final_index Integer that Lowest(final_index) doesn't work?是不是final_index Integer Lowest(final_index)不起作用?

please help me.请帮我。 Thanks谢谢

Picture 2 is coded with enabled plot_1 .图片 2 使用启用的plot_1进行编码。

Click to see the Picture #1点击查看图片#1

Click to see the Picture #2点击查看图片#2

You can obtain these values with the use of additional variables to track the low and by using ta.valuewhen() to obtain the values necessary.您可以通过使用附加变量来跟踪低点并使用ta.valuewhen()来获取必要的值来获取这些值。

//@version=5
indicator("lowest between conditions", overlay = true)

long_condition = ta.crossover(ta.ema(close, 13), ta.ema(close, 30))

var float lowest_since_long = na
var int lowest_since_long_index = na

if long_condition
    lowest_since_long := low
    lowest_since_long_index := bar_index
else
    if low < lowest_since_long
        lowest_since_long := low
        lowest_since_long_index := bar_index


prev_long_low = ta.valuewhen(long_condition, lowest_since_long[1], 0)
prev_long_index = ta.valuewhen(long_condition, lowest_since_long_index[1], 0)

l = line.new(x1 = prev_long_index, y1 = prev_long_low, x2 = bar_index, y2 = prev_long_low, color = color.red)
line.delete(l[1])


plotshape(long_condition, color = color.lime, location = location.belowbar, size = size.small, style = shape.triangleup)

Sorry if I'm off topic but maybe you could help me.对不起,如果我跑题了,但也许你可以帮助我。 Do you know of a crypto trading platform that is good for customizing a lot of the token buying/selling conditions?你知道一个适合定制大量代币买卖条件的加密交易平台吗? Thanks谢谢

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM