PINE LIBRARY
Updated ToolsPos

Library "ToolsPos"
Library for general purpose position helpers
new_pos(state, price, when, index)
Returns new PosInfo object
Parameters:
state (series PosState): <PosState> Position state
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
Returns: PosInfo
new_tp(pos, price, when, index, info)
Returns PosInfo object with new take profit info object
Parameters:
pos (PosInfo): PosInfo object
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object. Default: na
Returns: PosInfo
new_re(pos, price, when, index, info)
Returns PosInfo object with new re-entry info object
Parameters:
pos (PosInfo): PosInfo object
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object. Default: na
Returns: PosInfo
PosTPInfo
PosTPInfo - Position Take Profit info object
Fields:
price (series float): float Take profit price
when (series int): int Take profit bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object
PosREInfo
PosREInfo - Position Re-Entry info object
Fields:
price (series float): float Re-entry price
when (series int): int Re-entry bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state
price (series float): float Entry price
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosTPInfo>): PosTPInfo[] Take profit info. Default: na
re (array<PosREInfo>): PosREInfo[] Re-entry info. Default: na
info (Info type from aybarsm/Tools/14): <Info> Info holder object
Library for general purpose position helpers
new_pos(state, price, when, index)
Returns new PosInfo object
Parameters:
state (series PosState): <PosState> Position state
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
Returns: PosInfo
new_tp(pos, price, when, index, info)
Returns PosInfo object with new take profit info object
Parameters:
pos (PosInfo): PosInfo object
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object. Default: na
Returns: PosInfo
new_re(pos, price, when, index, info)
Returns PosInfo object with new re-entry info object
Parameters:
pos (PosInfo): PosInfo object
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object. Default: na
Returns: PosInfo
PosTPInfo
PosTPInfo - Position Take Profit info object
Fields:
price (series float): float Take profit price
when (series int): int Take profit bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object
PosREInfo
PosREInfo - Position Re-Entry info object
Fields:
price (series float): float Re-entry price
when (series int): int Re-entry bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Info type from aybarsm/Tools/14): <Info> Info holder object
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state
price (series float): float Entry price
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosTPInfo>): PosTPInfo[] Take profit info. Default: na
re (array<PosREInfo>): PosREInfo[] Re-entry info. Default: na
info (Info type from aybarsm/Tools/14): <Info> Info holder object
Release Notes
v2Added:
method enter(this, state, price, when, index, info)
modifies PosInfo object for new position entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
state (series PosState): <PosState> Position state
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/3): <Fluent> Info holder fluent object. Default: na
method action(this, type, price, when, index, info)
modifies PosInfo object for action take-profit/re-entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
type (series PosActionType): <PosActionType> Pos ActionType
price (float): float Action price
when (int): int Action bar time UNIX. Default: time
index (int): int Action bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/3): <Fluent> Info holder fluent object. Default: na
PosAction
PosTPInfo - Position Take Profit info object
Fields:
type (series PosActionType)
price (series float): float Take profit price
when (series int): int Take profit bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/3)
Updated:
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state
price (series float): float Entry price
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosAction>): PosAction[] Take profit info. Default: na
re (array<PosAction>): PosAction[] Re-entry info. Default: na
info (Fluent type from aybarsm/ToolsFluent/3): <Fluent> Info holder fluent object. Default: na
Removed:
new_pos(state, price, when, index)
Returns new PosInfo object
new_tp(pos, price, when, index, info)
Returns PosInfo object with new take profit info object
new_re(pos, price, when, index, info)
Returns PosInfo object with new re-entry info object
PosTPInfo
PosTPInfo - Position Take Profit info object
PosREInfo
PosREInfo - Position Re-Entry info object
Release Notes
v3Updated:
method action(this, actionType, price, when, index, info)
modifies PosInfo object for action take-profit/re-entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
actionType (series PosActionType)
price (float): float Action price
when (int): int Action bar time UNIX. Default: time
index (int): int Action bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/3): <Fluent> Info holder fluent object. Default: na
Release Notes
v4Updated:
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state. Default: na
price (series float): float Entry price. Default: na
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosAction>): PosAction[] Take profit info. Default: na
re (array<PosAction>): PosAction[] Re-entry info. Default: na
info (Fluent type from aybarsm/ToolsFluent/3): <Fluent> Info holder fluent object. Default: na
Release Notes
v5Release Notes
v6Updated:
method enter(this, state, price, when, index, info)
modifies PosInfo object for new position entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
state (series PosState): <PosState> Position state
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/4): <Fluent> Info holder fluent object. Default: na
method action(this, actionType, price, when, index, info)
modifies PosInfo object for action take-profit/re-entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
actionType (series PosActionType)
price (float): float Action price
when (int): int Action bar time UNIX. Default: time
index (int): int Action bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/4): <Fluent> Info holder fluent object. Default: na
PosAction
PosTPInfo - Position Take Profit info object
Fields:
type (series PosActionType)
price (series float): float Take profit price
when (series int): int Take profit bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/4)
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state. Default: na
price (series float): float Entry price. Default: na
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosAction>): PosAction[] Take profit info. Default: na
re (array<PosAction>): PosAction[] Re-entry info. Default: na
info (Fluent type from aybarsm/ToolsFluent/4): <Fluent> Info holder fluent object. Default: na
Release Notes
v7Updated:
method enter(this, state, price, when, index, info)
modifies PosInfo object for new position entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
state (series PosState): <PosState> Position state
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/6): <Fluent> Info holder fluent object. Default: na
method action(this, actionType, price, when, index, info)
modifies PosInfo object for action take-profit/re-entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
actionType (series PosActionType)
price (float): float Action price
when (int): int Action bar time UNIX. Default: time
index (int): int Action bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/6): <Fluent> Info holder fluent object. Default: na
PosAction
PosTPInfo - Position Take Profit info object
Fields:
type (series PosActionType)
price (series float): float Take profit price
when (series int): int Take profit bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/6)
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state. Default: na
price (series float): float Entry price. Default: na
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosAction>): PosAction[] Take profit info. Default: na
re (array<PosAction>): PosAction[] Re-entry info. Default: na
info (Fluent type from aybarsm/ToolsFluent/6): <Fluent> Info holder fluent object. Default: na
Release Notes
v8Updated:
PosAction
PosTPInfo - Position Take Profit info object
Fields:
actionType (series PosActionType)
price (series float): float Take profit price
when (series int): int Take profit bar time UNIX. Default: time
index (series int): int Take profit bar index. Default: bar_index
info (Fluent type from aybarsm/ToolsFluent/6)
Release Notes
v9Updated:
method enter(this, state, price, when, index, markPrice, markWhen, markIndex)
modifies PosInfo object for new position entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
state (series PosState): <PosState> Position state
price (float): float Entry price
when (int): int Entry bar time UNIX. Default: time
index (int): int Entry bar index. Default: bar_index
markPrice (float): float Mark price. Default: na
markWhen (int): int Mark bar time UNIX. Default: na
markIndex (int): int Mark bar index. Default: na
method action(this, actionType, price, when, index, markPrice, markWhen, markIndex)
modifies PosInfo object for action take-profit/re-entry
Namespace types: PosInfo
Parameters:
this (PosInfo)
actionType (series PosActionType)
price (float): float Action price
when (int): int Action bar time UNIX. Default: time
index (int): int Action bar index. Default: bar_index
markPrice (float): float Mark price. Default: na
markWhen (int): int Mark bar time UNIX. Default: na
markIndex (int): int Mark bar index. Default: na
PosAction
PosTPInfo - Position Action info object
Fields:
actionType (series PosActionType)
price (series float): float Action price
when (series int): int Action bar time UNIX. Default: time
index (series int): int Action bar index. Default: bar_index
markPrice (series float): float Action mark price. Default: na
markWhen (series int): int Action mark bar time UNIX. Default: na
markIndex (series int): int Action mark bar index. Default: na
PosInfo
PosInfo - Position info object
Fields:
state (series PosState): <PosState> Position state. Default: na
price (series float): float Entry price. Default: na
when (series int): int Entry bar time UNIX. Default: time
index (series int): int Entry bar index. Default: bar_index
tp (array<PosAction>): PosAction[] Take profit info. Default: na
re (array<PosAction>): PosAction[] Re-entry info. Default: na
markPrice (series float): float Mark price. Default: na
markWhen (series int): int Mark bar time UNIX. Default: na
markIndex (series int): int Mark bar index. Default: na
Release Notes
v10Added:
method reset(this)
resets PosInfo object exit
Namespace types: PosInfo
Parameters:
this (PosInfo)
method exit(this)
resets PosInfo object exit
Namespace types: PosInfo
Parameters:
this (PosInfo)
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.