pine-script

How to conditionally delete line in Pine Script

岁酱吖の 提交于 2020-05-13 07:33:43
问题 I am attempting to create a TradingView study that draws a line from a crossunder on the current bar to a crossunder on a previous bar, where the previous bar is less than a set maximum number of bars back. I only want to draw lines with negative slopes (i.e. the previous crossunder happens at a higher value), and I also don't want multiple lines with the same starting point (no overlapping lines). I am able to draw the lines correctly, but I don't know how to delete lines when they overlap

How to draw a vertical line at a certain time in pinescript on Tradingview?

会有一股神秘感。 提交于 2020-04-12 06:24:09
问题 I would like to draw a vertical line, every day at a certain local time (e.g. 08:00 GMT+1). Since my last post about vertical lines, pine-script has been updated to include vline(), however, the issue here is getting the time right. Most servers (for FX) seem to be US based and the Trading view local time settings (shown on bottom left) seem totally independent of what is done in pine-script. //@version=4 study("Time Adjusted Vertical Line", overlay=true) vline(BarIndex, Color, LineStyle,

Cannot use a mutable variable as an argument of the security function?

こ雲淡風輕ζ 提交于 2020-02-07 03:08:26
问题 I have experiencing problem to include a mutable variable as an argument for security function. I tried wrapping the code with a mutable variable in a function, like this article suggested. But it doesn't seem to work for me on v4. The security function is required because my strategy runs on 4 different timeframes. The following code is a simplified version to show where the issue occurs. Any advices? https://www.tradingview.com/wiki/Pine_Version_3_Migration_Guide#Resolving_a_problem_with_a

Update stop loss based on last entry price

纵饮孤独 提交于 2020-01-24 19:34:06
问题 I want to set stop loss order based on price changing for each new entry order. The problem is that stop loss is executed only for the first order. I wrote the code this way: //@version=4 strategy("Mutual funds RSI Index", "MF_RSI_IDX", default_qty_type=strategy.percent_of_equity, default_qty_value=10, initial_capital=1000, calc_on_order_fills=true, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.29, process_orders_on_close=true) if (rsi(close, 14) < 30)

Risk Management: If already long then do not place new order

风格不统一 提交于 2020-01-05 08:23:18
问题 If the flag is already indicating long, there should not be a new flag indicating long. If flag does not indicate long evaluate the expression longCondition = if (strategy.long) ? false: (rsi<30) and (close>moving_avg) shortCondition = if (strategy.short) ? false: (rsi>70) and (close<moving_avg) Processing script... line 30: mismatched input 'shortCondition' expecting 'end of line without line continuation' 回答1: I assume this is an indicator and not a strategy. Because you can configure how

How to break this limit?

五迷三道 提交于 2019-12-24 19:22:07
问题 This is a limt when using label.new. So has some way for break this limit? I just achieve the follow goal. The following code can achieve goals but has limits. label.new(bar_index, high, '1', textcolor=color.red, style=label.style_none) label.new(bar_index, high, '2\n', textcolor=color.green, style=label.style_none) label.new(bar_index, high, '3\n\n', textcolor=color.blue, style=label.style_none) 来源: https://stackoverflow.com/questions/59222261/how-to-break-this-limit

After alert condition when condition changes from true/false. Currently alerts if either condition is true. Not when it changes

天大地大妈咪最大 提交于 2019-12-24 10:50:03
问题 This is part of a pine script for tradingview. On the script after '//Condition', I want an alert to generate only when the condition changes from long to short or short to long. Not the end of each candle as it does now, as one condition is always true. This has been changed to a study. threshold = input(title="Threshold", type=float, defval=0.0014, step=0.0001) buying = l3_0 > threshold ? true : l3_0 < -threshold ? false : buying[1] ///// T edit selling = l3_0 > -threshold ? true : l3_0 <

Pinescript initialisation

雨燕双飞 提交于 2019-12-24 08:23:13
问题 I am trying to understand the following pinescript indicator code - https://www.tradingview.com/script/XzcIRUHv-JMA-RSX-Clone-LazyBear/ I am not sure what values variables like f90, f88 hold. Are they predefined short-cuts for something else? They seem to be arrays because they are used with index. E.g.: f90_ = (nz(f90_[1]) == 0.0) ? 1.0 : (nz(f88[1]) <= nz(f90_[1])) ? nz(f88[1])+1 : nz(f90_[1])+1 回答1: They are not built-in variables. pine-script versions 1 and 2 allow you to access variables

How to plot a dashed line on pine script V4?

老子叫甜甜 提交于 2019-12-24 06:44:15
问题 Trying to plot a normal serie line but with the V4 of pine script I can't find how to set the style? This gives me an error : plot(my_serie, color=color.blue,linewidth=2, style=line.style_dashed) Any help appreciated. 回答1: There is no dashed style for plot() . This turns the color on and off to achieve the effect: plot(my_serie, color=bar_index % 2 == 0 ? color.blue : #00000000, linewidth=2) 来源: https://stackoverflow.com/questions/58854071/how-to-plot-a-dashed-line-on-pine-script-v4

How to plot a dashed line on pine script V4?

半世苍凉 提交于 2019-12-24 06:44:00
问题 Trying to plot a normal serie line but with the V4 of pine script I can't find how to set the style? This gives me an error : plot(my_serie, color=color.blue,linewidth=2, style=line.style_dashed) Any help appreciated. 回答1: There is no dashed style for plot() . This turns the color on and off to achieve the effect: plot(my_serie, color=bar_index % 2 == 0 ? color.blue : #00000000, linewidth=2) 来源: https://stackoverflow.com/questions/58854071/how-to-plot-a-dashed-line-on-pine-script-v4