Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-pro· GoogleHugging Face Arena Human Preference 55K

If you are familiar with PineScript 5, please write a script using the 'ta.percentrank'…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Perplexitypplx-70b-online’s answer.
  1. User

    If you are familiar with PineScript 5, please write a script using the 'ta.percentrank' function.

  2. Gemini Assistant
    //@version=5
    indicator("Percent Rank", overlay=true)
    
    src = close
    length = input(14, title="Length")
    
    rank_value = ta.percentrank(src, length)
    
    plot(rank_value, color=color.lime, title="Percent Rank")
    

    This script calculates the percent rank of the closing price over a specified length and plots the result as a line on the chart. The percent rank is a measure of how high or low the current price is relative to the prices over the specified length. It is calculated by dividing the number of prices that are below the current price by the total number of prices in the length.

    The input parameters for this script are:

    • src: The data series to calculate the percent rank for.
    • length: The number of periods to use in the calculation.

    The output of this script is a line plot of the percent rank. The line will range from 0 to 100, with 0 indicating that the current price is the lowest price over the specified length and 100 indicating that the current price is the highest price over the specified length.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.