The average price in FMZ PINE Script is the price that includes the handling fee. For example: the price of the order is 8000, the direction of sale, the number of hands (one), the average price after the transaction is not 8000, less than 8000 (including the handling fee in the cost).
Types series float
See you later
strategy.position_size
I'm going to go with you.
Types strategy_direction
See you later
strategy.entry
strategy.exit
The head is empty.
Types strategy_direction
See you later
strategy.entry
strategy.exit
The number of transactions closed in the entire trading interval.
Types series int
See you later
strategy.position_size
strategy.opentrades
The number of transactions that have not been closed or continue to be held. If not, 0 is shown.
Types series int
See you later
strategy.position_size
The total monetary value of all completed transactions.
Types series float
See you later
strategy.openprofit
strategy.position_size
strategy.grossprofit
The total monetary value of all winning trades completed.
Types series float
See you later
strategy.netprofit
Unrealized losses on positions that are not currently closed.
Types series float
See you later
strategy.netprofit
strategy.position_size
The only strategy is to do more.
Types const string
See you later
strategy.risk.allow_entry_in
The only strategy is to do nothing.
Types const string
See you later
strategy.risk.allow_entry_in
Allowing strategies that can do more and do less
Types const string
See you later
strategy.risk.allow_entry_in
The week of the current k-line time in the time zone switched.
Types series int
NotesNote that this variable returns the day 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 1 lower than the day of the trading day. You can use the variables dayofweek.sunday, dayofweek.monday, dayofweek.tuesday, dayofweek.wednesday, dayofweek.thursday, dayofweek.friday and dayofweek.saturday to compare.
See you later
time
dayofmonth
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.monday
dayofweek.tuesday
dayofweek.wednesday
dayofweek.thursday
dayofweek.friday
dayofweek.saturday
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.sunday
dayofweek.tuesday
dayofweek.wednesday
dayofweek.thursday
dayofweek.friday
dayofweek.saturday
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.sunday
dayofweek.monday
dayofweek.wednesday
dayofweek.thursday
dayofweek.friday
dayofweek.saturday
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.sunday
dayofweek.monday
dayofweek.tuesday
dayofweek.thursday
dayofweek.friday
dayofweek.saturday
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.sunday
dayofweek.monday
dayofweek.tuesday
dayofweek.wednesday
dayofweek.friday
dayofweek.saturday
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.sunday
dayofweek.monday
dayofweek.tuesday
dayofweek.wednesday
dayofweek.thursday
dayofweek.saturday
is the name constant for the return value of the dayofweek function and the value of the dayofweek variable.
Types const int
See you later
dayofweek.sunday
dayofweek.monday
dayofweek.tuesday
dayofweek.wednesday
dayofweek.thursday
dayofweek.friday
is the named constant of the Hline-style dotted line.
Types hline_style
See you later
hline.style_solid
hline.style_dotted
hline.style_dotted
is the named constant of the point-value-line style of the Hline function.
Types hline_style
See you later
hline.style_solid
hline.style_dashed
is the name constant of the real-line type of the Hline function.
Types hline_style
See you later
hline.style_dotted
hline.style_dashed
Combine the data with the possible gap (na value) for the requested data.
Types barmerge_gaps
See you later
request.security
barmerge.gaps_off
The strategy of merging the requested data. The data is merged continuously, with all gaps filled with the previous most recent available value.
Types barmerge_gaps
See you later
request.security
barmerge.gaps_on
Combine the requested data location policy. Combine the requested bar graph with the current bar graph according to the k-line start time. This combination policy may have adverse effects on the history of data computation from the future bar. This is not accepted in regression testing policies, but can be used in indicators.
Types barmerge_lookahead
See you later
request.security
barmerge.lookahead_off
The policy of merging the requested data location. The policy of merging the requested bar chart with the current bar chart according to the time of closing of the k-line. This merging policy prohibits the impact of obtaining the data computation history from the future bar.
Types barmerge_lookahead
See you later
request.security
barmerge.lookahead_on
is the shortcut for ((highest price + lowest price) /2)
Types series float
See you later
open
high
low
close
volume
time
hlc3
hlcc4
ohlc4
is the shortcut for ((highest price + lowest price + closing price) /3)
Types series float
See you later
open
high
low
close
volume
time
hl2
hlcc4
ohlc4
is the shortcut for ((high + low + receive + receive) /4)
Types series float
See you later
open
high
low
close
volume
time
hl2
hlc3
ohlc4
is the shortcut for ((Opening price + Highest price + Lowest price + Closing price) /4)
Types series float
See you later
open
high
low
close
volume
time
hl2
hlc3
hlcc4
Double.NaN is a value (non-numerical).
Types simple na
Examples
// na
plot(bar_index < 10 ? na : close) // CORRECT
plot(close == na ? close[1] : close) // INCORRECT!
plot(na(close) ? close[1] : close) // CORRECT
NotesUse only the return value. Do not try to compare with it. If you want to check whether some values are NaN, use the built-in function na.
See you later
na
The current price bar index is numbered from zero, with the index of the first item being 0.
Types series int
Examples
// bar_index
plot(bar_index)
plot(bar_index > 5000 ? close : 0)
NotesPlease note that bar_index has replaced n variables in version 4. Note that the index of K strings is 0 from the first historical K string. Please note that using this variable/function may result in a redrawing of the indicator.
See you later
barstate.isfirst
barstate.islast
barstate.isrealtime
The index of the last K-line of the graph. The index of the K-line begins with the first K-line at zero.
Types series int
Examples
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 the valueThe last historical K-string index of the close, or the real-time K-string index of the open.
NotesPlease note that using this variable may cause the indicator to be redrawn.
See you later
bar_index
last_bar_time
barstate.ishistory
barstate.isrealtime
The current k-line time in the UNIX format. This is the number of milliseconds since 00:00:00 UTC on January 1, 1970.
The current time in the UNIX format. This is the number of milliseconds since 00:00:00 UTC on January 1, 1970.
Types series int
NotesPlease note that using this variable/function may result in a redrawing of the indicator.
See you later
timestamp
time
dayofmonth
dayofweek
Types series int
NotesNote that this variable will return a time frame based on the opening time of the K line. Thus, for overnight trading periods (e.g. EURUSD, whose Monday timeframe starts at 17:00 on Sunday), this variable can return the time before the specified date of the trading day. For example, on EURUSD, the time frame for the day of the month can be 1 lower than the date of the trading day because the K line for the current date was actually open the day before.
See you later
time
dayofmonth
dayofweek
The current year k-line of the time zone switched.
Types series int
NotesNote that this variable returns the year 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 1 lower than the year of the trading day.
See you later
year
time
month
weekofyear
dayofmonth
dayofweek
hour
minute
second
The current month k-line in the exchange time zone.
Types series int
NotesNote that this variable returns the month 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 1 lower than the month of the trading day.
See you later
month
time
year
weekofyear
dayofmonth
dayofweek
hour
minute
second
The current time k-line in the exchange's time zone.
Types series int
See you later
hour
time
year
month
weekofyear
dayofmonth
dayofweek
minute
second
The current minute k line in the exchange time zone.
Types series int
See you later
minute
time
year
month
weekofyear
dayofmonth
dayofweek
hour
second
The current k-second line in the exchange's time zone.
Types series int
See you later
second
time
year
month
weekofyear
dayofmonth
dayofweek
hour
minute
The current opening price.
Types series float
NotesThe parenthesized operator [] can be used to access previous values, for example; open[1], open[2]。
See you later
high
low
close
volume
time
hl2
hlc3
hlcc4
ohlc4
This is the highest price ever paid.
Types series float
NotesThe parenthesized operator [] can be used to access previous values, e.g.↑ high[1], high[2]↑
See you later
open
low
close
volume
time
hl2
hlc3
hlcc4
ohlc4
This is the lowest price ever.
Types series float
NotesThe parenthesized operator [] can be used to access previous values, e.g.↑ low[1], low[2]↑
See you later
open
high
close
volume
time
hl2
hlc3
hlcc4
ohlc4
The closing price of the current K line at the time of closing, or the final trading price of the real-time K line that has not yet been completed.
Types series float
NotesThe parenthesized operator [] can be used to access previous values, e.g.↑ close[1], close[2]↑
See you later
open
high
low
volume
time
hl2
hlc3
hlcc4
ohlc4
Currently, K-Line is fully operational.
Types series float
NotesThe parenthesized operator [] can be used to access previous values, e.g.↑ volume[1], volume[2]↑
See you later
open
high
low
close
time
hl2
hlc3
hlcc4
ohlc4
The number of weeks in the current k-line time period of the switching time zone.
Types series int
NotesNote that this variable returns 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
The date of the current k-line time in the time zone.
Types series int
NotesNote that this variable returns the day based on the opening time of the K line. For overnight trading hours (for example, EURUSD, whose Monday trading hours start at 17:00 on Sunday), this value can be lower than the day of the trading day.
See you later
time
dayofweek
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.