PINE LIBRARY
更新済 AdaptivePNL

Library "Adaptive Profit And Loss"
Provide Take profit and Stop loss values depending on source.
TakeProfitPriceTypes()
Provides supported Take profit sources
Returns: Supported Take profit sources
StopLossPriceTypes()
Provides supported Take profit sources
Returns: Supported Take profit sources
Price(type)
Get price value by selected price type
Parameters:
type (string): price type from @TakeProfitPriceTypes() or @StopLossPriceTypes()
Returns: Required price value.
LinearProfit(initPerc, stepPerc)
Lineary changed profit
Parameters:
initPerc (float): Initial profit value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
Returns: Profit value lineary increased/decreased since last entry. If there is no opened trade, value is NaN
AdaptedProfit(initPerc, stepPerc, source)
Profit adapted to lowest/highest value of given source and lineary changes after it
Parameters:
initPerc (float): Initial profit value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
source (float): Source according to is profit adapted. If it reach high, profit is increased for long positions, same for low and short positions.
Returns: Profit value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
LinearStopLoss(initPerc, stepPerc)
Lineary changed stop loss
Parameters:
initPerc (float): Initial stop loss value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
Returns: Stop loss value lineary increased/decreased since last entry. If there is no opened trade, value is NaN
AdaptedStopLoss(initPerc, stepPerc, source)
Stop loss adapted to highest/lowest value of given source and lineary changes after it
Parameters:
initPerc (float): Initial stop loss value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
source (float): Source according to is stop loss adapted. If it reach high, stop loss is increased for long positions, same for low and short positions.
Returns: Stop loss value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
Provide Take profit and Stop loss values depending on source.
TakeProfitPriceTypes()
Provides supported Take profit sources
Returns: Supported Take profit sources
StopLossPriceTypes()
Provides supported Take profit sources
Returns: Supported Take profit sources
Price(type)
Get price value by selected price type
Parameters:
type (string): price type from @TakeProfitPriceTypes() or @StopLossPriceTypes()
Returns: Required price value.
LinearProfit(initPerc, stepPerc)
Lineary changed profit
Parameters:
initPerc (float): Initial profit value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
Returns: Profit value lineary increased/decreased since last entry. If there is no opened trade, value is NaN
AdaptedProfit(initPerc, stepPerc, source)
Profit adapted to lowest/highest value of given source and lineary changes after it
Parameters:
initPerc (float): Initial profit value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
source (float): Source according to is profit adapted. If it reach high, profit is increased for long positions, same for low and short positions.
Returns: Profit value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
LinearStopLoss(initPerc, stepPerc)
Lineary changed stop loss
Parameters:
initPerc (float): Initial stop loss value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
Returns: Stop loss value lineary increased/decreased since last entry. If there is no opened trade, value is NaN
AdaptedStopLoss(initPerc, stepPerc, source)
Stop loss adapted to highest/lowest value of given source and lineary changes after it
Parameters:
initPerc (float): Initial stop loss value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
source (float): Source according to is stop loss adapted. If it reach high, stop loss is increased for long positions, same for low and short positions.
Returns: Stop loss value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
リリースノート
v2Added:
TakeProfit(initPerc, stepPerc, source)
Profit adapted to lowest/highest value of given source and lineary changes after it
Parameters:
initPerc (float): Initial profit value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
source (float): Source according to is profit adapted. If it reach high, profit is increased for long positions, same for lowest price and short positions.
Returns: Profit value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
StopLoss(initPerc, stepPerc, source)
Stop loss adapted to highest/lowest value of given source and lineary changes after it
Parameters:
initPerc (float): Initial stop loss value in percent unit
stepPerc (float): Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
source (float): Source according to is stop loss adapted. If it reach high, stop loss is increased for long positions, same for low and short positions.
Returns: Stop loss value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
Removed:
LinearProfit(initPerc, stepPerc)
Lineary changed profit
AdaptedProfit(initPerc, stepPerc, source)
Profit adapted to lowest/highest value of given source and lineary changes after it
LinearStopLoss(initPerc, stepPerc)
Lineary changed stop loss
AdaptedStopLoss(initPerc, stepPerc, source)
Stop loss adapted to highest/lowest value of given source and lineary changes after it
リリースノート
v3Updated:
TakeProfit(initPerc, stepPerc, source)
Profit adapted to lowest/highest value of given source and lineary changes after it
Parameters:
initPerc (simple float): Initial profit value in percent unit
stepPerc (simple float): Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
source (float): Source according to is profit adapted. If it reach high, profit is increased for long positions, same for lowest price and short positions.
Returns: Profit value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
StopLoss(initPerc, stepPerc, source)
Stop loss adapted to highest/lowest value of given source and lineary changes after it
Parameters:
initPerc (simple float): Initial stop loss value in percent unit
stepPerc (simple float): Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
source (float): Source according to is stop loss adapted. If it reach high, stop loss is increased for long positions, same for low and short positions.
Returns: Stop loss value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
Removed:
TakeProfitPriceTypes()
Provides supported Take profit sources
StopLossPriceTypes()
Provides supported Take profit sources
リリースノート
v4Added:
TruncateQuantity(price, digits)
Truncate quantity to required number of digits. It's truncate, not round, it simply zeroes digits after required amount. Truncate did not exceeds amount.
Parameters:
price (float): Price at which position is opened. Close price for market orders or stop price for stop limit orders.
digits (int): Number of digits.
Returns: Quantity truncate
PriceToPips(price)
Concerts given price to number of pips. Useful for parameters which reauires pips count, e.g. Convert relative price like `price * offset_percent / 100` to trail_offset.
Parameters:
price (float): Price will be converted to number of pips.
Returns: Number of pips which represents given price.
リリースノート
v5Updated:
Price(type, relativePrice, atrLen)
Get price value by selected price type
Parameters:
type (string): price type from @TakeProfitPriceTypes() or @StopLossPriceTypes()
relativePrice (float): price to which is added/substracted ATR value
atrLen (simple int): ATR length
Returns: Requested price value
Pineライブラリ
TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティ内の他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
Pineライブラリ
TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティ内の他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。