pine-script

Is it possible to draw a line into the future?

∥☆過路亽.° 提交于 2021-01-28 17:50:58
问题 For intraday timeframes. Is it possible to draw a horizontal line on the first bar of the session, that has a length until the end of that session? So, essentially drawing a line into the 'future'. Something like this: 回答1: It seems to be possible. Code below is based on the answer of PineCoders-LucF to one of my previous questions line.new draws 2 lines instead of 1 //@version=4 study("FutureLine", overlay=true) start = timestamp(2020,03,13,10,30,0) stop = timestamp(2020,03,16,16,00,0) level

Trying to write a code which gives the strategy a buffer time before it takes the next trades

﹥>﹥吖頭↗ 提交于 2021-01-28 07:09:36
问题 What I'm trying to achieve is a "gap" of a few candles, say 4 in this case before the next trade happens Here nexT is the number of bars, before which the next trade should not take place But the value of nextT always resets to 0, everytime the code runs. What can be a possible modification to the code that the value of nexT does not reset automatically. //@version=4 strategy("RSI Strategy", overlay=true) //timeframe //timframe FromMonth = input(defval = 9, title = "From Month", minval = 1)

how to check if pair exist in security function?

走远了吗. 提交于 2021-01-28 06:03:30
问题 I have a script which checks multiple pairs for a certain condition. But, now one pair (BINANCE:BTGETH) no longer exists, and it broke my script: you get an error, no value anymore. I would like to check inside my script if pairs do exist, so my script will keep on running despite one of the pairs no longer being available. Like, in java, try-catch or something. I've tried doing if-then on the security/input function, or using na() on it, but that does not work. E.g. stuff like: ab = na

Reference series by time - What was the value X days ago?

陌路散爱 提交于 2021-01-28 05:47:40
问题 To reference a value stored in a series with Tradingview's PineScript you use an subscript integer to call a value from a series. //What's the UNIX time of the previous bar? time[1] //What's the UNIX time of the 21st bar (counting from current time) time[20] My goal is to map an input of number of calendar days to a subscript integer to call the value of a series, such that it returns the value of that series, x days ago Pseudo code: SeriesIndexedByDays([series],[day,integer],[period]):

n/a value when line.new with if statement in Pine Script TradingView

ぐ巨炮叔叔 提交于 2021-01-24 11:44:37
问题 I wanted to create an indicator that shows when a close crossed over a trend line. Here's the code, here "trendLineCrossover" should show 1.00 on crossover bar and 0.00 on other bars. But actually this shows me 0.00 only on the last bar (and the consecutive area) and on other bars it shows n/a . lineObj = if (syminfo.tickerid == "BINANCE:SRMUSDT") if (barstate.islast) line.new(x1=3380-89, y1=0.9609, x2=3380 , y2=1.0216) line.set_extend(id=lineObj, extend=extend.right) trendLine = line.get

How to start a strategy at a specific time?

女生的网名这么多〃 提交于 2021-01-07 06:34:56
问题 I am trying out my first hello world pine script, with a very basic strategy test: Open order on market close, close order on market open. My current attempt: //@version=4 strategy(title = "Hour Purchasing", shorttitle = "HP",calc_on_every_tick=true, overlay = true, initial_capital = 20000, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, commission_value = 0.025) triggerLong = true triggerStopLong = true initialHour = 16 x = if (minute == 00 and hour == initialHour)

How to store data (pivots) from previous trading day, and draw them as levels on current today trading session?

≯℡__Kan透↙ 提交于 2021-01-07 06:34:30
问题 Trying to find some way to store pivots data of the previous day trading, and put them inside an array to carry those points to the current day trading for drawing them as line levels. For example, $AAPL stock. On Tuesday (yesterday), recorded pivots points at these levels [100.2, 100.3, 100.5] at 15-min timeframe. On Wednesday (today), I'm looking to draw Support/Resistance lines based on selected pivots [100.2, 100.3, 100.5] from the previous day of trading. I've already done it in python,

How to store data (pivots) from previous trading day, and draw them as levels on current today trading session?

岁酱吖の 提交于 2021-01-07 06:32:09
问题 Trying to find some way to store pivots data of the previous day trading, and put them inside an array to carry those points to the current day trading for drawing them as line levels. For example, $AAPL stock. On Tuesday (yesterday), recorded pivots points at these levels [100.2, 100.3, 100.5] at 15-min timeframe. On Wednesday (today), I'm looking to draw Support/Resistance lines based on selected pivots [100.2, 100.3, 100.5] from the previous day of trading. I've already done it in python,

History referencing in Pine Script arrays

送分小仙女□ 提交于 2020-12-15 06:22:26
问题 I have been trying to use array feature, which recently has been introduced in PineScript 4, but it seams that either I'm not aware of its limitations, or , possibly the implementation is still buggy. The problem I'm faced with is illustrated by the following very simple script: //@version=4 study("TEST") // A is basically the same as bar_index+1, and it is plotted as expected A=0 A:=nz(A[1])+1 // the same thing implemented using arrays nevertheless doesn't work as expected B=array.new_float

Label Horizontal EMA Lines (Variables)

笑着哭i 提交于 2020-12-15 05:31:47
问题 This is the Code I use atm. (Thanks to Bjorn Mistiaen) len1 = input(10, minval=1, title="Length") len2 = input(21, minval=1, title="Length") len3 = input(55, minval=1, title="Length") len4 = input(100, minval=1, title="Length") len5 = input(200, minval=1, title="Length") src = input(close, title="Source") var bool show_hlines = input(true, "Show horizontal lines", input.bool) var bool show_emas = not show_hlines var color_entryema = color.green var color_fastema = color.orange var color