pine-script

Plotting manual levels for daily high,low,close

天大地大妈咪最大 提交于 2020-07-20 03:54:07
问题 As I've already asked a couple of questions here in an attempt to solve my problem, this new question ties them all together and provides some context. Previous questions related to this: Is it possible to draw a line into the future? Edit series only on certain dates Set 2 series at once var does NOT keep it's value across bars function returning 2 values to global variable I have a program (outside of TradingView) that tries to estimate the high/low/close levels of the ticker SPX for the

Getting a constant value from a series

风流意气都作罢 提交于 2020-07-10 10:28:17
问题 I want to assign a constant value to a variable. This value comes from a series. The value is 10 bars back, and must stay constant unless there is a new bar. I tried this code and lots of variations on it, but it didn't work. //@version=4 study(title = "X", overlay = false) var x = 0.0 x := valuewhen(barstate.islast, sum(cht_acum[10], 10), 1) plot(x, title = "X") I don't get a straight line, or I get NA. How to resolve the issue? 回答1: Version 1 Hard to figure out what you want. This may come

Inquiries on how to label bar when MFI or RSI hline is breakthrough

南笙酒味 提交于 2020-06-29 03:47:13
问题 If MFI or RSI exceeds hline(80) or hline(20), I want to label the bar. Is there anyone who can tell me the script? Thank you ^^ 回答1: An example //@version=4 study("My Script",overlay=true) length = input(14),src = input(close) //---- mfi = mfi(src,length) rsi = rsi(src,length) cnd = crossover(mfi,80) or crossover(rsi,80) or crossover(mfi,20) or crossover(rsi,20) plotshape(cnd ? close : na,location=location.belowbar,text="Text") You could also use label.new within an if statement but plotshape

What is the equivalent of console.log in pine-script?

情到浓时终转凉″ 提交于 2020-06-24 11:15:27
问题 How does one console.log variables , or the results of functions in pine-script ? I'd like to convert a pine-script script into javascript , and I'd like to verify that the script I'm converting is the same as the original. Any work arounds are welcome if this functionality does not exist. Thanks! 回答1: There is no way to print text or variables in pine-script to any form of "console". But you can use plot to print, very short text above or below each tick. The text, however, is static and you

Timezone convertion between tickers

浪尽此生 提交于 2020-06-23 14:23:11
问题 I'm attempting to color the background on ticker ES1! for those bars that fall within the trading session of ticker SPX . We can use the time(resolution, session) function to find out if a bar is in a specified session. t1 = time(timeframe.period, "0930-1600") bgcolor(t1 ? color.yellow : na) This works when it's used on ticker SPX . You can see that all bars have a yellow background, as expected. Why? Because SPX trades between 09:30 and 16:00 in the timezone of the SPX ticker, which is