pine-script

How to draw a vertical line in TradingView pine script?

旧巷老猫 提交于 2019-12-23 19:19:02
问题 I'm trying to use the web based TradingView platform to make my own custom scripts to display various financial market properties. This is possible through its pine scripting engine/interpreter. At the moment I'm trying to simply display a vertical line on either the main chart or on an indicator chart. However, it doesn't seem that their scripting engine is supporting vertical lines, except by using the plot's histogram or column types. Either way, I am not able to get any satisfactory lines

How do I use a strategy that I've backtested to actually trade with? Example code is provided

谁说我不能喝 提交于 2019-12-23 02:29:32
问题 I've found some public strategies and am using them as a guide to develop my understanding of pine script. I will paste the script I am trying to alter. I'm very new to pine script and coding in general, but I understand the general ideas of coding and seem to be picking up pine script's syntax. Code is as follows: //@version=3 strategy("Moving Average and/or Bbands bot V1.1", shorttitle="Strategy", overlay=true, pyramiding=1000) //Make the backtest numbers more legible depending on the

How can I stop an alertcondition once its been activated

一世执手 提交于 2019-12-13 20:21:40
问题 I am triggering two separate alertconditions (when a crossover and crossunder happens) They cross over a few time after this alert and this trigger it multiple times. I'm hoping to set a condition so that once they've done it once it no longer triggers the alertcondition until the other alertcondition is triggered aka alertcondition(long...) is triggered once only even if its conditions happen again but the condition is reinstated after alertcondition(short...) is triggered and vice versa

How TradingView Pine Script RMA function works internally?

杀马特。学长 韩版系。学妹 提交于 2019-12-11 09:50:02
问题 I'm trying to re-implement the rma function from TradingView pinescript but I cannot make it output the same result as the original function. Here is the code I developed, the code is basically the ema function, but it differs greatly from the rma function plot result when charting: //@version=3 study(title = "test", overlay=true) rolling_moving_average(data, length) => alpha = 2 / (length + 1) sum = 0.0 for index = length to 0 if sum == 0.0 sum := data[index] else sum := alpha * data[index]

Problem with Pine Scripts plotshapes offset

前提是你 提交于 2019-12-11 07:51:25
问题 This script will denote highs, with the left bar being lower and the right bar being lower. I also want this script to give me the HighofHighs, with the left high and right high being lower. I have it working but I can't get the label to display on the correct bar. If I use offset=-1, it will put it over the most recent high, if I use offset=-high_bars_back it doesn't offset it at all. (the default of the code is showing "HighofHighs" on the most current high (using offset=-1), but I need it

How to fix TradingView out of depth at index 540 error

落花浮王杯 提交于 2019-12-11 06:37:19
问题 When working on a pine script in TradingView (tradingview.com), I kept seeing red text appear near the top of the chart saying "out of depth at index" 540, and my script would not execute. Being new to pine script, I wasn't really sure what it meant. This issue was rather cryptic and difficult to google, so I'm posting the answer I found here. Hopefully it will be useful to someone. 回答1: I found an answer via this detailed writeup regarding the issue. Since stackoverflow doesn't like link-rot

How can I check in a strategy if the current price is open price?

痞子三分冷 提交于 2019-12-11 04:55:38
问题 I have a strategy. I read that strategy is given open or low or high or close prices of a bar. I wonder if within a strategy. how the program can determine what the current price is and if it is equal to the open bar price. The program need to enter positions only at open bars. 回答1: close is the current/last price of a bar that is being rendered. Then you can compare close with open . However, I would not recommend a strategy that is based on the current price. A lot can change during the

How to use different string literals in PINE plot on trading view?

北城余情 提交于 2019-12-10 20:46:56
问题 I have plot defined like this: plotshape(xvalue, location=location.absolute, style=shape.labeldown, color=red, size=size.tiny, text ="Upper") Problem here is with part text="Upper". I wanted to allow user to shorten label so it can be "Upper" or "U". This usualy can be done with something like this: text = label ? "U" : "Upper" Where "label" is true/false for shorter strings. Problem is PINE isn't accepting it and error is something like "You must use string literals with 'text='". https:/

Tradingview Pine script save close price at time of strategy entry

对着背影说爱祢 提交于 2019-12-10 16:34:45
问题 Hey I'm trying to save the close price at the time of strategy.entry to a variable so I can use it later for an exit. if condition strategy.entry("long", true) buyprice=close (strategy.exit("exit","long", when = close>buyprice*1.1) I get the error: Undeclared identifier 'buyprice' . From what I understand this means that the variable is not valid outside of the if statement. Is there a way to change this? Thanks in advance for your help 回答1: This is the only way that I could get this to work.

I got TradingView's 'end of line without continuation' error with Pine Script

ⅰ亾dé卋堺 提交于 2019-12-07 04:29:21
问题 I am using this code in Pine Script but getting the "mismatched input 'a' expecting 'end of line without line continuation'" error. How to fix that error with this function code? val(s) => if s != s[1] a = s-s[1] if s = s[1] a a 回答1: The 'end of line without continuation' error happens when there's an indentation mistake in the TradingView Pine code. Looking at your code (and assuming copying it into StackOverflow went right), there is indeed an indentation problem: val(s) => if s != s[1] a =