miggphl77

TRADING

miggphl77 מעודכן   
Library "TRADING"
This library is a client script for making a webhook signal formatted string to PoABOT server.

entry_message(password, percent, leverage, margin_mode, kis_number)
  Create a entry message for POABOT
  Parameters:
    password (string): (string) The password of your bot.
    percent (float): (float) The percent for entry based on your wallet balance.
    leverage (int): (int) The leverage of entry. If not set, your levereage doesn't change.
    margin_mode (string): (string) The margin mode for trade(only for OKX). "cross" or "isolated"
    kis_number (int): (int) The number of koreainvestment account. Default 1
  Returns: (string) A json formatted string for webhook message.

order_message(password, percent, leverage, margin_mode, kis_number)
  Create a order message for POABOT
  Parameters:
    password (string): (string) The password of your bot.
    percent (float): (float) The percent for entry based on your wallet balance.
    leverage (int): (int) The leverage of entry. If not set, your levereage doesn't change.
    margin_mode (string): (string) The margin mode for trade(only for OKX). "cross" or "isolated"
    kis_number (int): (int) The number of koreainvestment account. Default 1
  Returns: (string) A json formatted string for webhook message.

close_message(password, percent, margin_mode, kis_number)
  Create a close message for POABOT
  Parameters:
    password (string): (string) The password of your bot.
    percent (float): (float) The percent for close based on your wallet balance.
    margin_mode (string): (string) The margin mode for trade(only for OKX). "cross" or "isolated"
    kis_number (int): (int) The number of koreainvestment account. Default 1
  Returns: (string) A json formatted string for webhook message.

exit_message(password, percent, margin_mode, kis_number)
  Create a exit message for POABOT
  Parameters:
    password (string): (string) The password of your bot.
    percent (float): (float) The percent for exit based on your wallet balance.
    margin_mode (string): (string) The margin mode for trade(only for OKX). "cross" or "isolated"
    kis_number (int): (int) The number of koreainvestment account. Default 1
  Returns: (string) A json formatted string for webhook message.

manual_message(password, exchange, base, quote, side, qty, price, percent, leverage, margin_mode, kis_number, order_name)
  Create a manual message for POABOT
  Parameters:
    password (string): (string) The password of your bot.
    exchange (string): (string) The exchange
    base (string): (string) The base
    quote (string): (string) The quote of order message
    side (string): (string) The side of order messsage
    qty (float): (float) The qty of order message
    price (float): (float) The price of order message
    percent (float): (float) The percent for order based on your wallet balance.
    leverage (int): (int) The leverage of entry. If not set, your levereage doesn't change.
    margin_mode (string): (string) The margin mode for trade(only for OKX). "cross" or "isolated"
    kis_number (int): (int) The number of koreainvestment account.
    order_name (string): (string) The name of order message
  Returns: (string) A json formatted string for webhook message.

in_trade(start_time, end_time, hide_trade_line)
  Create a trade start line
  Parameters:
    start_time (int): (int) The start of time.
    end_time (int): (int) The end of time.
    hide_trade_line (bool): (bool) if true, hide trade line. Default false.
  Returns: (bool) Get bool for trade based on time range.

real_qty(qty, precision, leverage, contract_size, default_qty_type, default_qty_value)
  Get exchange specific real qty
  Parameters:
    qty (float): (float) qty
    precision (float): (float) precision
    leverage (int): (int) leverage
    contract_size (float): (float) contract_size
    default_qty_type (string)
    default_qty_value (float)
  Returns: (float) exchange specific qty.

method set(this, password, start_time, end_time, leverage, initial_capital, default_qty_type, default_qty_value, margin_mode, contract_size, kis_number, entry_percent, close_percent, exit_percent, fixed_qty, fixed_cash, real, auto_alert_message, hide_trade_line)
  Set bot object.
  Namespace types: bot
  Parameters:
    this (bot)
    password (string): (string) password for poabot.
    start_time (int): (int) start_time timestamp.
    end_time (int): (int) end_time timestamp.
    leverage (int): (int) leverage.
    initial_capital (float)
    default_qty_type (string)
    default_qty_value (float)
    margin_mode (string): (string) The margin mode for trade(only for OKX). "cross" or "isolated"
    contract_size (float)
    kis_number (int): (int) kis_number for poabot.
    entry_percent (float): (float) entry_percent for poabot.
    close_percent (float): (float) close_percent for poabot.
    exit_percent (float): (float) exit_percent for poabot.
    fixed_qty (float): (float) fixed qty.
    fixed_cash (float): (float) fixed cash.
    real (bool): (bool) convert qty for exchange specific.
    auto_alert_message (bool): (bool) convert alert_message for exchange specific.
    hide_trade_line (bool): (bool) if true, Hide trade line. Default false.
  Returns: (void)

method print(this, message)
  Print message using log table.
  Namespace types: bot
  Parameters:
    this (bot)
    message (string)
  Returns: (void)

method start_trade(this)
  start trade using start_time and end_time
  Namespace types: bot
  Parameters:
    this (bot)
  Returns: (void)

method entry(this, id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, when)
  It is a command to enter market position. If an order with the same ID is already pending, it is possible to modify the order. If there is no order with the specified ID, a new order is placed. To deactivate an entry order, the command strategy.cancel or strategy.cancel_all should be used. In comparison to the function strategy.order, the function strategy.entry is affected by pyramiding and it can reverse market position correctly. If both 'limit' and 'stop' parameters are 'NaN', the order type is market order.
  Namespace types: bot
  Parameters:
    this (bot)
    id (string): (string) A required parameter. The order identifier. It is possible to cancel or modify an order by referencing its identifier.
    direction (string): (string) A required parameter. Market position direction: 'strategy.long' is for long, 'strategy.short' is for short.
    qty (float): (float) An optional parameter. Number of contracts/shares/lots/units to trade. The default value is 'NaN'.
    limit (float): (float) An optional parameter. Limit price of the order. If it is specified, the order type is either 'limit', or 'stop-limit'. 'NaN' should be specified for any other order type.
    stop (float): (float) An optional parameter. Stop price of the order. If it is specified, the order type is either 'stop', or 'stop-limit'. 'NaN' should be specified for any other order type.
    oca_name (string): (string) An optional parameter. Name of the OCA group the order belongs to. If the order should not belong to any particular OCA group, there should be an empty string.
    oca_type (string): (string) An optional parameter. Type of the OCA group. The allowed values are: "strategy.oca.none" - the order should not belong to any particular OCA group; "strategy.oca.cancel" - the order should belong to an OCA group, where as soon as an order is filled, all other orders of the same group are cancelled; "strategy.oca.reduce" - the order should belong to an OCA group, where if X number of contracts of an order is filled, number of contracts for each other order of the same OCA group is decreased by X.
    comment (string): (string) An optional parameter. Additional notes on the order.
    alert_message (string): (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

method order(this, id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, when)
  It is a command to place order. If an order with the same ID is already pending, it is possible to modify the order. If there is no order with the specified ID, a new order is placed. To deactivate order, the command strategy.cancel or strategy.cancel_all should be used. In comparison to the function strategy.entry, the function strategy.order is not affected by pyramiding. If both 'limit' and 'stop' parameters are 'NaN', the order type is market order.
  Namespace types: bot
  Parameters:
    this (bot)
    id (string): (string) A required parameter. The order identifier. It is possible to cancel or modify an order by referencing its identifier.
    direction (string): (string) A required parameter. Market position direction: 'strategy.long' is for long, 'strategy.short' is for short.
    qty (float): (float) An optional parameter. Number of contracts/shares/lots/units to trade. The default value is 'NaN'.
    limit (float): (float) An optional parameter. Limit price of the order. If it is specified, the order type is either 'limit', or 'stop-limit'. 'NaN' should be specified for any other order type.
    stop (float): (float) An optional parameter. Stop price of the order. If it is specified, the order type is either 'stop', or 'stop-limit'. 'NaN' should be specified for any other order type.
    oca_name (string): (string) An optional parameter. Name of the OCA group the order belongs to. If the order should not belong to any particular OCA group, there should be an empty string.
    oca_type (string): (string) An optional parameter. Type of the OCA group. The allowed values are: "strategy.oca.none" - the order should not belong to any particular OCA group; "strategy.oca.cancel" - the order should belong to an OCA group, where as soon as an order is filled, all other orders of the same group are cancelled; "strategy.oca.reduce" - the order should belong to an OCA group, where if X number of contracts of an order is filled, number of contracts for each other order of the same OCA group is decreased by X.
    comment (string): (string) An optional parameter. Additional notes on the order.
    alert_message (string): (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

method close_all(this, comment, alert_message, immediately, when)
  Exits the current market position, making it flat.
  Namespace types: bot
  Parameters:
    this (bot)
    comment (string): (string) An optional parameter. Additional notes on the order.
    alert_message (string): (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
    immediately (bool): (bool) An optional parameter. If true, the closing order will be executed on the tick where it has been placed, ignoring the strategy parameters that restrict the order execution to the open of the next bar. The default is false.
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

method cancel(this, id, when)
  It is a command to cancel/deactivate pending orders by referencing their names, which were generated by the functions: strategy.order, strategy.entry and strategy.exit.
  Namespace types: bot
  Parameters:
    this (bot)
    id (string): (string) A required parameter. The order identifier. It is possible to cancel an order by referencing its identifier.
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

method cancel_all(this, when)
  It is a command to cancel/deactivate all pending orders, which were generated by the functions: strategy.order, strategy.entry and strategy.exit.
  Namespace types: bot
  Parameters:
    this (bot)
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

method close(this, id, comment, qty, qty_percent, alert_message, immediately, when)
  It is a command to exit from the entry with the specified ID. If there were multiple entry orders with the same ID, all of them are exited at once. If there are no open entries with the specified ID by the moment the command is triggered, the command will not come into effect. The command uses market order. Every entry is closed by a separate market order.
  Namespace types: bot
  Parameters:
    this (bot)
    id (string): (string) A required parameter. The order identifier. It is possible to close an order by referencing its identifier.
    comment (string): (string) An optional parameter. Additional notes on the order.
    qty (float): (float) An optional parameter. Number of contracts/shares/lots/units to exit a trade with. The default value is 'NaN'.
    qty_percent (float): (float) Defines the percentage (0-100) of the position to close. Its priority is lower than that of the 'qty' parameter. Optional. The default is 100.
    alert_message (string): (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
    immediately (bool): (bool) An optional parameter. If true, the closing order will be executed on the tick where it has been placed, ignoring the strategy parameters that restrict the order execution to the open of the next bar. The default is false.
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

ticks_to_price(ticks, from)
  Converts ticks to a price offset from the supplied price or the average entry price.
  Parameters:
    ticks (float): (float) Ticks to convert to a price.
    from (float): (float) A price that can be used to calculate from. Optional. The default value is `strategy.position_avg_price`.
  Returns: (float) A price level that has a distance from the entry price equal to the specified number of ticks.

method exit(this, id, from_entry, qty, qty_percent, profit, limit, loss, stop, trail_price, trail_points, trail_offset, oca_name, comment, comment_profit, comment_loss, comment_trailing, alert_message, alert_profit, alert_loss, alert_trailing, when)
  It is a command to exit either a specific entry, or whole market position. If an order with the same ID is already pending, it is possible to modify the order. If an entry order was not filled, but an exit order is generated, the exit order will wait till entry order is filled and then the exit order is placed. To deactivate an exit order, the command strategy.cancel or strategy.cancel_all should be used. If the function strategy.exit is called once, it exits a position only once. If you want to exit multiple times, the command strategy.exit should be called multiple times. If you use a stop loss and a trailing stop, their order type is 'stop', so only one of them is placed (the one that is supposed to be filled first). If all the following parameters 'profit', 'limit', 'loss', 'stop', 'trail_points', 'trail_offset' are 'NaN', the command will fail. To use market order to exit, the command strategy.close or strategy.close_all should be used.
  Namespace types: bot
  Parameters:
    this (bot)
    id (string): (string) A required parameter. The order identifier. It is possible to cancel or modify an order by referencing its identifier.
    from_entry (string): (string) An optional parameter. The identifier of a specific entry order to exit from it. To exit all entries an empty string should be used. The default values is empty string.
    qty (float): (float) An optional parameter. Number of contracts/shares/lots/units to exit a trade with. The default value is 'NaN'.
    qty_percent (float): (float) Defines the percentage of (0-100) the position to close. Its priority is lower than that of the 'qty' parameter. Optional. The default is 100.
    profit (float): (float) An optional parameter. Profit target (specified in ticks). If it is specified, a limit order is placed to exit market position when the specified amount of profit (in ticks) is reached. The default value is 'NaN'.
    limit (float): (float) An optional parameter. Profit target (requires a specific price). If it is specified, a limit order is placed to exit market position at the specified price (or better). Priority of the parameter 'limit' is higher than priority of the parameter 'profit' ('limit' is used instead of 'profit', if its value is not 'NaN'). The default value is 'NaN'.
    loss (float): (float) An optional parameter. Stop loss (specified in ticks). If it is specified, a stop order is placed to exit market position when the specified amount of loss (in ticks) is reached. The default value is 'NaN'.
    stop (float): (float) An optional parameter. Stop loss (requires a specific price). If it is specified, a stop order is placed to exit market position at the specified price (or worse). Priority of the parameter 'stop' is higher than priority of the parameter 'loss' ('stop' is used instead of 'loss', if its value is not 'NaN'). The default value is 'NaN'.
    trail_price (float): (float) An optional parameter. Trailing stop activation level (requires a specific price). If it is specified, a trailing stop order will be placed when the specified price level is reached. The offset (in ticks) to determine initial price of the trailing stop order is specified in the 'trail_offset' parameter: X ticks lower than activation level to exit long position; X ticks higher than activation level to exit short position. The default value is 'NaN'.
    trail_points (float): (float) An optional parameter. Trailing stop activation level (profit specified in ticks). If it is specified, a trailing stop order will be placed when the calculated price level (specified amount of profit) is reached. The offset (in ticks) to determine initial price of the trailing stop order is specified in the 'trail_offset' parameter: X ticks lower than activation level to exit long position; X ticks higher than activation level to exit short position. The default value is 'NaN'.
    trail_offset (float): (float) An optional parameter. Trailing stop price (specified in ticks). The offset in ticks to determine initial price of the trailing stop order: X ticks lower than 'trail_price' or 'trail_points' to exit long position; X ticks higher than 'trail_price' or 'trail_points' to exit short position. The default value is 'NaN'.
    oca_name (string): (string) An optional parameter. Name of the OCA group (oca_type = strategy.oca.reduce) the profit target, the stop loss / the trailing stop orders belong to. If the name is not specified, it will be generated automatically.
    comment (string): (string) Additional notes on the order. If specified, displays near the order marker on the chart. Optional. The default is na.
    comment_profit (string): (string) Additional notes on the order if the exit was triggered by crossing `profit` or `limit` specifically. If specified, supercedes the `comment` parameter and displays near the order marker on the chart. Optional. The default is na.
    comment_loss (string): (string) Additional notes on the order if the exit was triggered by crossing `stop` or `loss` specifically. If specified, supercedes the `comment` parameter and displays near the order marker on the chart. Optional. The default is na.
    comment_trailing (string): (string) Additional notes on the order if the exit was triggered by crossing `trail_offset` specifically. If specified, supercedes the `comment` parameter and displays near the order marker on the chart. Optional. The default is na.
    alert_message (string): (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Optional. The default is na.
    alert_profit (string): (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Only replaces the text if the exit was triggered by crossing `profit` or `limit` specifically. Optional. The default is na.
    alert_loss (string): (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Only replaces the text if the exit was triggered by crossing `stop` or `loss` specifically. Optional. The default is na.
    alert_trailing (string): (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Only replaces the text if the exit was triggered by crossing `trail_offset` specifically. Optional. The default is na.
    when (bool): (bool) An optional parmeter. Condition, deprecated.
  Returns: (void)

percent_to_ticks(percent, from)
  Converts a percentage of the supplied price or the average entry price to ticks.
  Parameters:
    percent (float): (float) The percentage of supplied price to convert to ticks. 50 is 50% of the entry price.
    from (float): (float) A price that can be used to calculate from. Optional. The default value is `strategy.position_avg_price`.
  Returns: (float) A value in ticks.

percent_to_price(percent, from)
  Converts a percentage of the supplied price or the average entry price to a price.
  Parameters:
    percent (float): (float) The percentage of the supplied price to convert to price. 50 is 50% of the supplied price.
    from (float): (float) A price that can be used to calculate from. Optional. The default value is `strategy.position_avg_price`.
  Returns: (float) A value in the symbol's quote currency (USD for BTCUSD).

bot
  Fields:
    password (series__string)
    start_time (series__integer)
    end_time (series__integer)
    leverage (series__integer)
    initial_capital (series__float)
    default_qty_type (series__string)
    default_qty_value (series__float)
    margin_mode (series__string)
    contract_size (series__float)
    kis_number (series__integer)
    entry_percent (series__float)
    close_percent (series__float)
    exit_percent (series__float)
    log_table (series__table)
    fixed_qty (series__float)
    fixed_cash (series__float)
    real (series__bool)
    auto_alert_message (series__bool)
    hide_trade_line (series__bool)
הערות שחרור:
v2
הערות שחרור:
v3
הערות שחרור:
v4
ספריית Pine

ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומים אחרים בקוד פתוח, אך השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בספרייה זו?

העתק את השורה הבאה והדבק אותה בסקריפט שלך.