The resource loading... loading...

FMZ PINE Script documentation is provided.

Author: Inventors quantify - small dreams, Created: 2022-05-06 14:27:06, Updated: 2024-10-12 15:27:04

The column values.

  • length(series int) K number of lines (length).
  • mult(simple int/float) standard deviation

See you later ta.sma ta.stdev ta.kc

ta.bbw

The width of the Brin band. The width of the Brin band is the distance from the upstream and downstream tracks to the midline.

ta.bbw(series, length, mult) 

Examples

plot(ta.bbw(close, 5, 4), color=color.yellow)

// the same on pine
f_bbw(src, length, mult) =>
    float basis = ta.sma(src, length)
    float dev = mult * ta.stdev(src, length)
    ((basis + dev) - (basis - dev)) / basis

plot(f_bbw(close, 5, 4))

Returns the valueThe bandwidth of Brin.

Parameters

  • series(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).
  • mult(simple int/float) standard deviation

See you later ta.bb ta.sma ta.stdev

ta.cci

The CCI (Commodity Path Index) is calculated by dividing the difference between the typical price of a commodity and its simple moving average by the average absolute deviation of the typical price. The index is scaled by a factor of 0.015 to provide more readable figures.

ta.cci(source, length) 

Returns the valueThe commodity channel index of the source returned by the length K line.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

ta.change

The difference between the current value and the previous value, source - source[length]。

ta.change(source, length) 
ta.change(source) 

Returns the valueThe result of the law's reduction.

Parameters

  • source(series int/float) Source series.
  • length(series int) Shifts from the current k-string to the previous k-string. Optional, if not given, use length = 1♦

See you later ta.mom ta.cross

ta.mom

sourcePrices andsourceThe pricelengthThis is just a difference: source - source[length]].

ta.mom(source, length) 

Returns the value sourcePrices andsourceThe pricelengthThe momentum before the K line.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) Shifts from the current k-line to the previous k-line.

See you later ta.change

ta.cmo

Chandler momentum oscillator. Calculate the sum of the number of recent rally points and the number of recent fall points, subtract the two and then divide the result by the sum of all price changes over the same period.

ta.cmo(series, length) 

Examples

plot(ta.cmo(close, 5), color=color.yellow)

// the same on pine
f_cmo(src, length) =>
    float mom = ta.change(src)
    float sm1 = math.sum((mom >= 0) ? mom : 0.0, length)
    float sm2 = math.sum((mom >= 0) ? 0.0 : -mom, length)
    100 * (sm1 - sm2) / (sm1 + sm2)

plot(f_cmo(close, 5))

Returns the valueThe dynamic oscillation indicator in Chad

Parameters

  • series(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

See you later ta.rsi ta.stoch math.sum

ta.percentile_linear_interpolation

Calculate the percentage between the two most recent rankings using the linear insertion method.

ta.percentile_linear_interpolation(source, length, percentage) 

Returns the value lengthThe K line returnssourceThe first P percent of the series.

Parameters

  • source(series int/float) to be executed.
  • length(series int) Number of lines past K (length)
  • percentage(simple int/float) Percentage, a number in the range 0 to 100

NotesPlease note that not all of the input data set members are percentages calculated using this method.

See you later ta.percentile_nearest_rank

ta.percentile_nearest_rank

Percentages are calculated according to the most recent ranking method.

ta.percentile_nearest_rank(source, length, percentage) 

Returns the value lengthThe K line returnssourceThe first P percent of the series.

Parameters

  • source(series int/float) to be executed.
  • length(series int) Number of lines past K (length)
  • percentage(simple int/float) Percentage, a number in the range 0 to 100

NotesUsing a recent ranking method with less than 100 k lines of length in the past can result in the same number being used for multiple percentages. The most recent ranking percentage is an input data set member. The 100th percentile is defined as the maximum value in the input dataset.

See you later ta.percentile_linear_interpolation

ta.percentrank

The percentage rank is the percentage of the previous value less than or equal to the current value of the given series.

ta.percentrank(source, length) 

Returns the value lengthThe K line returnssourcePercentage of rankings.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

ta.variance

A differential is a set of expected values (ta.sma) of square deviation from its mean, which informally measures the distance of a set of numbers from its mean.

ta.variance(source, length, biased) 

Returns the value lengthThe K line returnssourceThe difference between the two.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).
  • biased(series bool) Determines which estimate should be used. Optional. Default is true.

NotesWhat ifbiasedIf true, the function will calculate using biased estimates of the total, if false - biased estimates of the sample.

See you later ta.dev ta.stdev

ta.tr

ta.tr(handle_na) 

Returns the valueThe real range. It is math.max ((high - low, math.abs ((high - close[1]), math.abs ((low - close[1]))).

Parameters

  • handle_na(simple bool) How to handle NaN values. If true, and the closing price of the previous day is NaN, then tr is calculated as the high-low of the day. Otherwise (if false) tr in this case returns NaN.ta.tr(true)。

Notes ta.tr(false)andta.trIt's exactly the same.

See you later ta.atr

ta.mfi

A cash flow indicator is a technical indicator that uses price and volume to determine whether an asset is overbought or oversold.

ta.mfi(series, length) 

Examples

plot(ta.mfi(hlc3, 14), color=color.yellow)

// the same on pine
pine_mfi(src, length) =>
    float upper = math.sum(volume * (ta.change(src) <= 0.0 ? 0.0 : src), length)
    float lower = math.sum(volume * (ta.change(src) >= 0.0 ? 0.0 : src), length)
    mfi = 100.0 - (100.0 / (1.0 + upper / lower))
    mfi

plot(pine_mfi(hlc3, 14))

Returns the valueIndicators of cash flow

Parameters

  • series(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

See you later ta.rsi math.sum

ta.kc

Cantonal channel. Cantonal channel is a technical indicator that contains a moving average in the middle as well as a channel up and down the track.

ta.kc(series, length, mult) 
ta.kc(series, length, mult, useTrueRange) 

Examples

[middle, upper, lower] = ta.kc(close, 5, 4)
plot(middle, color=color.yellow)
plot(upper, color=color.yellow)
plot(lower, color=color.yellow)


// the same on pine
f_kc(src, length, mult, useTrueRange) =>
    float basis = ta.ema(src, length)
    float span = (useTrueRange) ? ta.tr : (high - low)
    float rangeEma = ta.ema(span, length)
    [basis, basis + rangeEma * mult, basis - rangeEma * mult]
    
[pineMiddle, pineUpper, pineLower] = f_kc(close, 5, 4, true)

plot(pineMiddle)
plot(pineUpper)
plot(pineLower)

Returns the valueThe Kenta Pass

Parameters

  • series(series int/float) The series value to be executed.
  • length(simple int) K number of lines (length).
  • mult(simple int/float) standard deviation
  • useTrueRange(simple bool) Optional parameter. Specifies whether to use a true range; default to true. If the value is false, the range is calculated using the expression ((high-low)).

See you later ta.ema ta.atr ta.bb

ta.kcw

Kenta channel width. Kenta channel width is the value of the difference between the upper and lower channels divided by the middle channel.

ta.kcw(series, length, mult) 
ta.kcw(series, length, mult, useTrueRange) 

Examples

plot(ta.kcw(close, 5, 4), color=color.yellow)

// the same on pine
f_kcw(src, length, mult, useTrueRange) =>
    float basis = ta.ema(src, length)
    float span = (useTrueRange) ? ta.tr : (high - low)
    float rangeEma = ta.ema(span, length)
    
    ((basis + rangeEma * mult) - (basis - rangeEma * mult)) / basis

plot(f_kcw(close, 5, 4, true))

Returns the valueThe width of the channel.

Parameters

  • series(series int/float) The series value to be executed.
  • length(simple int) K number of lines (length).
  • mult(simple int/float) standard deviation
  • useTrueRange(simple bool) Optional parameter. Specifies whether to use a true range; default to true. If the value is false, the range is calculated using the expression ((high-low)).

See you later ta.kc ta.ema ta.atr ta.bb

ta.correlation

相关系数。描述两个系列倾向于偏离其ta.sma值的程度。

ta.correlation(source1, source2, length) 

Returns the valueRelated coefficients.

Parameters

  • source1(series int/float) Source series.
  • source2(series int/float) The target series.
  • length(series int) length ((K number of lines)

See you later request.security

ta.cross

ta.cross(source1, source2) 

Returns the valueIf two series cross each other, they are true, otherwise they are false.

Parameters

  • source1(series int/float) The first data series.
  • source2(series int/float) The second data series.

See you later ta.change

ta.crossover

source1-series is defined as the spansource2-series, if on the current line K,source1is greater thansource2So the first line is the value of K, and the first line is the value of K.source2The value of source 1小于The value of source2 ≠.

ta.crossover(source1, source2) 

Returns the valueWhat ifsource1Go throughsource2If you want to change the name of the file, you can change the name of the file to true or false.

Parameters

  • source1(series int/float) The first data series.
  • source2(series int/float) The second data series.

ta.crossunder

source1-series is defined assource2-series below the intersection, if on the current line K,source1is less thansource2So the first line is the value of K, and the first line is the value of K.source1is greater thansource2The value of.

ta.crossunder(source1, source2) 

Returns the valueWhat ifsource1In thesource2The lower cross is true, the lower is false.

Parameters

  • source1(series int/float) The first data series.
  • source2(series int/float) The second data series.

ta.atr

The function ATR (true amplitude mean) returns a real range RMA. The real amplitude is max (high - low, abs (high - close[1]), abs (low - close[1])).

ta.atr(length) 

Examples

plot(ta.atr(14))

//the same on pine
pine_atr(length) =>
    trueRange = na(high[1])? high-low : math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
    //true range can be also calculated with ta.tr(true)
    ta.rma(trueRange, length)

plot(pine_atr(14))

Returns the valueThe mean of the true oscillation magnitude (ATR)

Parameterslength (simple int) length ((K number of lines)

See you later ta.tr ta.rma

ta.sar

Paradoxical reversal (also known as paradoxical stopping and reversal) is a method devised by J. Welles Wilder, Jr. to find potential reversals in the direction of a trading market price.

ta.sar(start, inc, max) 

Examples

plot(ta.sar(0.02, 0.02, 0.2), style=plot.style_cross, linewidth=3)

// The same on Pine
pine_sar(start, inc, max) =>
  var float result = na
  var float maxMin = na
  var float acceleration = na
  var bool isBelow = na
  bool isFirstTrendBar = false
  
  if bar_index == 1
    if close > close[1]
      isBelow := true
      maxMin := high
      result := low[1]
    else
      isBelow := false
      maxMin := low
      result := high[1]
    isFirstTrendBar := true
    acceleration := start
  
  result := result + acceleration * (maxMin - result)
  
  if isBelow
    if result > low
      isFirstTrendBar := true
      isBelow := false
      result := math.max(high, maxMin)
      maxMin := low
      acceleration := start
  else
    if result < high
      isFirstTrendBar := true
      isBelow := true
      result := math.min(low, maxMin)
      maxMin := high
      acceleration := start
      
  if not isFirstTrendBar
    if isBelow
      if high > maxMin
        maxMin := high
        acceleration := math.min(acceleration + inc, max)
    else
      if low < maxMin
        maxMin := low
        acceleration := math.min(acceleration + inc, max)
  
  if isBelow
    result := math.min(result, low[1])
    if bar_index > 1
      result := math.min(result, low[2])
    
  else
    result := math.max(result, high[1])
    if bar_index > 1
      result := math.max(result, high[2])
  
  result
  
plot(pine_sar(0.02, 0.02, 0.2), style=plot.style_cross, linewidth=3)

Returns the valueThe parallelized line turns towards the indicator.

Parameters

  • start(simple int/float) started.
  • inc(simple int/float) increases
  • max(simple int/float) is the largest.

ta.barssince

Calculate the number of k-strings from the last condition true.

ta.barssince(condition) 

Examples

// get number of bars since last color.green bar
plot(ta.barssince(close >= open))

Returns the valueIf the condition is true then the number of k strings is true.

NotesIf the condition is never satisfied before the current line K, the function returns na. Please note that using this variable/function may result in a redrawing of the indicator.

See you later ta.lowestbars ta.highestbars ta.valuewhen ta.highest ta.lowest

ta.cum

sourceThe sum of the sum of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums of the sums.sourceThe sum of all the elements of the equation.

ta.cum(source) 

Returns the valueSum of series.

Parameters

  • source (series int/float)

See you later math.sum

ta.dmi

The dmi function returns the dynamic index DMI.

ta.dmi(diLength, adxSmoothing) 

Examples

len = input.int(17, minval=1, title="DI Length")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
[diplus, diminus, adx] = ta.dmi(len, lensig)
plot(adx, color=color.red, title="ADX")
plot(diplus, color=color.blue, title="+DI")
plot(diminus, color=color.orange, title="-DI")

Returns the valueThe three components of the DMI series are: positive directional motion (+DI), negative directional motion (−DI) and average directional motion (ADX).

Parameters

  • diLength (simple int) DI Period。
  • adxSmoothing(simple int) ADX smooth cycle

See you later ta.rsi ta.tsi ta.mfi

ta.falling

TestingsourceThe serieslengthIs the K-long line going down?

ta.falling(source, length) 

Returns the valueIf the currentsourceValue less thanlengthAny previous k-line returnedsourceThe value is true or false.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

See you later ta.rising

ta.rising

TestingsourceThe serieslengthIs the K-long line going up?

ta.rising(source, length) 

Returns the valueIf the currentsourceThe value is greater thanlengthAny previous k-line returnedsourceThe value is true or false.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

See you later ta.falling

ta.pivothigh

This function returns the price at the pivot height. If no pivot height is available, it returns NaN.

ta.pivothigh(source, leftbars, rightbars) 
ta.pivothigh(leftbars, rightbars) 

Examples

leftBars = input(2)
rightBars=input(2)
ph = ta.pivothigh(leftBars, rightBars)
plot(ph, style=plot.style_cross, linewidth=3, color= color.red, offset=-rightBars)

Returns the valueThe price at this point is either NaN.

Parameters

  • source(series int/float) Optional parameter↑ data sequence computed value↑ default value string High string↑
  • leftbars(series int/float)
  • rightbars(series int/float) Right length.

NotesIf the parameter is leftbars or rightbars, you should use the max_bars_back function as the source bar.

ta.pivotlow

This function returns the price at the pivot lows. If there is no pivot lows, it returns NaN.

ta.pivotlow(source, leftbars, rightbars) 
ta.pivotlow(leftbars, rightbars) 

Examples

leftBars = input(2)
rightBars=input(2)
pl = ta.pivotlow(close, leftBars, rightBars)
plot(pl, style=plot.style_cross, linewidth=3, color= color.blue, offset=-rightBars)

Returns the valueThe price at this point is either NaN.

Parameters

  • source(series int/float) Optional parameter. The data series calculation value.
  • leftbars(series int/float)
  • rightbars(series int/float) Right length.

NotesIf the parameter is leftbars or rightbars, you should use the max_bars_back function as the source bar.

ta.highest

The highest value of a given number of past k lines.

ta.highest(source, length) 
ta.highest(length) 

Returns the valueThe highest value in the series.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

NotesTwo versions of args:sourceIt's a series.lengthis the number of returned k lines. A version of arg:lengthis the number of k lines returned. The algorithm uses high as thesourceThe series.

See you later ta.lowest ta.lowestbars ta.highestbars ta.valuewhen ta.barssince

ta.highestbars

The maximum value deviation of a given number of past k lines.

ta.highestbars(source, length) 
ta.highestbars(length) 

Returns the valueShift to the highest k-line.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

NotesTwo versions of args:sourceIt's a series.lengthis the number of returned k lines. A version of arg:lengthis the number of k lines returned. The algorithm uses high as thesourceThe series.

See you later ta.lowest ta.highest ta.lowestbars ta.barssince ta.valuewhen

ta.stoch

Random indicator. The equation: 100 * (close - lowest ((low, length)) / (highest ((high, length) - lowest ((low, length))).

ta.stoch(source, high, low, length) 

Returns the valueRandomly

Parameters

  • source(series int/float) Source series.
  • high(series int/float)
  • low(series int/float) Low series
  • length(series int) length ((K number of lines)

See you later ta.cog

ta.supertrend

Supertrend indicator. A supertrend indicator is an indicator that follows a trend.

ta.supertrend(factor, atrPeriod)

Examples

//@version=5
indicator("Pine Script™ Supertrend")

[supertrend, direction] = ta.supertrend(3, 10)
plot(direction < 0 ? supertrend : na, "Up direction", color = color.green, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, "Down direction", color = color.red, style=plot.style_linebr)

// The same on Pine Script™
pine_supertrend(factor, atrPeriod) =>
  src = hl2
  atr = ta.atr(atrPeriod)
  upperBand = src + factor * atr
  lowerBand = src - factor * atr
  prevLowerBand = nz(lowerBand[1])
  prevUpperBand = nz(upperBand[1])

  lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
  upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
  int direction = na
  float superTrend = na
  prevSuperTrend = superTrend[1]
  if na(atr[1])
    direction := 1
  else if prevSuperTrend == prevUpperBand
    direction := close > upperBand ? -1 : 1
  else
    direction := close < lowerBand ? 1 : -1
  superTrend := direction == -1 ? lowerBand : upperBand
  [superTrend, direction]

[pineSupertrend, pineDirection] = pine_supertrend(3, 10)
plot(pineDirection < 0 ? pineSupertrend : na, "Up direction", color = color.green, style=plot.style_linebr)
plot(pineDirection > 0 ? pineSupertrend : na, "Down direction", color = color.red, style=plot.style_linebr)

Returns the valueThe components of the two supertrend series are: supertrend lines and trend directions. Possible values are 1 (downward) and -1 (upward).

Parameters

  • factor(series int/float) The number of times ATR will be multiplied.
  • atrPeriod(simple int) The mean real wavelength

See you later ta.macd

ta.lowest

The minimum value of a given number of k lines past.

ta.lowest(source, length) 
ta.lowest(length) 

Returns the valueThe lowest value in the series.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

NotesTwo versions of args:sourceIt's a series.lengthis the number of returned k lines. A version of arg:lengthis the number of k-strings returned.sourceThe series.

See you later ta.highest ta.lowestbars ta.highestbars ta.valuewhen ta.barssince

ta.lowestbars

Minimum value deviation of a given number of k lines past.

ta.lowestbars(source, length) 
ta.lowestbars(length) 

Returns the valueMoving to the lowest k line.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) Returns the number of k strings.

NotesTwo versions of args:sourceIt's a series.lengthis the number of returned k lines. A version of arg:lengthis the number of k-strings returned.sourceThe series.

See you later ta.lowest ta.highest ta.highestbars ta.barssince ta.valuewhen

ta.valuewhen

Returns the value of the n-most recent occurrence of the n-source n-series of n-condition n-strings that are true.

ta.valuewhen(condition, source, occurrence) 

Examples

slow = ta.sma(close, 7)
fast = ta.sma(close, 14)
// Get value of `close` on second most recent cross
plot(ta.valuewhen(ta.cross(slow, fast), close, 1))

Parameters

  • condition(series bool) The conditions to be searched.
  • source(series int/float/bool/color) Returns the value from the line K that satisfies the condition.
  • occurrence(simple int) condition occurs. The number starts at 0 and goes backwards in time, so 0 is the most recently occurring condition , 1 is the second most recently occurring , and so on.

NotesThis function needs to be executed on every K line. It is not recommended to use it in for or while loop structures, as its behavior may be unexpected. Please note that using this function may cause indicators to be redrawn.

See you later ta.lowestbars ta.highestbars ta.barssince ta.highest ta.lowest

ta.vwap

Weighted average price of transactions

ta.vwap(source) 

Returns the valueWeighted average of transactions

Parameters

  • source(series int/float) Source series.

See you later ta.vwap

ta.vwma

vwma function is returnedlengthK-linesourceThis is equivalent to: sma (source * volume, length) / sma (volume, length).

ta.vwma(source, length) 

Examples

plot(ta.vwma(close, 15))

// same on pine, but less efficient
pine_vwma(x, y) =>
    ta.sma(x * volume, y) / ta.sma(volume, y)
plot(pine_vwma(close, 15))

Returns the value lengthThe K line returnssourceThe number of transactions multiplied by the weighted moving average.

Parameters

  • source(series int/float) The series value to be executed.
  • length(series int) K number of lines (length).

See you later ta.sma ta.ema ta.rma ta.wma ta.swma ta.alma

ta.wpr

The Williams %R indicator shows the relationship between the current closing price and the high/low price that has been hovering for some time.

ta.wpr(length) 

Examples

plot(ta.wpr(14), title="%R", color=color.new(#ff6d00, 0))

Returns the value Williams %R。

Parameters

  • length(series int) K number of lines.

See you later ta.mfi ta.cmo

plot

plot

A series of data is plotted on a graph.

plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display) 

Examples

plot(high+low, title='Title', color=color.new(#00ffaa, 70), linewidth=2, style=plot.style_area, offset=15, trackprice=true)

// You may fill the background between any two plots with a fill() function:
p1 = plot(open)
p2 = plot(close)
fill(p1, p2, color=color.new(color.green, 90))

Returns the valueDrawing objects that can be used to fill.

Parameters

  • series(series int/float) The data series to be drawn.
  • title(const string) Drawing title.
  • color(series color) The color of the drawing. You can use constants such as color = red or color = #ff001a and complex expressions such as 'color = close >= open? green : red. Optional parameters.
  • linewidth(input int) Width of drawing line. The default value is 1; not applicable to all styles.
  • style(plot_style) plot type. Possible values are plot.style_line, plot.style_stepline, plot.style_stepline, plot.style_histogram, plot.style_cross, plot.style_area, plot.style_columns, plot.style_circles, plot.style_linebr, plot.style_areabr. The default value is plot.style_line.
  • trackprice(input bool) If true, the horizontal price line will appear at the level of the last indicator value.
  • histbase(input int/float) When drawing a plot in the style of plot.style_histogram, plot.style_columns or plot.style_area, the value of the reference level is used. The default value is 0.0.
  • offset(series int) Moves left or right on a certain number of k lines. Default is 0.
  • join(input bool) If true, the drawing point will be connected to the line, only for plot.style_cross and plot.style_circles styles. The default is false.
  • editable(const bool) If true, the drawing style can be edited in the format dialog box. The default is true.
  • show_last(input int) If set, defines the number of k lines drawn on the graph ((returns past from last k line) ).
  • display(plot_display) Controls the position of the drawing. Possible values are display.none, display.all. The default is display.all.
  • overlay(const bool) A parameter of the FMZ platform extension used to set the current function in the main diagram (set true) or subgraph (set false).strategyOrindicatorThe insideoverlayThe parameters are set.strategyOrindicatorNo settingsoverlayParameters are processed according to the default parameters.

See you later plotshape plotchar bgcolor

plotshape

Drawing visual shapes on a graph.

plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display) 

Examples

data = close >= open
plotshape(data, style=shape.xcross)

Parameters

  • series(series bool) A series of data plotted as a shape. Except for location.absolute, the series is treated as a set of Boolean values for all location values. Necessary parameters.
  • title(const string) Drawing title.
  • style(input string) Drawing type. Possible values are shape.xcross, shape.cross, shape.triangleup, shape.triangledown, shape.flag, shape.circle, shape.arrowup, shape.arrowdown, shape.labelup, shape.labeldown, shape.square, shape.diamond. The default value is shape.xcross.
  • location(input string) shape's location on the graph. Possible values include: location.abovebar, location.belowbar,location.top,location.bottom,location.absolute。 The default is location.abovebar。
  • color(series color) shaped colors. You can use a color constant such as color = red or color = #ff001a and complex expressions such as 'color = close >= open? green : red. Optional parameters.
  • offset(series int) a left or right moving shape over a specified number of k lines. The default value is 0.
  • text(const string) The text is displayed as a shape. You can use multiple lines of text, separated by a string of consonants. Example: consonant one line consonant two lines.
  • textcolor(series color) The color of the text. You can use constants such as textcolor=red or textcolor=#ff001a, as well as complex expressions such as textcolor = close >= open? green : red. Optional parameters.
  • editable(const bool) If true, the plotshape style can be edited in the format dialog box. The default is true.
  • show_last(input int) If set, defines the number of shapes drawn on the graph ((from the last k-line back to the past)).
  • size(const string) Character size on the chart. Possible values are:size.auto, size.tiny, size.small, size.normal, size.large, size.huge。默认值为size.auto
  • display(plot_display) Controls the position of the drawing. Possible values are display.none, display.all. The default is display.all.
  • overlay(const bool) A parameter of the FMZ platform extension used to set the current function in the main diagram (set true) or subgraph (set false).strategyOrindicatorThe insideoverlayThe parameters are set.strategyOrindicatorNo settingsoverlayParameters are processed according to the default parameters.

See you later plot plotchar bgcolor

plotchar

Draw a visual shape on a chart using any given Unicode character.

plotchar(series, title, char, location, color, offset, text, textcolor, editable, size, show_last, display) 

Examples

data = close >= open
plotchar(data, char='❄')

Parameters

  • series(series bool) A series of data plotted as a shape. Except for location.absolute, the series is treated as a set of Boolean values for all location values. Necessary parameters.
  • title(const string) Drawing title.
  • char(input string) Characters used as visual shapes
  • location(input string) shape's location on the graph. Possible values include: location.abovebar, location.belowbar,location.top,location.bottom,location.absolute。 The default is location.abovebar。
  • color(series color) shaped colors. You can use a color constant such as color = red or color = #ff001a and complex expressions such as 'color = close >= open? green : red. Optional parameters.
  • offset(series int) a left or right moving shape over a specified number of k lines. The default value is 0.
  • text(const string) The text is displayed as a shape. You can use multiple lines of text, separated by a string of consonants. Example: consonant one line consonant two lines.
  • textcolor(series color) The color of the text. You can use constants such as textcolor=red or textcolor=#ff001a, as well as complex expressions such as textcolor = close >= open? green : red. Optional parameters.
  • editable(const bool) If true, the plotchar style can be edited in the format dialog box. The default is true.
  • show_last(input int) If set, defines the number of graphs drawn on the graph ((from the last k-line backwards));
  • size(const string) Character size in the chart.size.auto,size.tiny,size.small,size.normal,size.large,size.huge。 默认值为size.auto
  • display(plot_display) Controls the position of the drawing. Possible values are display.none, display.all. The default is display.all.
  • overlay(const bool) A parameter of the FMZ platform extension used to set the current function in the main diagram (set true) or subgraph (set false).strategyOrindicatorThe insideoverlayThe parameters are set.strategyOrindicatorNo settingsoverlayParameters are processed according to the default parameters.

See you later plot plotshape bgcolor

plotcandle

I'm going to draw a chicken on a chart.

plotcandle(open, high, low, close, title, color, wickcolor, editable, show_last, bordercolor, display)

Examples

indicator("plotcandle example", overlay=true)
plotcandle(open, high, low, close, title='Title', color = open < close ? color.green : color.red, wickcolor=color.black)

Parameters

  • open(series int/float) Data open series are used as float open values.
  • high(series int/float) High-series data is used as the high value of the array.
  • low(series int/float) Low-series data is used as the low value of the array.
  • close(series int/float) Closes the series data as a value to close the k-string.
  • title(const string) plotcandle title. Optional parameters.
  • color(series color) The color of the onion. You can use a constant of the onion such as onioncolor = red onion or onioncolor = #ff001a and complex expressions such as onioncolor = close >= open? green : red onion. Optional parameters.
  • wickcolor(series color) The color of the incandescent lamp head.
  • editable(const bool) If true, the plotcandle style can be edited in the format dialog box.
  • show_last(input int) If set, defines the number of vertices drawn on the graph ((from the last k-line back to the past)).
  • bordercolor(series color) The color of the border of the grid.
  • display(plot_display) Controls the position of the drawing. Possible values are display.none, display.all. The default is display.all.
  • overlay(const bool) A parameter of the FMZ platform extension used to set the current function in the main diagram (set true) or subgraph (set false).strategyOrindicatorThe insideoverlayThe parameters are set.strategyOrindicatorNo settingsoverlayParameters are processed according to the default parameters.

NotesIf the slope is NaN, then the K line need not be shown. The maximum value of open, high, low, and receive will be set to high and low, and the minimum value will be set to low and high.

See you later plotbar

plotarrow

Draw up and down arrows on a graph: the up arrow is drawn on each positive indicator, while the down arrow is drawn on each negative. If the indicator returns na, no arrow is drawn. The arrows have different heights, the greater the absolute value of the indicator, the longer the arrow is drawn.

plotarrow(series, title, colorup, colordown, offset, minheight, maxheight, editable, show_last, display)

Examples

codiff = close - open
plotarrow(codiff, colorup=color.new(color.teal,40), colordown=color.new(color.orange, 40), overlay=true)

Parameters

  • series(series int/float) To draw a data series in the form of an arrow.
  • title(const string) Drawing title.
  • colorup(series color) The color of the up arrow. Optional parameters.
  • colordown(series color) The color of the down arrow. Optional parameter.
  • offset(series int) Moves arrows left or right on a specific number of K lines. Default is 0.
  • minheight(input int) The smallest possible arrow height in pixels. The default value is 5.
  • maxheight(input int) Maximum possible arrow height in pixels. Default is 100
  • editable(const bool) If true, the plotarrow style can be edited in the format dialog box. The default is true.
  • show_last(input int) If set, defines the number of arrows drawn on the graph ((from the last k-line backwards));
  • display(plot_display) Controls the position of the drawing. Possible values are display.none, display.all. The default is display.all.
  • overlay(const bool) A parameter of the FMZ platform extension used to set the current function in the main diagram (set true) or subgraph (set false).strategyOrindicatorThe insideoverlayThe parameters are set.strategyOrindicatorNo settingsoverlayParameters are processed according to the default parameters.

See you later plot plotshape plotchar barcolor bgcolor

array

array.pop

The function removes the last element from the array and returns its value.

array.pop(id)

Examples

// array.pop example
a = array.new_float(5,high)
removedEl = array.pop(a)
plot(array.size(a))
plot(removedEl)

Returns the valueThe value of the deleted element.

Parameters

  • id(any array type) Array object.

See you later array.new_float array.set array.push array.remove array.insert array.shift

array.shift

The function removes the first element of the array and returns its value.

array.shift(id)

Examples

// array.shift example
a = array.new_float(5,high)
removedEl = array.shift(a)
plot(array.size(a))
plot(removedEl)

Returns the valueThe value of the deleted element.

Parameters

  • id(any array type) Array object.

See you later array.unshift array.set array.push array.remove array.includes

array.unshift

The function inserts the value at the initial position of the array.

array.unshift(id, value)

Examples

// array.unshift example
a = array.new_float(5, 0)
array.unshift(a, open)
plot(array.get(a, 0))

Parameters

  • id(any array type) Array object.
  • value (series <type of the array's elements>) to be added to the value at the initial position of the array.

See you later array.shift array.set array.insert array.remove array.indexof

array.size

This function returns the number of elements in the array.

array.size(id)

Examples

// array.size example
a = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
// note that changes in slice also modify original array
slice = array.slice(a, 0, 5)
array.push(slice, open)
// size was changed in slice and in original array
plot(array.size(a))
plot(array.size(slice))

Returns the valueThe number of elements in the array.

Parameters

  • id(any array type) Array object.

See you later array.new_float array.sum array.slice array.sort

array.slice

This function creates a partition from an existing array. If an object in the partition changes, the change is applied to the new array and the original array simultaneously.

array.slice(id, index_from, index_to)

Examples

// array.slice example
a = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
// take elements from 0 to 4
// *note that changes in slice also modify original array 
slice = array.slice(a, 0, 5)
plot(array.sum(a) / 10)
plot(array.sum(slice) / 5)

Returns the valueA shallow copy of an array of fragments.

Parameters

  • id(any array type) Array object.
  • index_from(series int) To start extracting from an index starting from zero.
  • index_to(series int) An index starting from zero before the extraction is complete. The function extracts the elements before this index.

See you later array.new_float array.get array.sort

array.abs

Returns an array containing the absolute value of each element in the original array.

array.abs(id)

Parameters

  • id(int[]/float[]) array objects.

See you later array.new_float array.insert array.slice array.reverse order.ascending order.descending

array.binary_search

The function returns the index of the value, which returns -1 if it is not found. The array to be searched must be ordered in ascending order.

array.binary_search(id, val)

Examples

// array.binary_search
a = array.from(5, -2, 0, 9, 1)
array.sort(a) // [-2, 0, 1, 5, 9]
position = array.binary_search(a, 0) // 1
plot(position)

Parameters

  • id(int[]/float[]) array objects.
  • val(series int/float) The value to be searched in the array.

NotesBinary search is used for arrays that have been pre-ordered in ascending order. It first compares the element in the middle of the array with the target value. If the element matches the target value, it returns its position in the array. If the value of the element is greater than the target value, the search continues in the lower half of the array. If the value of the element is less than the target value, the search continues in the upper half of the array.

See you later array.new_float array.insert array.slice array.reverse order.ascending order.descending

array.binary_search_leftmost

If a value is found, the function returns the index of that value. When the value is not found, the function returns the index of the next smallest element, if it is in the array, to the left of the value's location. The array to be searched must be ordered in ascending order.

array.binary_search_leftmost(id, val)

Examples

// array.binary_search_leftmost
a = array.from(5, -2, 0, 9, 1)
array.sort(a) // [-2, 0, 1, 5, 9]
position = array.binary_search_leftmost(a, 3) // 2
plot(position)

Parameters

  • id(int[]/float[]) array objects.
  • val(series int/float) The value to be searched in the array.

NotesBinary search is used for arrays that have been pre-ordered in ascending order. It first compares the element in the middle of the array with the target value. If the element matches the target value, it returns its position in the array. If the value of the element is greater than the target value, the search continues in the lower half of the array. If the value of the element is less than the target value, the search continues in the upper half of the array.

See you later array.new_float array.insert array.slice array.reverse order.ascending order.descending

array.binary_search_rightmost

If the value is found, the function returns the index of the value. If the value is not found, the function returns the index of the element to the right of the value in the array. The array must be ordered in ascending order.

array.binary_search_rightmost(id, val)

Examples

// array.binary_search_rightmost
a = array.from(5, -2, 0, 9, 1)
array.sort(a) // [-2, 0, 1, 5, 9]
position = array.binary_search_rightmost(a, 3) // 3
plot(position)

Parameters

  • id(int[]/float[]) array objects.
  • val(series int/float) The value to be searched in the array.

NotesBinary search works on an array that has been sorted in ascending order. It first compares the element in the middle of the array to the target value. If the element matches the target value, it returns its position in the array. If the element's value is greater than the target value, the search continues in the lower half of the array. If the element's value is less than the target value, the search continues in the upper half of the array.

See you later array.new_float array.insert array.slice array.reverse order.ascending order.descending

array.sort

The function sorts the elements of the array.

array.sort(id, order)

Examples

// array.sort example
a = array.new_float(0,0)
for i = 0 to 5
    array.push(a, high[i])
array.sort(a, order.descending)
if barstate.islast
    runtime.log(str.tostring(a))

Parameters

  • id(int[]/float[]/string[]) array objects are also used.
  • order(sort_order) Sort order: order.ascending (default) or order.descending.

See you later array.new_float array.insert array.slice array.reverse order.ascending order.descending

array.sort_indices

Returns an indexed array that, when used to index the original array, will access its elements in the order in which they were sorted. It does not modify the original array.

array.sort_indices(id, order)

Examples

// array.sort_indices
a = array.from(5, -2, 0, 9, 1)
sortedIndices = array.sort_indices(a) // [1, 2, 4, 0, 3]
indexOfSmallestValue = array.get(sortedIndices, 0) // 1
smallestValue = array.get(a, indexOfSmallestValue) // -2
plot(smallestValue)

Parameters

  • id(int[]/float[]/string[]) array objects are also used.
  • order(sort_order) Sort order: order.ascending or order.descending。 optional。 the default is order.ascending。

See you later array.new_float array.insert array.slice array.reverse order.ascending order.descending

array.clear

The function removes all elements from the array.

array.clear(id)

Examples

// array.clear example
a = array.new_float(5,high)
array.clear(a)
array.push(a, close)
plot(array.get(a,0))
plot(array.size(a))

Parameters

  • id(any array type) Array object.

See you later array.new_float array.insert array.push array.remove array.pop

array.concat

This function is used to merge two arrays. It pushes all elements from the second array to the first array and then returns to the first array.

array.concat(id1, id2)

Examples

// array.concat example
a = array.new_float(0,0)
b = array.new_float(0,0)
for i = 0 to 4
    array.push(a, high[i])
    array.push(b, low[i])
c = array.concat(a,b)
plot(array.size(a))
plot(array.size(b))
plot(array.size(c))

Returns the valueThe first array has a composite element from the second array.

Parameters

  • id1(any array type) The first array object.
  • id2(any array type) The second array object.

See you later array.new_float array.insert array.slice

array.copy

This function creates a copy of an existing array.

array.copy(id)

Examples

// array.copy example
length = 5
a = array.new_float(length, close)
b = array.copy(a)
a := array.new_float(length, open)
plot(array.sum(a) / length)
plot(array.sum(b) / length)

Returns the valueA copy of the array.

Parameters

  • id(any array type) Array object.

See you later array.new_float array.get array.slice array.sort

array.stdev

The function returns the standard deviation of the array element.

array.stdev(id, biased)

Examples

// array.stdev example
a = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
plot(array.stdev(a))

Returns the valueThe standard deviation of array elements.

Parameters

  • id(int[]/float[]) array objects.
  • biased(series bool) Determines which estimate should be used. Optional. Default is true.

NotesWhat ifbiasedIf true, the function will calculate using biased estimates of the total, if false - biased estimates of the sample.

See you later array.new_float array.max array.min array.avg

array.standardize

The function returns an array of standardized elements.

array.standardize(id)

Examples

// array.standardize example
a = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
b = array.standardize(a)
plot(array.min(b))
plot(array.max(b))

Returns the valueArray of standardized elements.

Parameters

  • id(int[]/float[]) array objects.

See you later array.max array.min array.mode array.avg array.variance array.stdev

array.variance

The function returns the square of the element of the array.

array.variance(id, biased)

Examples

// array.variance example
a = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
plot(array.variance(a))

Returns the valueThe square of the element of the array.

Parameters

  • id(int[]/float[]) array objects.
  • biased(series bool) Determines which estimate should be used. Optional. Default is true.

NotesWhat ifbiasedIf true, the function will calculate using biased estimates of the total, if false - biased estimates of the sample.

See you later array.new_float array.stdev array.min array.avg array.covariance

array.covariance

The function returns the covariance of the two arrays.

array.covariance(id1, id2, biased)

Examples

// array.covariance example
a = array.new_float(0)
b = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
    array.push(b, open[i])
plot(array.covariance(a, b))

Returns the valueThe two arrays have a cosine difference.

Parameters

  • id1(int[]/float[]) array objects.
  • id2(int[]/float[]) array objects.
  • biased(series bool) Determines which estimate should be used. Optional. Default is true.

NotesWhat ifbiasedIf true, the function will calculate using biased estimates of the total, if false - biased estimates of the sample.

See you later array.new_float array.max array.stdev array.avg array.variance

array.fill

The function sets the element of the array to a single value. If no index is specified, it sets all the elements. If only the start index is provided (default 0), it sets the element that starts from that index. If two index parameters are used simultaneously, it sets the element from the start index to but not including the end index (default na).

array.fill(id, value, index_from, index_to)

Examples

// array.fill example
a = array.new_float(10)
array.fill(a, close)
plot(array.sum(a))

Parameters

  • id(any array type) Array object.
  • value (series <type of the array's elements>) is used to fill array values.
  • index_from(series int) starts the index as 0⋅.
  • index_to(series int) terminates the index, assuming by default that na. must be greater than the index of the last element to be set.

See you later array.new_float array.set array.slice

array.includes

If the value is found in the array, the function returns true, otherwise false.

array.includes(id, value)

Examples

// array.includes example
a = array.new_float(5,high)
p = close
if array.includes(a, high)
    p := open
plot(p)

Returns the valueIf the value is found in the array, it is true, otherwise it is false.

Parameters

  • id(any array type) Array object.
  • value (series <type of the array's elements>The value to be searched in the array.

See you later array.new_float array.indexof array.shift array.remove array.insert

array.insert

The function changes the contents of the array by adding new elements in the appropriate location.

array.insert(id, index, value)

Examples

// array.insert example
a = array.new_float(5, close)
array.insert(a, 0, open)
plot(array.get(a, 5))

Parameters

  • id(any array type) Array object.
  • index(series int) is the index to which the value is inserted.
  • value (series <type of the array's elements>) to be added to the array.

See you later array.new_float array.set array.push array.remove array.pop array.unshift

array.join

The function creates and returns a new string by connecting all elements of the array, separated by a specified separator string.

array.join(id, separator)

Examples

// array.join example
a = array.new_float(5, 5)
runtime.log(array.join(a, ","))

Parameters

  • id(int[]/float[]/string[]) array objects are also used.
  • separator(series string) A string used to separate each array element.

See you later array.new_float array.set array.insert array.remove array.pop array.unshift

array.lastindexof

This function returns the value in the index of the last time it appeared. If the value cannot be found, it returns −1.

array.lastindexof(id, value)

Examples

// array.lastindexof example
a = array.new_float(5,high)
index = array.lastindexof(a, high)
plot(index)

Returns the valueThe index of the element.

Parameters

  • id(any array type) Array object.
  • value (series <type of the array's elements>The value to be searched in the array.

See you later array.new_float array.set array.push array.remove array.insert

array.max

The function returns the maximum value, or the nth largest value in the given array.

array.max(id, nth)

Examples

// array.max
a = array.from(5, -2, 0, 9, 1)
secondHighest = array.max(a, 2) // 1
plot(secondHighest)

Returns the valueThe largest value in the array, or the nth largest value.

Parameters

  • id(int[]/float[]) array objects.
  • nth(series int) returns the nth largest value, where 0 is the largest. Optional. Default null.

See you later array.new_float array.min array.sum

array.min

The function returns the minimum value, or the nth smallest value in the given sequence.

array.min(id, nth)

Examples

// array.min
a = array.from(5, -2, 0, 9, 1)
secondLowest = array.min(a, 1) // 0
plot(secondLowest)

Returns the valueThe smallest value in the array, or the nth smallest value.

Parameters

  • id(int[]/float[]) array objects.
  • nth(series int) The first n-minimum value to be returned, where 0 is the minimum. Optional. Default null.

See you later array.new_float array.max array.sum

array.median

The function returns the median of the array element.

array.median(id)

Examples

// array.median example
a = array.new_float(0)
for i = 0 to 9
    array.push(a, close[i])
plot(array.median(a))

More

wuhuoyanHow do you do it if you want to have multiple transactions running simultaneously?

Light cloudsPlease tell me, can pine do more transactions? Can it also go through transactions like JS? Thank you.

lisa20231Thank you for providing detailed documentation.

artistryWow! How does this pine script use the okex simulation on the platform?

artistryThis is equivalent to copying the tradingview platform's strategy directly to the inventor platform and using it!

Inventors quantify - small dreamsThe PINE language can only do single-variety strategies, multi-variety strategies are best written in python, javascript, c++.

Inventors quantify - small dreamsOh, yes, OKX is special, their analog environment and the real disk environment have the same address, only the difference is made elsewhere.

Light cloudsI can't use the okx analogue disc.

Inventors quantify - small dreamsThis multi-variety architecture problem cannot be solved, because each exchange has a different interface, and the frequency limitation of the interface is not the same, which causes many problems.

Inventors quantify - small dreamsWell, thank you for the suggestion, please report this request here.

Light cloudsIt feels better to be able to mix with JS and JS can be better adapted to different trading methods.

The trend hunterIn the future, will we consider more varieties?

Inventors quantify - small dreamsI'm not being polite.

Light cloudsGood, thank you very much.

Inventors quantify - small dreamsHello, the PINE language policy is currently only for single varieties.

Inventors quantify - small dreamsThank you for your support. The documentation will continue to be improved.

Inventors quantify - small dreamsYes, I did.

Inventors quantify - small dreamsPINE template library, where parameters can be set to switch exchange base addresses.