资源加载中... loading...

FMZ PINE Script Doc

Author: 发明者量化-小小梦, Created: 2022-04-28 16:05:05, Updated: 2024-10-12 17:25:27

plot(timestamp(“04 Dec 1995 00:12:00 GMT+5”))


**Returns**
Unix time.

**Arguments**
- ```timezone``` (series string) Timezone. Optional. The default is syminfo.timezone. Can be specified in GMT notation (e.g. "GMT-5") or as an IANA time zone database name (e.g. "America/New_York").
- ```year``` (series int) Year.
- ```month``` (series int) Month.
- ```day``` (series int) Day.
- ```hour``` (series int) (Optional argument) Hour. Default is 0.
- ```minute``` (series int) (Optional argument) Minute. Default is 0.
- ```second``` (series int) (Optional argument) Second. Default is 0.
- ```dateString``` (const string) A string containing the date and, optionally, the time and time zone. Its format must comply with either the IETF RFC 2822 or ISO 8601 standards ("DD MMM YYYY hh:mm:ss ±hhmm" or "YYYY-MM-DDThh:mm:ss±hh:mm", so "20 Feb 2020" or "2020-02-20"). If no time is supplied, "00:00" is used. If no time zone is supplied, GMT+0 will be used. Note that this diverges from the usual behavior of the function where it returns time in the exchange's timezone.

**Remarks**
UNIX time is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.

**See also**
```time``` ```timenow``` ```syminfo.timezone```

### fill

Fills background between two plots or hlines with a given color.

fill(hline1, hline2, color, title, editable, fillgaps, display)


fill(plot1, plot2, color, title, editable, show_last, fillgaps, display)


**Example**
```pine
h1 = hline(20)
h2 = hline(10)
fill(h1, h2, color=color.new(color.blue, 90))

p1 = plot(open)
p2 = plot(close)
fill(p1, p2, color=color.new(color.green, 90))

Arguments

  • hline1 (hline) The first hline object. Required argument.
  • hline2 (hline) The second hline object. Required argument.
  • plot1 (plot) The first plot object. Required argument.
  • plot2 (plot) The second plot object. Required argument.
  • color (series color) Color of the plot. You can use constants like ‘color=color.red’ or ‘color=#ff001a’ as well as complex expressions like ‘color = close >= open ? color.green : color.red’. Optional argument.
  • title (const string) Title of the created fill object. Optional argument.
  • editable (const bool) If true then fill style will be editable in Format dialog. Default is true.
  • show_last (input int) If set, defines the number of bars (from the last bar back to the past) to fill on chart.
  • fillgaps (const bool) Controls continuing fills on gaps, i.e., when one of the plot() calls returns an na value. When true, the last fill will continue on gaps. The default is false.
  • display (plot_display) Controls where the fill is displayed. Possible values are: display.none, display.all. Default is display.all.

See also plot barcolor bgcolor hline

hline

Renders a horizontal line at a given fixed price level.

hline(price, title, color, linestyle, linewidth, editable, display)

Example

// input.hline
hline(3.14, title='Pi', color=color.blue, linestyle=hline.style_dotted, linewidth=2)

// You may fill the background between any two hlines with a fill() function:
h1 = hline(20)
h2 = hline(10)
fill(h1, h2, color=color.new(color.green, 90))

Returns An hline object, that can be used in fill.

Arguments

  • price (input int/float) Price value at which the object will be rendered. Required argument.
  • title (const string) Title of the object.
  • color (input color) Color of the rendered line. Must be a constant value (not an expression). Optional argument.
  • linestyle (hline_style) Style of the rendered line. Possible values are: solid, dotted, dotted. Optional argument.
  • linewidth (input int) Width of the rendered line. Default value is 1.
  • editable (const bool) If true then hline style will be editable in Format dialog. Default is true.
  • display (plot_display) Controls where the hline is displayed. Possible values are: display.none, display.all. Default is display.all.
  • overlay (const bool) is the extension argument of FMZ platform, it is used to set the current function to be displayed on the main image (set to true) or sub-image (set to false), the default value is false. If this argument is not specified, it will be set according to the overlay argument in strategy or indicator, if strategy or indicator does not set the overlay argument, it will be processed according to the default arguments.

bgcolor

Fill background of bars with specified color.

bgcolor(color, offset, editable, show_last, title, display, overlay)

Example

// bgcolor example
bgcolor(close < open ? color.new(color.red,70) : color.new(color.green, 70))

Arguments

  • color (series color) Color of the filled background. You can use constants like “red” or “#ff001a” as well as complex expressions like ‘close >= open ? color.green : color.red’. Required argument.
  • offset (series int) Shifts the color series to the left or to the right on the given number of bars. Default is 0.
  • editable (const bool) If true then bgcolor style will be editable in Format dialog. Default is true.
  • show_last (input int) If set, defines the number of bars (from the last bar back to the past) to fill on chart.
  • title (const string) Title of the bgcolor. Optional argument.
  • display (plot_display) Controls where the bgcolor is displayed. Possible values are: display.none, display.all. Default is display.all.
  • overlay (const bool) is the extension argument of FMZ platform, it is used to set the current function to be displayed on the main image (set to true) or sub-image (set to false), the default value is false. If this argument is not specified, it will be set according to the overlay argument in strategy or indicator, if strategy or indicator does not set the overlay argument, it will be processed according to the default arguments.

See also plot

barcolor

Set color of bars.

barcolor(color, offset, editable, show_last, title, display)

Example

barcolor(close < open ? color.black : color.white)

Arguments

  • color (series color) Color of bars. You can use constants like ‘red’ or ‘#ff001a’ as well as complex expressions like ‘close >= open ? color.green : color.red’. Required argument.
  • offset (series int) Shifts the color series to the left or to the right on the given number of bars. Default is 0.
  • editable (const bool) If true then barcolor style will be editable in Format dialog. Default is true.
  • show_last (input int) If set, defines the number of bars (from the last bar back to the past) to fill on chart.
  • display (plot_display) Controls where the barcolor is displayed. Possible values are: display.none, display.all. Default is display.all.

See also bgcolor plot fill

error

Compatible with error of PINE v4, and the function is the same as runtime.error.

Built-in variables

order

order.ascending

Determines the sort order of the array from the smallest to the largest value.

Type sort_order

See also array.new_float array.sort

order.descending

Determines the sort order of the array from the largest to the smallest value.

Type sort_order

See also array.new_float array.sort

timeframe

timeframe.isdaily

Returns true if current resolution is a daily resolution, false otherwise.

Type simple bool

See also timeframe.isdwm timeframe.isintraday timeframe.isminutes timeframe.isseconds timeframe.isweekly timeframe.ismonthly

timeframe.isdwm

Returns true if current resolution is a daily or weekly or monthly resolution, false otherwise.

Type simple bool

See also timeframe.isintraday timeframe.isminutes timeframe.isseconds timeframe.isdaily timeframe.isweekly timeframe.ismonthly

timeframe.isintraday

Returns true if current resolution is an intraday (minutes or seconds) resolution, false otherwise.

Type simple bool

See also timeframe.isminutes timeframe.isseconds timeframe.isdwm timeframe.isdaily timeframe.isweekly timeframe.ismonthly

timeframe.isminutes

Returns true if current resolution is a minutes resolution, false otherwise.

Type simple bool

See also timeframe.isdwm timeframe.isintraday timeframe.isseconds timeframe.isdaily timeframe.isweekly timeframe.ismonthly

timeframe.ismonthly

Returns true if current resolution is a monthly resolution, false otherwise.

Type simple bool

See also timeframe.isdwm timeframe.isintraday timeframe.isminutes timeframe.isseconds timeframe.isdaily timeframe.isweekly

timeframe.isseconds

Returns true if current resolution is a seconds resolution, false otherwise.

Type simple bool

See also timeframe.isdwm timeframe.isintraday timeframe.isminutes timeframe.isdaily timeframe.isweekly timeframe.ismonthly

timeframe.isweekly

Returns true if current resolution is a weekly resolution, false otherwise.

Type simple bool

See also timeframe.isdwm timeframe.isintraday timeframe.isminutes timeframe.isseconds timeframe.isdaily timeframe.ismonthly

timeframe.multiplier

Multiplier of resolution, e.g. ‘60’ - 60, ‘D’ - 1, ‘5D’ - 5, ‘12M’ - 12.

Type simple int

See also syminfo.ticker syminfo.tickerid timeframe.period

timeframe.period

Resolution, e.g. ‘60’ - 60 minutes, ‘D’ - daily, ‘W’ - weekly, ‘M’ - monthly, ‘5D’ - 5 days, ‘12M’ - one year, ‘3M’ - one quarter.

Type simple string

See also syminfo.ticker syminfo.tickerid timeframe.multiplier

display

display.none

A named constant that specifies where the plot is displayed. Display nowhere. Available in alert template message.

Type plot_display

See also plot plotshape plotchar

display.all

A named constant that specifies where the plot is displayed. Display everywhere.

Type plot_display

See also plot plotshape plotchar plotarrow plotbar plotcandle

shape

shape.xcross

Shape style for plotshape function.

Type const string

See also plotshape

shape.cross

Shape style for plotshape function.

Type const string

See also plotshape

shape.triangleup

Shape style for plotshape function.

Type const string

See also plotshape

shape.triangledown

Shape style for plotshape function.

Type const string

See also plotshape

shape.flag

Shape style for plotshape function.

Type const string

See also plotshape

shape.circle

Shape style for plotshape function.

Type const string

See also plotshape

shape.arrowup

Shape style for plotshape function.

Type const string

See also plotshape

shape.arrowdown

Shape style for plotshape function.

Type const string

See also plotshape

shape.labelup

Shape style for plotshape function.

Type const string

See also plotshape

shape.labeldown

Shape style for plotshape function.

Type const string

See also plotshape

shape.square

Shape style for plotshape function.

Type const string

See also plotshape

shape.diamond

Shape style for plotshape function.

Type const string

See also plotshape

color

color.aqua

Is a named constant for #00BCD4 color.

Type const color

color.black

Is a named constant for #363A45 color.

Type const color

color.blue

Is a named constant for #2962ff color.

Type const color

color.fuchsia

Is a named constant for #E040FB color.

Type const color

color.gray

Is a named constant for #787B86 color.

Type const color

color.green

Is a named constant for #4CAF50 color.

Type const color

color.lime

Is a named constant for #00E676 color.

Type const color

color.maroon

Is a named constant for #880E4F color.

Type const color

color.navy

Is a named constant for #311B92 color.

Type const color

color.olive

Is a named constant for #808000 color.

Type const color

color.orange

Is a named constant for #FF9800 color.

Type const color

color.purple

Is a named constant for #9C27B0 color.

Type const color

color.red

Is a named constant for #FF5252 color.

Type const color

color.silver

Is a named constant for #B2B5BE color.

Type const color

color.teal

color.teal

Is a named constant for #00897B color.

Type const color

color.white

Is a named constant for #FFFFFF color.

Type const color

color.yellow

Is a named constant for #FFEB3B color.

Type const color

plot

plot.style_line

A named constant for the ‘Line’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_cross plot.style_area plot.style_areabr plot.style_columns plot.style_circles

plot.style_linebr

A named constant for the ‘Line With Breaks’ style, to be used as an argument for the style parameter in the plot function. Similar to plot.style_line, except the gaps in the data are not filled.

Type plot_style

See also plot plot.style_line plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_cross plot.style_area plot.style_areabr plot.style_columns plot.style_circles

plot.style_histogram

A named constant for the ‘Histogram’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_cross plot.style_area plot.style_areabr plot.style_columns plot.style_circles

plot.style_columns

A named constant for the ‘Columns’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_cross plot.style_area plot.style_areabr plot.style_circles

plot.style_circles

A named constant for the ‘Circles’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_cross plot.style_area plot.style_areabr plot.style_columns

plot.style_area

A named constant for the ‘Area’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_areabr plot.style_cross plot.style_columns plot.style_circles

plot.style_areabr

A named constant for the ‘Area With Breaks’ style, to be used as an argument for the style parameter in the plot function. Similar to plot.style_area, except the gaps in the data are not filled.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_cross plot.style_area plot.style_columns plot.style_circles

plot.style_cross

A named constant for the ‘Cross’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_stepline plot.style_stepline_diamond plot.style_histogram plot.style_area plot.style_areabr plot.style_columns plot.style_circles

plot.style_stepline

A named constant for the ‘Step Line’ style, to be used as an argument for the style parameter in the plot function.

Type plot_style

See also plot plot.style_stepline_diamond plot.style_linebr plot.style_histogram plot.style_cross plot.style_area plot.style_areabr plot.style_columns plot.style_circles

plot.style_stepline_diamond

A named constant for the ‘Step Line With Diamonds’ style, to be used as an argument for the style parameter in the plot function. Similar to plot.style_stepline, except the data changes are also marked with the Diamond shapes.

Type plot_style

See also plot plot.style_line plot.style_linebr plot.style_histogram plot.style_cross plot.style_area plot.style_areabr plot.style_columns plot.style_circles

location

location.abovebar

location.abovebar

Location value for plotshape, plotchar functions. Shape is plotted above main series bars.

Type const string

See also plotshape plotchar location.belowbar location.top location.bottom location.absolute

location.belowbar

Location value for plotshape, plotchar functions. Shape is plotted below main series bars.

Type const string

See also plotshape plotchar location.abovebar location.top location.bottom location.absolute

location.top

Location value for plotshape, plotchar functions. Shape is plotted near the top chart border.

Type const string

See also plotshape plotchar location.abovebar location.belowbar location.bottom location.absolute

location.bottom

Location value for plotshape, plotchar functions. Shape is plotted near the bottom chart border.

Type const string

See also plotshape plotchar location.abovebar location.belowbar location.top location.absolute

location.absolute

Location value for plotshape, plotchar functions. Shape is plotted on chart using indicator value as a price coordinate.

Type const string

See also plotshape plotchar location.abovebar location.belowbar location.top location.bottom

size

size.auto

size.auto

Size value for plotshape, plotchar functions. The size of the shape automatically adapts to the size of the bars.

Type const string

See also plotshape plotchar size.tiny size.small size.normal size.large size.huge

size.tiny

Size value for plotshape, plotchar functions. The size of the shape constantly tiny.

Type const string

See also plotshape plotchar size.auto size.small size.normal size.large size.huge

size.small

Size value for plotshape, plotchar functions. The size of the shape constantly small.

Type const string

See also plotshape plotchar size.auto size.tiny size.normal size.large size.huge

size.normal

Size value for plotshape, plotchar functions. The size of the shape constantly normal.

Type const string

See also plotshape plotchar size.auto size.tiny size.small size.large size.huge

size.large

Size value for plotshape, plotchar functions. The size of the shape constantly large.

Type const string

See also plotshape plotchar size.auto size.tiny size.small size.normal size.huge

size.huge

Size value for plotshape, plotchar functions. The size of the shape constantly huge.

Type const string

See also plotshape plotchar size.auto size.tiny size.small size.normal size.large

alert

alert.freq_once_per_bar

A named constant for use with the freq parameter of the alert() function. The first function call during the bar triggers the alert.

Type const string

See also alert

alert.freq_all

A named constant for use with the freq parameter of the alert() function. All function calls trigger the alert.

Type const string

See also alert

alert.freq_once_per_bar_close

A named constant for use with the ‘freq’ parameter of the alert() function. The function call triggers the alert only when it occurs during the last script iteration of the real-time bar, when it closes.

Type const string

See also alert

format

format.inherit

Is a named constant.

Type const string

See also format.price format.volume

format.price

Is a named constant.

Type const string

Remarks If format is format.price, default precision value is set. You can use the precision argument of indicator function to change the precision value.

See also format.inherit format.volume

format.volume

It’s a named constant.

Type const string

See also format.inherit format.price

syminfo

syminfo.ticker

Symbol name without exchange prefix, e.g. ‘MSFT’.

Type simple string

See also syminfo.tickerid timeframe.period timeframe.multiplier

syminfo.tickerid

Symbol name with exchange prefix, e.g. ‘BATS:MSFT’, ‘NASDAQ:MSFT’.

Type simple string

See also syminfo.ticker timeframe.period timeframe.multiplier

syminfo.basecurrency

Base currency for the symbol. For the symbol “BTCUSD” returns “BTC”.

Type simple string

See also syminfo.currency syminfo.ticker

syminfo.currency

Currency for the current symbol. Returns currency code: “USD”, “EUR”, etc.

Type simple string

See also syminfo.basecurrency syminfo.ticker

syminfo.type

Type of the current symbol. Possible values are stock, futures, index, forex, crypto, fund, dr.

Type simple string

See also syminfo.ticker

syminfo.mintick

Min tick value for the current symbol. On FMZ Platform, the template parameter pricing currency precision in the “Pine Language Trading Class Library” on the real order/backtest interface can control this value. Pricing currency precision Setting 2 means that the price is accurate to the second decimal place when trading, and the minimum price change unit is 0.01. The value of syminfo.mintick is 0.01.

Type simple float

See also syminfo.pointvalue

syminfo.pointvalue

Point value of current product

Type simple float

See also syminfo.mintick

syminfo.timezone

Timezone of the exchange of the chart main series. Possible values see in timestamp.

Type simple string

See also timestamp

barstate

barstate.islastconfirmedhistory

Returns true if script is executing on the dataset’s last bar when market is closed, or script is executing on the bar immediately preceding the real-time bar, if market is open. Returns false otherwise.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.islast barstate.ishistory barstate.isrealtime barstate.isnew

barstate.isnew

Returns true if script is currently calculating on new bar, false otherwise.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.islast barstate.ishistory barstate.isrealtime barstate.isconfirmed barstate.islastconfirmedhistory

barstate.isfirst

Returns true if current bar is first bar in barset, false otherwise.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. Please note that using this variable/function can cause indicator repainting.

See also barstate.islast barstate.ishistory barstate.isrealtime barstate.isnew barstate.isconfirmed barstate.islastconfirmedhistory

barstate.islast

Returns true if current bar is the last bar in barset, false otherwise.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.ishistory barstate.isrealtime barstate.isnew barstate.isconfirmed barstate.islastconfirmedhistory

barstate.ishistory

Returns true if current bar is a historical bar, false otherwise.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.islast barstate.isrealtime barstate.isnew barstate.isconfirmed barstate.islastconfirmedhistory

barstate.isconfirmed

Returns true if the script is calculating the last (closing) update of the current bar. The next script calculation will be on the new bar data.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. It is NOT recommended to use barstate.isconfirmed in request.security expression. Its value requested from request.security is unpredictable. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.islast barstate.ishistory barstate.isrealtime barstate.isnew barstate.islastconfirmedhistory

barstate.isrealtime

Returns true if current bar is a real-time bar, false otherwise.

Type series bool

Remarks PineScript code that uses this variable could calculate differently on history and real-time data. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.islast barstate.ishistory barstate.isnew barstate.isconfirmed barstate.islastconfirmedhistory

barstate.time

Not available.

ta

ta.accdist

Accumulation/distribution index.

Type series float

ta.iii

Intraday Intensity Index.

Type series float

Example

// Intraday Intensity Index
plot(ta.iii, color=color.yellow)

// the same on pine
f_iii() =>
    (2 * close - high - low) / ((high - low) * volume)

plot(f_iii())

ta.nvi

Negative Volume Index.

Type series float

Example

// Negative Volume Index

plot(ta.nvi, color=color.yellow)

// the same on pine
f_nvi() =>
    float ta_nvi = 1.0
    float prevNvi = (nz(ta_nvi[1], 0.0) == 0.0)  ? 1.0: ta_nvi[1]
    if nz(close, 0.0) == 0.0 or nz(close[1], 0.0) == 0.0
        ta_nvi := prevNvi
    else
        ta_nvi := (volume < nz(volume[1], 0.0)) ? prevNvi + ((close - close[1]) / close[1]) * prevNvi : prevNvi
    result = ta_nvi

plot(f_nvi())

ta.pvi

Positive Volume Index.

Type series float

Example

// Positive Volume Index

plot(ta.pvi, color=color.yellow)

// the same on pine
f_pvi() =>
    float ta_pvi = 1.0
    float prevPvi = (nz(ta_pvi[1], 0.0) == 0.0)  ? 1.0: ta_pvi[1]
    if nz(close, 0.0) == 0.0 or nz(close[1], 0.0) == 0.0
        ta_pvi := prevPvi
    else
        ta_pvi := (volume > nz(volume[1], 0.0)) ? prevPvi + ((close - close[1]) / close[1]) * prevPvi : prevPvi
    result = ta_pvi

plot(f_pvi())

ta.obv

On Balance Volume.

Type series float

Example

// On Balance Volume
plot(ta.obv, color=color.yellow)

// the same on pine
f_obv() =>
    ta.cum(math.sign(ta.change(close)) * volume)

plot(f_obv())

ta.pvt

Price-Volume Trend.

Type series float

Example

// Price-Volume Trend
plot(ta.pvt, color=color.yellow)

// the same on pine
f_pvt() =>
    ta.cum((ta.change(close) / close[1]) * volume)

plot(f_pvt())

ta.wad

Williams Accumulation/Distribution.

Type series float

Example

// Williams Accumulation/Distribution
plot(ta.wad, color=color.yellow)

// the same on pine
f_wad() =>
    trueHigh = math.max(high, close[1])
    trueLow = math.min(low, close[1])
    mom = ta.change(close)
    gain = (mom > 0) ? close - trueLow : (mom < 0) ? close - trueHigh : 0
    ta.cum(gain)

plot(f_wad())

ta.wvad

Williams Variable Accumulation/Distribution.

Type series float

Example

// Williams Variable Accumulation/Distribution
plot(ta.wvad, color=color.yellow)

// the same on pine
f_wvad() =>
    (close - open) / (high - low) * volume

plot(f_wvad())

math

math.e

Is a named constant for Euler’s number. It is equal to 2.7182818284590452.

Type const float

See also math.phi math.pi math.rphi

math.phi

Is a named constant for the golden ratio. It is equal to 1.6180339887498948.

Type const float

See also math.e math.pi math.rphi

math.pi

Is a named constant for Archimedes’ constant. It is equal to 3.1415926535897932.

Type const float

See also math.e math.phi math.rphi

math.rphi

Is a named constant for the golden ratio conjugate. It is equal to 0.6180339887498948.

Type const float

See also math.e math.pi math.phi

strategy

strategy.equity

Current equity (strategy.initial_capital + strategy.netprofit + strategy.openprofit).

Type series float

See also strategy.netprofit strategy.openprofit strategy.position_size

strategy.position_size

Direction and size of the current market position. If the value is > 0, the market position is long. If the value is < 0, the market position is short. The absolute value is the number of contracts/shares/lots/units in trade (position size).

Type series float

See also strategy.position_avg_price

strategy.position_avg_price

Average entry price of current market position. If the market position is flat, “NaN” is returned.

Explanation The average price in FMZ PINE Script is the price including handling fee. For example: the order price is 8000, the selling direction, the quantity is 1 lot (pieces, sheets), the average price after the transaction is not 8000, but lower than 8000 (the cost includes the handling fee).

Type series float

See also strategy.position_size

strategy.long

Long position entry.

Type strategy_direction

See also strategy.entry strategy.exit

strategy.short

Short position entry.

Type strategy_direction

See also strategy.entry strategy.exit

strategy.closedtrades

Number of trades, which were closed for the whole trading interval.

Type series int

See also strategy.position_size strategy.opentrades

strategy.opentrades

Number of market position entries, which were not closed and remain opened. If there is no open market position, 0 is returned.

Type series int

See also strategy.position_size

strategy.netprofit

Total currency value of all completed trades.

Type series float

See also strategy.openprofit strategy.position_size strategy.grossprofit

strategy.grossprofit

Total currency value of all completed winning trades.

Type series float

See also strategy.netprofit

strategy.openprofit

Current unrealized profit or loss for all open positions.

Type series float

See also strategy.netprofit strategy.position_size

strategy.direction.long

It allows strategy to open only long positions.

Type const string

See also strategy.risk.allow_entry_in

strategy.direction.short

It allows strategy to open only short positions.

Type const string

See also strategy.risk.allow_entry_in

strategy.direction.all

It allows strategy to open both long and short positions.

Type const string

See also strategy.risk.allow_entry_in

dayofweek

dayofweek

Day of week for current bar time in exchange timezone.

Type series int

Remarks Note that this variable returns the day based on the time of the bar’s open. For overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this value can be lower by 1 than the day of the trading day. You can use dayofweek.sunday, dayofweek.monday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.thursday, dayofweek.friday and dayofweek.saturday variables for comparisons.

See also time dayofmonth

dayofweek.sunday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.monday dayofweek.tuesday dayofweek.wednesday dayofweek.thursday dayofweek.friday dayofweek.saturday

dayofweek.monday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.sunday dayofweek.tuesday dayofweek.wednesday dayofweek.thursday dayofweek.friday dayofweek.saturday

dayofweek.tuesday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.sunday dayofweek.monday dayofweek.wednesday dayofweek.thursday dayofweek.friday dayofweek.saturday

dayofweek.wednesday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.sunday dayofweek.monday dayofweek.tuesday dayofweek.thursday dayofweek.friday dayofweek.saturday

dayofweek.thursday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.sunday dayofweek.monday dayofweek.tuesday dayofweek.wednesday dayofweek.friday dayofweek.saturday

dayofweek.friday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.sunday dayofweek.monday dayofweek.tuesday dayofweek.wednesday dayofweek.thursday dayofweek.saturday

dayofweek.saturday

Is a named constant for return value of dayofweek function and value of dayofweek variable.

Type const int

See also dayofweek.sunday dayofweek.monday dayofweek.tuesday dayofweek.wednesday dayofweek.thursday dayofweek.friday

hline

hline.style_dashed

Is a named constant for dashed linestyle of hline function.

Type hline_style

See also hline.style_solid hline.style_dotted

hline.style_dotted

hline.style_dotted

Is a named constant for dotted linestyle of hline function.

Type hline_style

See also hline.style_solid hline.style_dashed

hline.style_solid

Is a named constant for solid linestyle of hline function.

Type hline_style

See also hline.style_dotted hline.style_dashed

barmerge

barmerge.gaps_on

Merge strategy for requested data. Data is merged with possible gaps (na values).

Type barmerge_gaps

See also request.security barmerge.gaps_off

barmerge.gaps_off

Merge strategy for requested data. Data is merged continuously without gaps, all the gaps are filled with the previous nearest existing value.

Type barmerge_gaps

See also request.security barmerge.gaps_on

barmerge.lookahead_on

Merge strategy for the requested data position. Requested barset is merged with current barset in the order of sorting bars by their opening time. This merge strategy can lead to undesirable effect of getting data from “future” on calculation on history. This is unacceptable in backtesting strategies, but can be useful in indicators.

Type barmerge_lookahead

See also request.security barmerge.lookahead_off

barmerge.lookahead_off

Merge strategy for the requested data position. Requested barset is merged with current barset in the order of sorting bars by their close time. This merge strategy disables effect of getting data from “future” on calculation on history.

Type barmerge_lookahead

See also request.security barmerge.lookahead_on

others

hl2

It is a shortcut for (highest price + lowest price)/2.

Type series float

See also open high low close volume time hlc3 hlcc4 ohlc4

hlc3

It is a shortcut for (highest price + lowest price + closing price)/3.

Type series float

See also open high low close volume time hl2 hlcc4 ohlc4

hlcc4

It is a shortcut for (highest price + lowest price + closing price + closing price)/4.

Type series float

See also open high low close volume time hl2 hlc3 ohlc4

ohlc4

It is a shortcut for (opening price + highest price + lowest price + closing price)/4.

Type series float

See also open high low close volume time hl2 hlc3 hlcc4

na

Double.NaN value (Not a Number).

Type simple na

Example

// na
plot(bar_index < 10 ? na : close)    // CORRECT
plot(close == na ? close[1] : close)    // INCORRECT!
plot(na(close) ? close[1] : close)    // CORRECT

Remarks Use it for return values ONLY. DON’T TRY TO COMPARE WITH IT! If you need to check if some value is NaN, use built-in function na.

See also na

bar_index

Current bar index. Numbering is zero-based, index of the first bar is 0.

Type series int

Example

// bar_index
plot(bar_index)
plot(bar_index > 5000 ? close : 0)

Remarks Note that bar_index has replaced n variable in version 4. Note that bar indexing starts from 0 on the first historical bar. Please note that using this variable/function can cause indicator repainting.

See also barstate.isfirst barstate.islast barstate.isrealtime

last_bar_index

Bar index of the last chart bar. Bar indices begin at zero on the first bar.

Type series int

Example

strategy("Mark Last X Bars For Backtesting", overlay = true, calc_on_every_tick = true)
lastBarsFilterInput = input.int(100, "Bars Count:")
// Here, we store the 'last_bar_index' value that is known from the beginning of the script's calculation.
// The 'last_bar_index' will change when new real-time bars appear, so we declare 'lastbar' with the 'var' keyword.
var lastbar = last_bar_index
// Check if the current bar_index is 'lastBarsFilterInput' removed from the last bar on the chart, or the chart is traded in real-time.
allowedToTrade = (lastbar - bar_index <= lastBarsFilterInput) or barstate.isrealtime
bgcolor(allowedToTrade ? color.new(color.green, 80) : na)

Returns Last historical bar index for closed markets, or the real-time bar index for open markets.

Remarks Please note that using this variable can cause indicator repainting.

See also bar_index last_bar_time barstate.ishistory barstate.isrealtime

time

Current bar time in UNIX format. It is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.

timenow

Current time in UNIX format. It is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.

Type series int

Remarks Please note that using this variable/function can cause indicator repainting.

See also timestamp time dayofmonth dayofweek

Type series int

Remarks Note that this variable returns the timestamp based on the time of the bar’s open. Because of that, for overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this variable can return time before the specified date of the trading day. For example, on EURUSD, “dayofmonth(time)” can be lower by 1 than the date of the trading day, because the bar for the current day actually opens one day prior.

See also time dayofmonth dayofweek

year

Current bar year in exchange timezone.

Type series int

Reamrks Note that this variable returns the year based on the time of the bar’s open. For overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this value can be lower by 1 than the year of the trading day.

See also year time month weekofyear dayofmonth dayofweek hour minute second

month

Current bar month in exchange timezone.

Type series int

Reamrks Note that this variable returns the month based on the time of the bar’s open. For overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this value can be lower by 1 than the month of the trading day.

See also month time year weekofyear dayofmonth dayofweek hour minute second

hour

Current bar hour in exchange timezone.

Type series int

See also hour time year month weekofyear dayofmonth dayofweek minute second

minute

Current bar minute in exchange timezone.

Type series int

See also minute time year month weekofyear dayofmonth dayofweek hour second

second

Current bar second in exchange timezone.

Type series int

See also second time year month weekofyear dayofmonth dayofweek hour minute

open

Current open price.

Type series float

Remarks Previous values may be accessed with square brackets operator [], e.g. open[1], open[2].

See also high low close volume time hl2 hlc3 hlcc4 ohlc4

high

Current highest price.

Type series float

Remarks Previous values may be accessed with square brackets operator [], e.g. high[1], high[2].

See also open low close volume time hl2 hlc3 hlcc4 ohlc4

low

Current lowest price.

Type series float

Remarks Previous values may be accessed with square brackets operator [], e.g. low[1], low[2].

See also open high close volume time hl2 hlc3 hlcc4 ohlc4

close

Close price of the current bar when it has closed, or last traded price of a yet incomplete, realtime bar.

Type series float

Remarks Previous values may be accessed with square brackets operator [], e.g. close[1], close[2].

See also open high low volume time hl2 hlc3 hlcc4 ohlc4

volume

Current bar volume.

Type series float

Remarks Previous values may be accessed with square brackets operator [], e.g. volume[1], volume[2].

See also open high low close time hl2 hlc3 hlcc4 ohlc4

weekofyear

Week number of current bar time in exchange timezone.

Type series int

Remarks Note that this variable returns the week based on the time of the bar’s open. For overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this value can be lower by 1 than the week of the trading day.

See also weekofyear time year month dayofmonth dayofweek hour minute second

dayofmonth

Date of current bar time in exchange timezone.

Type series int

Remarks Note that this variable returns the day based on the time of the bar’s open. For overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this value can be lower by 1 than the day of the trading day.

See also time dayofweek


More

乞丐 为何策略广场复制的pine策略无法实盘

发明者量化-小小梦 好的,我们检查下。

乞丐 张超大佬的Optimized Trend Tracker

发明者量化-小小梦 您好,请问具体是哪个策略呢?