PINE LIBRARY

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)
statistics

Libreria Pine

In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Un saluto all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.


djmad|Bitblockart

Declinazione di responsabilità