djmad

Position_control

Library "Position_control"
This is a library for defining positions and working with them.

f_calculateLeverage(_Leverage, _maintenance, _value, _direction)
  Calculate the leverage used in a trade.
@description This function calculates the leverage used in a trade, based on the value of the trade, the maintenance margin, and the direction of the trade.
  Parameters:
    _Leverage (float): The leverage used in the trade, as a floating point number.
    _maintenance (float): The maintenance margin percentage, as a floating point number.
    _value (float): The value of the trade, as a floating point number.
    _direction (string): The direction of the trade, either "long" or "short".
  Returns: The leverage used in the trade, as a floating point number.

f_calculate_PL(_Position, _max_TP, _Position_index, _show_profit, _i_decimals_contracts, _i_decimals_prercent)
  Calculate the profit or loss for a given trade.
@description This function calculates the profit or loss for a given trade, based on the position type, maximum take profit, position index, and whether to show the profit as a percentage or a value.
  Parameters:
    _Position (t_Position_type): An array of position types for the trade.
    _max_TP (int): The maximum take profit for the trade, as an integer value.
    _Position_index (int): The index of the position in the array, as an integer value.
    _show_profit (bool): A boolean value indicating whether to show the profit as a percentage or a value.
    _i_decimals_contracts (int)
    _i_decimals_prercent (int)
  Returns: The profit or loss for the trade, as a floating point number.

f_drawposition(_Position, _Parameters, _Position_index)
  draws a position on the chart
@description via sending in a typo of Position this function is able to drawout Stoploss, Entrybox, Takeprofits and the required labels with information
  Parameters:
    _Position (t_Position_type): array of type t_Position_type containing the position information.
    _Parameters (t_drawing_parameters)
    _Position_index (int): the index of the current position.
  Returns: None but boxes / lines / labels on the chart itself

t_TP_Variant
  Fields:
    TP_Type (series__string)
    TP_Parameter_1 (series__integer)
    TP_Parameter_2 (series__integer)
    TP_Parameter_3 (series__float)
    TP_Parameter_4 (series__float)

t_TPs
  Fields:
    TP_Price (series__float)
    TP_Lot (series__float)
    TP_Variant (|t_TP_Variant|#OBJ)
    TP_Active (series__bool)

t_SLs
  Fields:
    SL_Price (series__float)
    SL_Lot (series__float)
    SL_Active (series__bool)

t_Position_type
  Fields:
    Lot (series__float)
    Leverage (series__float)
    Maintenance (series__float)
    Starttime (series__integer)
    Entry_Start (series__float)
    Stoptime (series__integer)
    Entry_Stop (series__float)
    Entryprice (series__float)
    TPs (array__|t_TPs|#OBJ)
    SLs (array__|t_SLs|#OBJ)

t_drawing_parameters
  Fields:
    ShowPos (series__bool)
    ShowLIQ (series__bool)
    A_Colors (array__color)
    Prolong_lines (series__bool)
    Str_fontsize (series__string)
    Textshift (series__integer)
    Decimals_contracts (series__integer)
    Decimals_price (series__integer)
    Decimals_percent (series__integer)
    bartime (series__integer)

Trader & coder. TA & NFTs.
bitblockwizard.com more at bitblockart.com
Pine脚本库

本着真正的TradingView精神,作者将此Pine代码以开源脚本库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码受网站规则约束。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想使用这个脚本库吗?

复制以下行并将其粘贴到您的脚本中。