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 Bibliothek

In echter TradingView-Manier hat der Autor diesen Pine-Code als Open-Source-Bibliothek veröffentlicht, so dass andere Pine-Programmierer aus unserer Community ihn weiterverwenden können. Ein Hoch auf den Autor! Sie können diese Bibliothek privat oder in anderen Open-Source-Publikationen verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.

Möchten Sie diese Bibliothek nutzen?

Kopieren Sie die folgende Zeile und fügen Sie sie in Ihr Skript ein.