Help get this topic noticed by sharing it on Twitter, Facebook, or email.
I’m happy
admin (Company Admin) December 13, 2013 16:01

Pine scripting language

We are proud to present the Pine scripting language! TradingView is the first platform of to have this kind of functionality, combined with advanced real-time charting and a super-engaged community of investors discussing ideas. We hope you enjoy using TradingView’s Pine programming language! Try it and let us know your feedback in this thread.

Update (Feb-3 2014): TradingView Pine Script New Features! Read more http://blog.tradingview.com/?p=223
This topic is no longer open for comments or replies.
next » « previous
  • I'd like to plot the difference of two MA's in spirit of MACD, but when one MA is shifted with respect to another.

    Of course, there will be truncated function definition domain.

    How can I do that?
    • view 7 more comments
    • Why don't you make PINE just a library of regular FORTRAN/JAVA-like language, which include loops? This would make happy both people-in-charge and customers.

      We're thinking currently in this direction. We'll either create a JAVA SDK or make Pine powerful enough to handle most cases.
    • awesome. JAVA SDK please. then i'll be able to code in Clojure! ;)
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Trying to plot on the extension, or off the chart, if possible.

    study(title = "extensionplot", overlay =false)
    bc = na(close) ? bc[1] + 1 : n
    plot(bc)

    Technically, this should do it, if it was possible, right?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Also, I'm looking to target only the current, unclosed bar*, and only plotting a point if that bar is not closed. Once the bar closes**, I want that point to be removed.
    Any ideas on how I might be able to do this?
    * by unclosed bar I mean, it is the newest bar on the chart, and nothing is after it.
    ** by closes I mean, a new bar has formed

    I've tried a few things that I've used on other platforms and none seem to work, thanks
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • it would be nice if the user could input string values in the input object to specify period length for 'D', 'W', 'M', 'Y' instead of having to enter numerical values:

    user_period = input(defval = 'W', title = 'Period')

    where user_period is of type String.

    for ex, at the moment, for the following to work

    is_newbar(res, sess) => change(time(res, sess)) != 0

    res needs to be hard coded as 'D' or 'W', etc...

    i have developed an indicator that would be better if the user could just change in the input dialog the period from 'D' to 'W' and so on. right now, you have to go into the code and type in the change. yikes!

    also, it would be great to have the ?: operator overloaded for (bool, string, string) so that we could return string values depending on the results of a conditional test.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • I recently got help with adding a moving average to the ROC indicator with the line,

    plot(sma(roc(close, 10), 10))

    I tried this with the momentum indicator, but it gave me an error message after using a line,

    plot(sma(mom(close, 10), 10).

    Is there a way to write in moving averages for momentum and the choppiness indicator?

    Thanks for any assistance.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Hey there - I'm trying to create a PInescript that pilots a VStop from a higher timeframe than the current one. I looked at this code:

    study(title="High Time Frame MA", overlay=true)
    src = close, len = input(9)
    out = sma(src, len)
    out1 = security(tickerid, 'D', out)
    plot(out1)

    But vstop doesn't seem to be a standalone function - rather a Pinescript itself. Could you post the code for the Pinescript or is there another way to do this?

    Thanks!
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • How do I make a comment in Pine??
    Every computer language on the planet has this feature. Pine should too.

    Or perhaps a better question:

    Where is a formal description of the Pine scripting language?

    Thanks, David
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • For comments use
    // this is a comment
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Is there a way to add a text comment to the Study other than a study() title parameter?

    Or is perhaps a better question:

    Is there some debug facility?
    Is there a way to do "print line" (i.e. print or printf or println or puts ) ??

    How do I write "Hello World" ?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • guys, i am having a cosmetic/presentation issue. one of the indicators i am working on needs to display some graphical elements n amounts of points away from the low or high BUT this (vertical) offset amount is different depending on how many decimals the price has.

    so depending on the instrument, we might have 0 (ie GER30), 1 (ie SPX500), 3 (ie EURJPY), or 5 (ie AUDUSD) decimals.

    there seems to be no way to determine how many decimals the price of the currently displayed instrument has. there is now way to create a symbol table as a hash table for quick look-up (or associative array or map). there is no way to write 'if == '. and there is now way to write:

    var decimals = current_price.number_of_decimals();

    switch decimals {
    case 0: {
    offset = 5;
    }
    case 1: {
    offset = ....;
    }
    case 2: {
    offset = ...;
    }
    case 3: {
    offset = 0.05;
    }
    case 4: {
    ...
    }
    case 5: {
    ...
    }
    default: {
    ...
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • also, i just realized the scaling factor changes even between 2 instruments quoted with 2 decimals. for ex, it's different between XAUUSD and DXY. so even though i use some computation to keep the vertical offset proportionally away from the high/low, it is too far when displaying XAUUSD and just right when displaying DXY.

    that is to say, for ex, that high + 15 appears to be a greater distance on XAUUSD than on DXY chart!

    how about exposing a function to return the current chart's scaling factor so that we can use that in our own computation to plot the graphical elements such as dots/circles always at the same (perceived) distance from the candle bars?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

  • re the issue of vertical offset, here is a temporary fix:

    high + 0.5 * (high - low)
    low - 0.5 * (high - low)
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • I'd like to plot a Coppock curve. How would I do that?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • guys,

    take a look at this code:

    study(title = "Yearly High/Low", overlay = true)

    is_newbar(res, sess) => change(time(res, sess)) != 0
    adopt(r, s) => security(tickerid, r, s)

    low_range = valuewhen(is_newbar('12M','0000-0000'), low, 0)
    high_range = valuewhen(is_newbar('12M','0000-0000'), high, 0)

    down = plot(adopt('12M', low_range), color = green)
    up = plot(adopt('12M', high_range), color = red)

    fill(down, up, color = red, transp=97)

    then take a look at the high for year 2006. seems to work usually except for 2006. what's going on here?
    • view 5 more comments
    • admin (Company Admin) February 13, 2014 11:22
      This is a great conversation that's separate from the main topic, so I created a new topic to continue the discussion. Please reference the new topic here: Pine Script Heiken-Ashi problem
    • This comment was removed on 2014-02-13.
      see the change log
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • 1 more issue: i get this error:

    Error: Cannot call `falling` with arguments (series, series); available overloads: falling(series, integer) => series;

    when writing this:

    _cross = cross(_sma10, _sma21)
    _barssince = barssince(_cross)
    _isfalling = falling(_cross, _barssince) ? true : false

    the lookback argument 'arg1' into falling(arg0, arg1) is of type 'int'. but the function 'barssince()' only returns the # of bars as a series.

    how can we extract an int from a series?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • guys, here is an inconsistency issue re the use of the ?: operator:

    for ex,

    ( series conditional_test series ) ? bool : bool --> error

    BUT

    ( series conditional_test series ) ? 1 : 0 --> OK

    if '1' and '0' are ok, then so should 'true' and 'false'.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • something weird is happening: this line

    sb1_signal_color = sflag1 ? yellow : na

    causes the price chart to disappear (the indicator panes are fine, the candles are gone)

    BUT this line:

    sb1_signal_color = sflag1 == true ? yellow : na

    behaves properly and the plot color is indeed yellow! it's driving me nuts.

    so i did one more test:

    sflag1 = true (or sflag1 = 1)
    sb1_signal_color = sflag1 ? yellow : na

    causes no problem.

    BUT

    sflag1 = (sflag0 and (barssince(_cross(ema, sma) < 0) < 0) ? 1 : 0
    sb1_signal_color = sflag1 == true ? yellow : na

    also causes NO PROBLEM! obviously, the complex conditional returns 1, so sflag1 == 1 implies sflag1 == true BUT then why doesn't it work when sflag1 ? yellow : na ???

    actually, i just tried something else:

    sflag1 = 1
    sb1_signal_color = sflag1 == true ? yellow : na

    and execution goes to the 'else' branch (na)!

    so 1 != true .

    i had enough for one day. going to sleep.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned

  • admin (Company Admin) February 13, 2014 11:33
    We close this topic because it's too long and it is difficult to navigate here. Please write all your new suggestions and problems in a separate topics
    https://getsatisfaction.com/tradingvi...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned happy, confident, thankful, excited

next » « previous