s.entry_price(tradeNo) exitP = strategy.closedtrades.exit_price(tradeNo) profitPct += (exitP - entryP) / entryP * strategy.closedtrades.size(tradeNo) * 100
// Calculate average profit percent for both closed trades. avgProfitPct = nz(profitPct / strategy.closedtrades)
plot(avgProfitPct)
**参数**
- ```trade_num``` (series int) 已平仓交易的交易编号。第一笔交易的编号为零。
**另见**
```strategy.opentrades.size``` ```strategy.position_size``` ```strategy.closedtrades``` ```strategy.opentrades```
### strategy.closedtrades.exit_time
返回已平仓交易退出的UNIX时间。
strategy.closedtrades.exit_time(trade_num)
**例子**
```pine
strategy("strategy.closedtrades.exit_time Example 1")
// Enter long trades on three rising bars; exit on two falling bars.
if ta.rising(close, 3)
strategy.entry("Long", strategy.long)
if ta.falling(close, 2)
strategy.close("Long")
// Calculate the average trade duration.
avgTradeDuration() =>
sumTradeDuration = 0
for i = 0 to strategy.closedtrades - 1
sumTradeDuration += strategy.closedtrades.exit_time(i) - strategy.closedtrades.entry_time(i)
result = nz(sumTradeDuration / strategy.closedtrades)
// Display average duration converted to seconds and formatted using 2 decimal points.
if barstate.islastconfirmedhistory
label.new(bar_index, high, str.tostring(avgTradeDuration() / 1000, "#.##") + " seconds")
Re-open a closed trade in X seconds.
Examples
strategy("strategy.closedtrades.exit_time Example 2")
// Strategy calls to emulate a single long trade at the first bar.
if bar_index == 0
strategy.entry("Long", strategy.long)
reopenPositionAfter(timeSec) =>
if strategy.closedtrades > 0
if time - strategy.closedtrades.exit_time(strategy.closedtrades - 1) >= timeSec * 1000
strategy.entry("Long", strategy.long)
// Reopen last closed position after 120 sec.
reopenPositionAfter(120)
if ta.change(strategy.opentrades)
strategy.exit("Long", stop = low * 0.9, profit = high * 2.5)
Parameters
trade_num
(series int) The transaction number of the transaction that has been settled. The first transaction number is zero.See you later
strategy.closedtrades.entry_time
此函数可用于指定strategy.entry函数允许在哪个市场方向开仓。
strategy.risk.allow_entry_in(value)
Examples
strategy("strategy.risk.allow_entry_in")
strategy.risk.allow_entry_in(strategy.direction.long)
strategy.entry("Long", strategy.long, when = open > close)
// Instead of opening a short position with 10 contracts, this command will close long entries.
strategy.entry("Short", strategy.short, when = open < close, qty = 10)
Parameters
value
(simple string) Allowed directions. Possible values:strategy.direction.all
、strategy.direction.long
、strategy.direction.short
The purpose of this rule is to determine the maximum value of a market position. The rule affects the following functions:strategy.entry
The number of entry tickets can be reduced (if necessary) to the number of contracts/shares/hands/units, so that the total position value does not exceed the value specified in the tickets strategy.risk.max_position_size.
strategy.risk.max_position_size(contracts)
Examples
strategy("risk.max_position_size Demo", default_qty_value = 100)
strategy.risk.max_position_size(10)
strategy.entry("buy", strategy.long, when = open > close)
plot(strategy.position_size) // max plot value will be 10
Parameters
contracts
(simple int/float) Necessary parameter. Maximum number of contracts/shares/hands/units in the position.What ifnumber
>= 0,number
The absolute value isnumber
I'm not going to say anything else.number
。
math.abs(number)
Returns the value
number
This is the absolute value of ∞.
The acos function returns the inverse of a number, such that cos (acos (y)) = y in the range y [-1, 1];
math.acos(angle)
Returns the valueIf y is outside the range [-1,1], return the angle in the range [0, Pi] or na.
Returns a pseudo-random value. This function will generate a different value sequence for each script run. Using the same value for the selected seed parameter will generate a repeatable sequence.
math.random(min, max, seed)
Returns the valueA random value.
Parameters
min
(series int/float) The lower limit of the range of random values. This value is not included in the range. The default value is 0.max
(series int/float) Upper limit of the range of random values. This value is not included in the range. The default value is 1.seed
(input int) Optional parameter. When using the same seed, it is allowed to call the function consecutively to produce a set of repeatable values.The asin function returns the inverse sine of the number (which is expressed as an arc), sine (which is expressed as y) = y in the y-scale [-1, 1].
math.asin(angle)
Returns the valueThe inverse chord value. If y exceeds the range [-1,1], the return angle is in the range of [−Pi / 2,Pi / 2] or na.
The atan function returns the inverse of a number (in arcs), where tan (atan (y)) = any y in y.
math.atan(angle)
Returns the valueThe inverse of the shear value; the return angle is in the range of [−Pi / 2,Pi / 2].
The upper integer function returns the smallest (closest to negative infinity) integer greater than or equal to the parameter.
math.ceil(number)
Returns the valueThe smallest integer less than or equal to a given number
See you later
math.floor
math.round
The cos function returns the trigonometric consonant of the angle.
math.cos(angle)
Returns the valueThe triangular consonants of the corners.
Parameters
angle
(series int/float) angle, in the form of an arcnumber
The exp function is e.number
The second side, where e is the Eura number.
math.exp(number)
Returns the valueSo the value of e is equal tonumber
I'm not going to lie.
See you later
math.pow
math.floor(number)
Returns the valueThe largest integer less than or equal to a given number.
See you later
math.ceil
math.round
anynumber
The natural logarithm > 0 is the only y, so e^y =number
。
math.log(number)
Returns the value
number
The natural logarithm of a linear system is the logarithm of the natural logarithm of a system.
See you later
math.log10
number
A commonly used (or bottomed by 10) logarithm is the one that must be raised to 10 to get the sine of 10.number
。10^y = number
。
math.log10(number)
Returns the value
number
The logarithm of the base 10.
See you later
math.log
Mathematical curve function
math.pow(base, exponent)
Examples
// math.pow
plot(math.pow(close, 2))
Returns the value
base
Increase toexponent
I'm not sure what you mean.base
A series is a series that is computed by elements.
Parameters
base
(series int/float) Specifies the base to be used.exponent
(series int/float) Specifies the index.See you later
math.sqrt
math.exp
The symbol (signum) of the symbol (signum) is zero if it is zero, 1.0 if it is greater than 0, and 1.0 if it is less than 0.
math.sign(number)
Returns the valueThe symbol of the parameter.
The sine function returns the sine of a triangle at one angle.
math.sin(angle)
Returns the valueThe triangular sine of the corners.
Parameters
angle
(series int/float) angle, in the form of an arcanynumber
So the square root of y > = 0 is the only way that y > = 0 makes y squared equal tonumber
。
math.sqrt(number)
Returns the value
number
The square root of
See you later
math.pow
The tangent of the tangent of the tangent of the tangent of the tangent of the tangent.
math.tan(angle)
Returns the valueThe triangles of the corners are straight.
Parameters
angle
(series int/float) angle, in the form of an arcGoing backnumber
The value of the square root of 5 goes to the nearest integer and is integrated upwards.precision
Parameter, which returns a floating point value of four-fifths to the decimal place.
math.round(number)
math.round(number, precision)
Returns the value
number
The value of four to the nearest whole number, or according to precision.
Parameters
number
(series int/float) To have a value of four to five entries.precision
(series int) Optional parameters.number
The least common multiple of four squares of five. When no arguments are provided, four squares of five are added to the nearest integer.NotesNote that for the threshold value of
See you later
math.ceil
math.floor
Returns the largest of several values.
math.max(number0, number1, ...)
Examples
// math.max
plot(math.max(close, open))
plot(math.max(close, math.max(open, 42)))
Returns the valueThe largest of several given values.
See you later
math.min
Returns the smallest of several values.
math.min(number0, number1, ...)
Examples
// math.min
plot(math.min(close, open))
plot(math.min(close, math.min(open, 42)))
Returns the valueThe smallest of several given values.
See you later
math.max
Calculates the average of all series (corresponding elements)
math.avg(number0, number1, ...)
Returns the valueAverage
See you later
math.sum
ta.cum
ta.sma
返回四舍五入到商品的mintick的值,即可以除以syminfo.mintick的最接近的值,没有余数,并向上舍入。
math.round_to_mintick(number)
Returns the value
number
Four-fifths to the tick.
Parameters
number
(series int/float) To have a value of four to five entries.See you later
math.ceil
math.floor
The sum function returns the sliding sum of the last y-value of x.
math.sum(source, length)
Returns the value
length
The K line returnssource
Summary.
Parameters
source
(series int/float) The series value to be executed.length
(series int) K number of lines (length).See you later
ta.cum
for
Returns the approximate equivalent angle in degrees from the angle in units of arc.
math.todegrees(radians)
Returns the valueThe unit of angle in degrees.
Parameters
radians
(series int/float) angle in units of arc.Returns the approximate equivalent angle in units of arc from the angle in degrees.
math.toradians(degrees)
Returns the valueAngular value in units of arc.
Parameters
degrees
(series int/float) in units of degree.For a given series, replace the NaN value with the previous non-NaN value.
fixnan(source)
Returns the valueThe series without any gaps.
Parameters
source
(series int/float/bool/color)See you later
na
nz
Replace the NaN value with a zero ((or specified number) in the series.
nz(source, replacement)
nz(source)
Examples
// nz
plot(nz(ta.sma(close, 100)))
Returns the value
source
The value, if it's notna
❖ Ifsource
The value ofna
So if you use 1, you get 0.replacement
Parameters are.
Parameters
source
(series int/float/bool/color) The series value to be executed.replacement
(series int/float/bool/color) replaces the values of all the threshold values of the array in the source array.See you later
na
fixnan
If NaN, test the value.
na(x)
Returns the valueIf x is an invalid number, then true (x is NaN), otherwise false.
See you later
fixnan
nz
Convert to na or cut the float value to int.
int(x)
Returns the valueConvert to the value of the parameter after int.
See you later
float
bool
color
string
Set na to float.
float(x)
Returns the valueConvert to float parameter value.
See you later
int
bool
color
string
Trigger an alert event when called during a real-time K-line, and create an alert based on an alert function event as an indicator or strategy by creating an alert dialog box with the previous alert.
alert(message, freq)
Examples
// alert() example
ma = ta.sma(close, 14)
xUp = ta.crossover(close, ma)
if xUp
// Trigger the alert the first time a cross occurs during the real-time bar.
alert("Price (" + str.tostring(close) + ") crossed over MA (" + str.tostring(ma) + ").", alert.freq_once_per_bar)
plot(ma)
plotchar(xUp, "xUp", "▲", location.top, size = size.tiny)
Parameters
message
(series string) The message sent when the alert is triggered.freq
(input string) trigger frequency;; Possible values are: alert.freq_all (all function calls trigger alerts), alert.freq_once_per_bar (the first function call in the K-line triggers alerts), alert.freq_once_per_bar_close (function calls only trigger alerts when they occur during the last script iteration of the real-time K-line and only when they are closed); default value is alert.freq_once_per_bar (alert.freq_once_per_bar);NotesThe Help Center explains how to create such alerts.
Unlike the alert condition, the alert call does not count as an additional drawing.
Function calls can be made both globally and locally.
Function calls don't show anything on the chart.
The
See you later
alertcondition
Create Alert Condition, available in the Create Alert dialog box. Note that alertcondition does not create an alert, it only gives you more options in the Create Alert dialog box. In addition, the effect of alertcondition is not visible in the chart.
alertcondition(condition, title, message)
Examples
// alertcondition
alertcondition(close >= open, title='Alert on Green Bar', message='Green Bar!')
Parameters
condition
(series bool) A series boolean value used for alerts. True represents the trigger of the alert, false - no alert.title
(const string) The title of the alert condition. Optional parameters.message
(const string) Displays a message when an alert is triggered. Optional parameter.NotesNote that in Pine v4, an alert condition call generates an additional graph. All of these calls are taken into account when we calculate the number of output series for each script.
See you later
alert
For compatibilityTrading View
In the case of the most recent version of the software, the user can use the following commands:
See you later
strategy
The time function returns the current UNIX time of the current K-line of the specified time range and transactional time period, and NaN if the time point is not in the transactional time period. Note: FMZ is not supported.session
Parameters are.
time(timeframe, session, timezone)
time(timeframe, session)
time(timeframe)
Examples
timeinrange(res, sess) => not na(time(res, sess, "America/New_York")) ? 1 : 0
plot(timeinrange("1", "1300-1400"), color=color.red)
// This plots 1.0 at every start of 10 minute bar on a 1 minute chart:
newbar(res) => ta.change(time(res)) == 0 ? 0 : 1
plot(newbar("10"))
When you set up a session, you can specify not only the hours and minutes, but also the date of the week. If no date is specified, the trading period is assumed to be from Sunday (1) to Saturday (7), i.e. the same as the trading period for the 1100--2000 tonnes as for the 1100--1200:1234567 tonnes. You can change it by specifying a date. For example, for commodities that trade 7 days a week and are in a 24-hour trading period, the following script will not be colored for Saturday and Sunday:
Examples
// Time
t1 = time(timeframe.period, "0000-0000:23456")
bgcolor(t1 ? color.new(color.blue, 90) : na)
Onesession
Parameters can contain several different trading time periods separated by commas. For example, the following script will highlight a K-string from 10:00 to 11:00 and from 14:00 to 15:00 (weekdays only):
Examples
// Time
t1 = time(timeframe.period, "1000-1100,1400-1500:23456")
bgcolor(t1 ? color.new(color.blue, 90) : na)
Returns the valueUnix time.
Parameters
timeframe
(simple string) Time period. The empty string is interpreted as the current time period of the graph.session
timezone
(simple string) session
The time zone of the parameter. It can only be used when a sync session bar is specified. It is optional. The default value is syminfo.timezone. It can be specified using GMT (e.g. sync GMT-5 bar) or IANA time zone database name (e.g. syncAmerica/New_York bar).NotesUNIX time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970.
year(time)
year(time, timezone)
Returns the valueThe year in which UNIX time is provided (the time zone of the exchange).
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values. Note that this function returns the year based on the opening time of the K-line. For overnight trading hours (e.g. EURUSD Monday trading hours starting at 17:00 UTC-4 on Sunday), this value can be lower than the year of the trading day.
See you later
year
time
month
dayofmonth
dayofweek
hour
minute
second
month(time)
month(time, timezone)
Returns the valueThe month in which UNIX time is available (the time zone of the exchange).
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values. Note that this function returns the month based on the opening time of the K-line. For overnight trading periods (e.g., EURUSD Monday trading period starts at 17:00 UTC-4 on Sunday), this value can be lower than 1 for the month of the trading day.
See you later
month
time
year
dayofmonth
dayofweek
hour
minute
second
hour(time)
hour(time, timezone)
Returns the valueProvides hours of UNIX time (switching time zones).
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values.
See you later
hour
time
year
month
dayofmonth
dayofweek
minute
second
minute(time)
minute(time, timezone)
Returns the valueMinutes of UNIX time are provided.
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values.
See you later
minute
time
year
month
dayofmonth
dayofweek
hour
second
second(time)
second(time, timezone)
Returns the valueThe number of seconds of UNIX time (switching time zone) is provided.
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values.
See you later
second
time
year
month
dayofmonth
dayofweek
hour
minute
weekofyear(time)
weekofyear(time, timezone)
Returns the valueIt provides a cycle of UNIX time (switching time zones).
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values. Note that this function returns the week based on the opening time of the K-line. For overnight trading hours (e.g. EURUSD, whose Monday trading hours start at 17:00 on Sunday), this value can be lower than the week of the trading day.
See you later
weekofyear
time
year
month
dayofmonth
dayofweek
hour
minute
second
dayofweek(time)
dayofweek(time, timezone)
Returns the valueThe date of each week (switching time zone) is provided in UNIX time.
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesNote that this function returns the date based on the opening time of the K-line. For overnight trading hours (e.g. EURUSD Monday trading hours starting at 17:00 on Sunday), this value can be 1 lower than the date of the trading day. UNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values.
See you later
time
dayofmonth
dayofmonth(time)
dayofmonth(time, timezone)
Returns the valueThe date of the month (switching time zone) for which UNIX time is provided.
Parameters
time
(series int) Unix time in milliseconds.timezone
(series string) Optional parameters.Time zone.NotesUNIX time is the number of milliseconds since 00:00:00 UTC on January 1, 1970. By default, the time zone is syminfo.timezone. You can use timestamp to check for possible values. Note that this function returns the date based on the opening time of the K line. For overnight trading hours (e.g. EURUSD Monday trading hours starting at 17:00 UTC-4 on Sunday), this value can be 1 lower than the date of the trading day.
See you later
time
dayofweek
The timestamp function returns the specified date and time of UNIX time.
timestamp(dateString)
timestamp(year, month, day, hour, minute, second)
timestamp(timezone, year, month, day, hour, minute, second)
Examples
// timestamp
plot(timestamp(2016, 01, 19, 09, 30), linewidth=3, color=color.green)
plot(timestamp(syminfo.timezone, 2016, 01, 19, 09, 30), color=color.blue)
plot(timestamp(2016, 01, 19, 09, 30), color=color.yellow)
plot(timestamp("GMT+6", 2016, 01, 19, 09, 30))
plot(timestamp(2019, 06, 19, 09, 30, 15), color=color.lime)
plot(timestamp("GMT+3", 2019, 06, 19, 09, 30, 15), color=color.fuchsia)
plot(timestamp("Feb 01 2020 22:10:05"))
plot(timestamp("2011-10-10T14:48:00"))
plot(timestamp("04 Dec 1995 00:12:00 GMT+5"))
Returns the valueUnix time.
Parameters
timezone
(series string) Time zone. Optional. Default is syminfo.timezone. It can be specified using GMT (e.g. GMT-5 string) or IANA time zone database name (e.g.year
(series int) year.month
(series int) Month.day
(series int) day.hour
(series int) (optional parameter) Hours. The default is 0.minute
(series int) (optional parameter) Minutes. The default is 0.second
(series int) (optional parameter) Second♦ The default is 0♦dateString
(const string) A string that contains the date as well as an optional time and time zone. Its format must conform to the IETF RFC 2822 or ISO 8601 standards. (NotesUNIX time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970.
See you later
time
timenow
syminfo.timezone
Use the provided color to fill the background between two drawings or lines.
fill(hline1, hline2, color, title, editable, fillgaps, display)
fill(plot1, plot2, color, title, editable, show_last, fillgaps, display)
Examples
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))
Parameters
hline1
(hline) The firsthline object.hline2
(hline) The secondhline object. == Necessary parameters==plot1
(plot) The first drawing object.plot2
(plot) The second drawing object. Parameters needed.color
(series color) The color of the drawing. You can use constants such as title
(const string) has created a header for filling objects. Optional parameters.editable
(const bool) If true, the style fill can be edited in the format dialog box. The default is true.show_last
(input int) If set, defines the number of k-strings to fill the graph ((returns past from last k-string)).fillgaps
(const bool) controls the continuous filling of the space, i.e. when one of the plot() calls returns a value of na. Set to true, the last fill will continue to fill the space. Default false.display
(plot_display) Controls the display position of the fill. Possible values are: display.none、display.all。 by default display.all。See you later
plot
barcolor
bgcolor
hline
A horizontal line is presented at a given fixed price level.
hline(price, title, color, linestyle, linewidth, editable, display)
Examples
// 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 the valueHline objects that can be used to fill.
Parameters
price
(input int/float) The price value that the object will display.title
(const string) Title of the objectcolor
(input color) The color of the rendered line. It must be a constant (non-expressive). Optional parameters.linestyle
(hline_style) Rendering line style. Possible values include: solid, dotted, dotted. Optional parameters.linewidth
(Input int) Width of render line. Default is 1editable
(const bool) If true, the hline style can be edited in the format dialog box. The default is true.display
(plot_display) The display location of the control line. Possible values are display.none, 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).strategy
Orindicator
The insideoverlay
The parameters are set.strategy
Orindicator
No settingsoverlay
Parameters are processed according to the default parameters.Fill the background of the K-line with a specified color.
bgcolor(color, offset, editable, show_last, title, display, overlay)
Examples
// bgcolor example
bgcolor(close < open ? color.new(color.red,70) : color.new(color.green, 70))
Parameters
color
(series color) Fill in the background color. You can use constants such as red string or #ff001a string and complex expressions such as 'close >= open? green : red string. Necessary parameters.offset
(series int) A series of colors that move left or right on a certain number of k lines. The default value is 0.editable
(const bool) If true, the bgcolor style can be edited in the format dialog box. The default is true.show_last
(input int) If set, defines the number of k-strings to fill the graph ((returns past from last k-string)).title
(const string) title of bgcolor. Optional parameters.display
(plot_display) Controls the display position of bgcolor. Possible values are display.none、display.all。 by default 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).strategy
Orindicator
The insideoverlay
The parameters are set.strategy
Orindicator
No settingsoverlay
Parameters are processed according to the default parameters.See you later
plot
Set the K-line color.
barcolor(color, offset, editable, show_last, title, display)
Examples
barcolor(close < open ? color.black : color.white)
Parameters
color
(series color) K-line color. You can use constants such as offset
(series int) A series of colors that move left or right on a certain number of k lines. The default value is 0.editable
(const bool) If true, the barcolor style can be edited in the format dialog box. The default is true.show_last
(input int) If set, defines the number of k-strings to fill the graph ((returns past from last k-string)).title
(const string) Barcolor title. Optional parameters.display
(plot_display) Controls the display position of the K-line color. Possible values are display.none、display.all。 by default display.all。See you later
bgcolor
plot
fill
It is compatible with PINE v4error
, function andruntime.error
I agree.
Determine the order of the array from smallest to largest.
Types sort_order
See you later
array.new_float
array.sort
Determine the order of the array from largest to smallest.
Types sort_order
See you later
array.new_float
array.sort
Returns true if the current resolution is daily, false if not.
Types simple bool
See you later
timeframe.isdwm
timeframe.isintraday
timeframe.isminutes
timeframe.isseconds
timeframe.isweekly
timeframe.ismonthly
Returns true if the current resolution is daily, weekly, or monthly, otherwise false.
Types simple bool
See you later
timeframe.isintraday
timeframe.isminutes
timeframe.isseconds
timeframe.isdaily
timeframe.isweekly
timeframe.ismonthly
Returns true if the current cycle is a daily (minute or second) cycle, otherwise false.
Types simple bool
See you later
timeframe.isminutes
timeframe.isseconds
timeframe.isdwm
timeframe.isdaily
timeframe.isweekly
timeframe.ismonthly
Returns true if the current cycle is a minute cycle, or false if it is not.
Types simple bool
See you later
timeframe.isdwm
timeframe.isintraday
timeframe.isseconds
timeframe.isdaily
timeframe.isweekly
timeframe.ismonthly
Returns true if the current resolution is a monthly resolution, otherwise false.
Types simple bool
See you later
timeframe.isdwm
timeframe.isintraday
timeframe.isminutes
timeframe.isseconds
timeframe.isdaily
timeframe.isweekly
Returns true if the current cycle is seconds, or false if it is not.
Types simple bool
See you later
timeframe.isdwm
timeframe.isintraday
timeframe.isminutes
timeframe.isdaily
timeframe.isweekly
timeframe.ismonthly
Returns true if the current resolution is weekly, false if not.
Types simple bool
See you later
timeframe.isdwm
timeframe.isintraday
timeframe.isminutes
timeframe.isseconds
timeframe.isdaily
timeframe.ismonthly
The time cycle multiples, for example,
Types simple int
See you later
syminfo.ticker
syminfo.tickerid
timeframe.period
Time cycles such as 60 days - 60 minutes, 60 days - 60 minutes, 60 days - 60 minutes, 60 days - 60 minutes, 5 days - 5 days, 12 months - 1 year, 3 months - 1 quarter.
Types simple string
See you later
syminfo.ticker
syminfo.tickerid
timeframe.multiplier
A named constant that specifies where the drawing is displayed. Nowhere displayed. Available in the alert template message.
Types plot_display
See you later
plot
plotshape
plotchar
A named constant that specifies the position of the drawing to be displayed.
Types plot_display
See you later
plot
plotshape
plotchar
plotarrow
plotbar
plotcandle
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
The shape style of the plotshape function.
Types const string
See you later
plotshape
is the naming constant for #00BCD4 color.
Types const color
The name of the color is #363A45.
Types const color
It is the naming constant of #2962ff color.
Types const color
This is the naming constant for #E040FB color.
Types const color
This is the naming constant for #787B86 colour.
Types const color
This is the naming constant for the color #4CAF50.
Types const color
is the naming constant for #00E676 colour.
Types const color
The naming constant for #880E4F colour.
Types const color
is the naming constant for color #311B92.
Types const color
This is the naming constant of #808000 colors.
Types const color
This is the naming constant for #FF9800 colour.
Types const color
is the naming constant for #9C27B0 color.
Types const color
It is the naming constant for the color #FF5252.
Types const color
The naming constants for #B2B5BE colors are:
Types const color
color.teal
This is the naming constant for #00897B color.
Types const color
This is the naming constant for #FFFFFF colors.
Types const color
It is the naming constant of the color #FFEB3B.
Types const color
'Linear array-style naming constants used in plot functionsstyle
The parameters of the parameters.
Types plot_style
See you later
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
'Line With Breaks', a naming constant in the 'Line With Breaks' style, used as a plot functionstyle
The parameters of the argument are similar to plot.style_line, except that the spaces in the data are not filled.
Types plot_style
See you later
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
'Histogram-style naming constant, used as a plot functionstyle
The parameters of the parameters.
Types plot_style
See you later
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
A named constant in the style of the column column, used as a plot functionstyle
The parameters of the parameters.
Types plot_style
See you later
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
A named constant in the form of a cube, used as a plot functionstyle
The parameters of the parameters.
Types plot_style
See you later
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
'Area array-style naming constants used in plot functionsstyle
The parameters of the parameters.
Types plot_style
See you later
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
'Area With Breaks', a naming constant in the shape of a cube, used as a plot functionstyle
The parameters of the argument are similar to plot.style_area except that the blank space in the data is not filled.
Types plot_style
See you later
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
A constant named in the form of a cross-curve, used in a plot functionstyle
The parameters of the parameters.
Types plot_style
See you later
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
'Step Line array-style naming constants used in plot functionsstyle
The parameters of the parameters.
Types plot_style
See you later
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
'Step Line With Diamonds', a naming constant in the shape of a cube, used in a plot functionstyle
Parameters of the parameter. Similar to plot.style_stepline, the data changes are also marked with a diagonal.
Types plot_style
See you later
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.abovebar
plotshape, the location value of the plotchar function. The shape is plotted above the k-line of the main series.
Types const string
See you later
plotshape
plotchar
location.belowbar
location.top
location.bottom
location.absolute
plotshape, the location value of the plotchar function. The shape is plotted below the k-line of the main series.
Types const string
See you later
plotshape
plotchar
location.abovebar
location.top
location.bottom
location.absolute
plotshape, the location value of the plotchar function. The shape is drawn near the top of the chart border.
Types const string
See you later
plotshape
plotchar
location.abovebar
location.belowbar
location.bottom
location.absolute
plotshape, the location value of the plotchar function. The shape is drawn near the bottom chart border.
Types const string
See you later
plotshape
plotchar
location.abovebar
location.belowbar
location.top
location.absolute
plotshape, the location value of the plotchar function. The shape is plotted on a graph using the indicator value as the price coordinate.
Types const string
See you later
plotshape
plotchar
location.abovebar
location.belowbar
location.top
location.bottom
plotshape, the size value of the plotchar function. The size of the shape is automatically adjusted to the size of the k-line.
Types const string
See you later
plotshape
plotchar
size.tiny
size.small
size.normal
size.large
size.huge
plotshape, the size value of the plotchar function.
Types const string
See you later
plotshape
plotchar
size.auto
size.small
size.normal
size.large
size.huge
plotshape, the size value of the plotchar function.
Types const string
See you later
plotshape
plotchar
size.auto
size.tiny
size.normal
size.large
size.huge
plotshape, the size and size of the plotchar function.
Types const string
See you later
plotshape
plotchar
size.auto
size.tiny
size.small
size.large
size.huge
plotshape, the size value of the plotchar function.
Types const string
See you later
plotshape
plotchar
size.auto
size.tiny
size.small
size.normal
size.huge
plotshape, the size of the plotchar function. The size of the shape is huge.
Types const string
See you later
plotshape
plotchar
size.auto
size.tiny
size.small
size.normal
size.large
A naming constant used with the
Types const string
See you later
alert
A naming constant used with the
Types const string
See you later
alert
A naming constant used in conjunction with the
Types const string
See you later
alert
This is a named constant.
Types const string
See you later
format.price
format.volume
This is a named constant.
Types const string
Notes 如果format是format.price,则设置默认精度值。您可以使用指标函数的precision参数来更改精度值。
See you later
format.inherit
format.volume
This is a named constant.
Types const string
See you later
format.inherit
format.price
Commodity codes without an exchange prefix, such as
Types simple string
See you later
syminfo.tickerid
timeframe.period
timeframe.multiplier
Commodity codes with an exchange prefix, such as
Types simple string
See you later
syminfo.ticker
timeframe.period
timeframe.multiplier
The base currency of the commodity. For the commodity code, the BTCUSD is the base currency, and the BTC is the return currency.
Types simple string
See you later
syminfo.currency
syminfo.ticker
Currency of the current commodity. Return currency codes:
Types simple string
See you later
syminfo.basecurrency
syminfo.ticker
The type of the current commodity code. Possible values are stock, futures, index, forex, crypto, fund, dr.
Types simple string
See you later
syminfo.ticker
Minimum scoring value for the current variety. On FMZ, template parameters in the "Pine language transaction library" on the hard disk/retry interfacePrecision pricingYou can control this value.Precision pricingSet 2 as the price is accurate to the second decimal place when trading, at which point the minimum unit of change in price is 0.01。syminfo.mintick value is 0.01。
Types simple float
See you later
syminfo.pointvalue
The point value of the current commodity
Types simple float
See you later
syminfo.mintick
Time zones for the main series of the chart. For possible values see timestamp.
Types simple string
See you later
timestamp
If the script is executing on the last K line of the dataset at the market close, or the script is executing on the K line before the real-time K line, it returns true if the market opens. Otherwise, it returns false.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations on historical records and real-time data. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.islast
barstate.ishistory
barstate.isrealtime
barstate.isnew
Returns true if the script is currently computing on the new k-line, otherwise false.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations on historical records and real-time data. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.islast
barstate.ishistory
barstate.isrealtime
barstate.isconfirmed
barstate.islastconfirmedhistory
Returns true if the current k-string is the first k-string of the k-string set, otherwise false.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations on historical records and real-time data. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.islast
barstate.ishistory
barstate.isrealtime
barstate.isnew
barstate.isconfirmed
barstate.islastconfirmedhistory
Returns true if the current k-string is the last k-string in the k-string set, otherwise false.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations on historical records and real-time data. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.ishistory
barstate.isrealtime
barstate.isnew
barstate.isconfirmed
barstate.islastconfirmedhistory
Returns true if the current k-string is a historical k-string, or false if it is not.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations on historical records and real-time data. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.islast
barstate.isrealtime
barstate.isnew
barstate.isconfirmed
barstate.islastconfirmedhistory
Returns true if the script is computing the last update of the current k-line. The next script will calculate on the new K-line data.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations for historical records and real-time data. It is not recommended to use barstate.isconfirmed in the request.security expression. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.islast
barstate.ishistory
barstate.isrealtime
barstate.isnew
barstate.islastconfirmedhistory
If the current k-line is a real-time k-line, it returns true, otherwise it returns false.
Types series bool
NotesUse of this variable allows the PineScript code to perform different calculations on historical records and real-time data. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.islast
barstate.ishistory
barstate.isnew
barstate.isconfirmed
barstate.islastconfirmedhistory
Not yet
Accumulated/Distributed Index
Types series float
The intensity index of the disc.
Types series float
Examples
// 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())
The negative weight indicator.
Types series float
Examples
// 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())
This is a good indicator.
Types series float
Examples
// 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())
This is the energy wave indicator.
Types series float
Examples
// 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())
The price trend indicators are also showing signs of decline.
Types series float
Examples
// 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())
William has a lot of air force lines.
Types series float
Examples
// 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())
William varies the dispersion.
Types series float
Examples
// Williams Variable Accumulation/Distribution
plot(ta.wvad, color=color.yellow)
// the same on pine
f_wvad() =>
(close - open) / (high - low) * volume
plot(f_wvad())
is the name constant of the Euler number. It is equal to 2.7182818284590452
Types const float
See you later
math.phi
math.pi
math.rphi
is the name constant of the gold partition. It is equal to 1.6180339887498948
Types const float
See you later
math.e
math.pi
math.rphi
is the name constant of the Archimedean constant. It is equal to 3.1415926535897932
Types const float
See you later
math.e
math.phi
math.rphi
is the nominal constant of the gold partition rate. It is equal to 0.6180339887498948
Types const float
See you later
math.e
math.pi
math.phi
This is the first time that the company has been able to make a profit on its own.
Types series float
See you later
strategy.netprofit
strategy.openprofit
strategy.position_size
The 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/hands/units in the transaction.
Types series float
See you later
strategy.position_avg_price
The current market position is the average entry price. If the market position is flat, the NaN position will fall back.
*Explained
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.