PINE LIBRARY

OrderLib

ที่อัปเดต:
Library "OrderLib"
TODO: add library description here

removeOrderView(view)
  Parameters:
    view (orderView)

createOrderView(model, length, profit_color, loss_color, enter_color)
  Parameters:
    model (orderModel)
    length (simple int)
    profit_color (simple color)
    loss_color (simple color)
    enter_color (simple color)

createOrder(enter, tp, sl)
  Parameters:
    enter (float)
    tp (float)
    sl (float)

createOrderByRR(enter, sl, rr)
  Parameters:
    enter (float)
    sl (float)
    rr (float)

createOrderByRR(enter, sl, rr, commision_percent)
  Parameters:
    enter (float)
    sl (float)
    rr (simple float)
    commision_percent (simple float)

orderModel
  Fields:
    enter (series__float)
    sl (series__float)
    tp (series__float)

orderView
  Fields:
    enter (series__line)
    sl (series__line)
    tp (series__line)
เอกสารเผยแพร่
v2

Обновлено:
createOrder(enter, sl, tp)
  Parameters:
    enter (float)
    sl (float)
    tp (float)
เอกสารเผยแพร่
v3
เอกสารเผยแพร่
v4

Добавлено:
updateOrderView(src, topPrice, bottomPrice, removeCompleted)
  Parameters:
    src (orderView)
    topPrice (float)
    bottomPrice (float)
    removeCompleted (bool)

Обновлено:
createOrderView(src, profit_color, loss_color, enter_color)
  Parameters:
    src (orderModel)
    profit_color (simple color)
    loss_color (simple color)
    enter_color (simple color)

removeOrderView(src)
  Parameters:
    src (orderView)
เอกสารเผยแพร่
v5

Добавлено:
updateOrderViews(views, topPrice, bottomPrice, removeCompleted)
  Parameters:
    views (orderView[])
    topPrice (float)
    bottomPrice (float)
    removeCompleted (bool)
เอกสารเผยแพร่
v6

Добавлено:
repaintView(views, remove_completed)
  Parameters:
    views (orderView[])
    remove_completed (bool)

updateOrderState(model, top_price, bottom_price)
  Parameters:
    model (orderModel)
    top_price (float)
    bottom_price (float)

updateOrderStates(orders, top_price, bottom_price, remove_completed)
  Parameters:
    orders (orderModel[])
    top_price (float)
    bottom_price (float)
    remove_completed (bool)

configureEnterPoint(src, price, amount, amount_usd)
  Parameters:
    src (orderModel)
    price (float)
    amount (float)
    amount_usd (float)

configureStopLoss(src, price, offset, max_loss)
  Parameters:
    src (orderModel)
    price (float)
    offset (float)
    max_loss (float)

addTakeProfit(src, piece, price, rr)
  Parameters:
    src (orderModel)
    piece (float)
    price (float)
    rr (float)

configureBreakeven(src, target_offset)
  Parameters:
    src (orderModel)
    target_offset (float)

configureTrailingStop(src, trigger_offset, lag_offset)
  Parameters:
    src (orderModel)
    trigger_offset (float)
    lag_offset (float)

orderPointModel
  Fields:
    price (series__float)
    offset (series__float)
    amount (series__float)
    amount_usd (series__float)
    order_piece (series__float)
    income (series__float)
    is_completed (series__bool)
    completed_bar_index (series__integer)

breakevenModel
  Fields:
    price (series__float)
    offset (series__float)
    target_price (series__float)
    target_offset (series__float)
    is_completed (series__bool)
    completed_bar_index (series__integer)

trailingStopModel
  Fields:
    price (series__float)
    offset (series__float)
    lag_offset (series__float)

enterPointModel
  Fields:
    price (series__float)
    amount (series__float)
    amount_usd (series__float)

Обновлено:
createOrder(ticker, side, enter, max_amount_usd, sl, rr, max_loss, leverage)
  Parameters:
    ticker (string)
    side (int)
    enter (float)
    max_amount_usd (float)
    sl (float)
    rr (float)
    max_loss (float)
    leverage (int)

Удалено:
updateOrderView(src, topPrice, bottomPrice, removeCompleted)

updateOrderViews(views, topPrice, bottomPrice, removeCompleted)

createOrderByRR(enter, sl, rr, commision_percent)
เอกสารเผยแพร่
v7

Добавлено:
createOrderWithEnterPoint(ticker, side, enter, max_amount_usd, leverage)
  Creates order with enter point
  Parameters:
    ticker (string): (string) Name of the ticker
    side (int): (int) "1" - buy , "-1" - sell
    enter (float): (float) enter point price
    max_amount_usd (float): (float) Maximum order amount in USDT
    leverage (int): (int) Order leverage (default x1)

createOrderWithEST(ticker, side, enter, max_amount_usd, sl, rr, max_loss, leverage, commision_percent)
  Creates order with enter point, stop loss and take profit
  Parameters:
    ticker (string)
    side (int)
    enter (float)
    max_amount_usd (float)
    sl (float)
    rr (float)
    max_loss (float)
    leverage (int)
    commision_percent (float)

Обновлено:
addTakeProfit(src, piece, price, rr, commision_percent)
  Parameters:
    src (orderModel)
    piece (float)
    price (float)
    rr (float)
    commision_percent (float)

configureBreakeven(src, target_price, target_offset, commision_percent)
  Parameters:
    src (orderModel)
    target_price (float)
    target_offset (float)
    commision_percent (float)

configureTrailingStop(src, lag_offset, trigger_offset, trigger_price, commision_percent)
  Parameters:
    src (orderModel)
    lag_offset (float)
    trigger_offset (float)
    trigger_price (float)
    commision_percent (float)

createOrder(ticker, side, leverage)
  Creates empty order
  Parameters:
    ticker (string)
    side (int)
    leverage (int)
เอกสารเผยแพร่
v8
เอกสารเผยแพร่
v9
เอกสารเผยแพร่
v10
เอกสารเผยแพร่
v11
เอกสารเผยแพร่
v12
เอกสารเผยแพร่
v13
เอกสารเผยแพร่
v14
เอกสารเผยแพร่
v15

Добавлено:
cleanOrderView(src)
  Parameters:
    src (orderView)

repaintViews(views, remove_completed)
  Parameters:
    views (orderView[])
    remove_completed (bool)

lineView
  Fields:
    _line (series__line)
    labels (array__label)
    is_completed (series__bool)
    color (series__color)

lineViewCollection
  Fields:
    collection (array__|lineView|#OBJ)
    color (series__color)
    is_completed (series__bool)

Обновлено:
repaintView(src)
  Parameters:
    src (orderView)

Удалено:
removeOrderView(src)
เอกสารเผยแพร่
v16
เอกสารเผยแพร่
v17

Обновлено:
configureBreakeven(src, target_price, target_offset, trigger_price, trigger_offset, commision_percent)
  Parameters:
    src (orderModel)
    target_price (float)
    target_offset (float)
    trigger_price (float)
    trigger_offset (float)
    commision_percent (float)
เอกสารเผยแพร่
v18

Обновлено:
configureTrailingStop(src, lag_offset, trigger_offset, trigger_price, commision_percent)
  Configures "Trailing Stop"
  Parameters:
    src (orderModel): (orderModel, required) target order model
    lag_offset (float): (float, percent, required) Execute stop order if price reverse back on [lag_offset] percents
    trigger_offset (float): (float, percent) "Trailing Stop" starts working if price moved by [trigger_offset] related to [src.enter.price]
    trigger_price (float): (float) "Trailing Stop" starts working if price moved to [trigger_price]
    commision_percent (float): (float, percent, required, default) Exchange commision for open + close orders togather (default = 0.08)
เอกสารเผยแพร่
v19
เอกสารเผยแพร่
v20

bar_index references removed
เอกสารเผยแพร่
v21

Добавлено:
configureTrailingStopByStopLoss(src, lag_offset_rr, trigger_offset_rr, commision_percent)
  Parameters:
    src (orderModel)
    lag_offset_rr (float)
    trigger_offset_rr (float)
    commision_percent (float)

Обновлено:
configureStopLoss(src, price, offset, max_loss, commision_percent)
  Parameters:
    src (orderModel)
    price (float)
    offset (float)
    max_loss (float)
    commision_percent (float)
เอกสารเผยแพร่
v22
เอกสารเผยแพร่
v23

Добавлено:
feesBinanceFutures()

configureStopLossByPrice(src, price_value, max_loss, fees)
  Parameters:
    src (tradePositionModel)
    price_value (float)
    max_loss (float)
    fees (exchangeFeesModel)

addTakeProfitByRR(src, rr, position_piece_prc, fees)
  Parameters:
    src (tradePositionModel)
    rr (float)
    position_piece_prc (float)
    fees (exchangeFeesModel)

configureBreakevenBySL(src, fees)
  Parameters:
    src (tradePositionModel)
    fees (exchangeFeesModel)

createTradePosition(ticker, side, started_on, leverage)
  Creates empty order
  Parameters:
    ticker (string)
    side (int)
    started_on (int)
    leverage (int)

exchangeFeesModel
  Fields:
    market_order_prc (series__float)
    limit_order_prc (series__float)

orderPriceModel
  Fields:
    price (series__float)
    price_with_commision (series__float)
    offset (series__float)
    offset_with_commision (series__float)

orderAmountModel
  Fields:
    coins (series__float)
    value (series__float)
    position_piece_prc (series__float)

orderStateModel
  Fields:
    is_completed (series__bool)
    completed_on (series__integer)

breakevenOrderModel
  Fields:
    target (|orderPointModel|#OBJ)
    trigger (|orderPriceModel|#OBJ)

trailingStopOrderModel
  Fields:
    trigger (|orderPriceModel|#OBJ)
    lag_offset (series__float)

tradePositionModel
  Fields:
    ticker (series__string)
    side (series__integer)
    leverage (series__integer)
    created_on (series__integer)
    enter (|orderPointModel|#OBJ)
    stop_loss (|orderPointModel|#OBJ)
    breakeven (|breakevenOrderModel|#OBJ)
    trailing_stop (|trailingStopOrderModel|#OBJ)
    take_profit_collection (array__|orderPointModel|#OBJ)
    state (|orderStateModel|#OBJ)

Обновлено:
createOrderView(src, profit_color, loss_color, enter_color)
  Parameters:
    src (tradePositionModel)
    profit_color (simple color)
    loss_color (simple color)
    enter_color (simple color)

repaintView(src, time_now)
  Parameters:
    src (orderView)
    time_now (int)

repaintViews(views, time_now, remove_completed)
  Parameters:
    views (orderView[])
    time_now (int)
    remove_completed (bool)

updateOrderState(src, top_price, bottom_price, time_now)
  Parameters:
    src (tradePositionModel)
    top_price (float)
    bottom_price (float)
    time_now (int)

updateOrderStates(models, top_price, bottom_price, time_now, remove_completed)
  Parameters:
    models (tradePositionModel[])
    top_price (float)
    bottom_price (float)
    time_now (int)
    remove_completed (bool)

configureEnterPoint(src, price, amount)
  Parameters:
    src (tradePositionModel)
    price (orderPriceModel)
    amount (orderAmountModel)

configureStopLoss(src, price, amount)
  Parameters:
    src (tradePositionModel)
    price (orderPriceModel)
    amount (orderAmountModel)

addTakeProfit(src, price, amount)
  Parameters:
    src (tradePositionModel)
    price (orderPriceModel)
    amount (orderAmountModel)

configureBreakeven(src, target, trigger)
  Parameters:
    src (tradePositionModel)
    target (orderPointModel)
    trigger (orderPriceModel)

configureTrailingStop(src, trigger, lag_offset, exchange_fees)
  Configures "Trailing Stop"
  Parameters:
    src (tradePositionModel): (orderModel, required) target order model
    trigger (orderPriceModel)
    lag_offset (float): (float, percent, required) Execute stop order if price reverse back on [lag_offset] percents
    exchange_fees (exchangeFeesModel)

Удалено:
configureTrailingStopByStopLoss(src, lag_offset_rr, trigger_offset_rr, commision_percent)

createOrder(ticker, side, leverage)
  Creates empty order

createOrderWithEnterPoint(ticker, side, enter, max_amount_usd, leverage)
  Creates order with enter point

createOrderWithEST(ticker, side, enter, max_amount_usd, sl, rr, max_loss, leverage, commision_percent)
  Creates order with enter point, stop loss and take profit

breakevenModel

trailingStopModel

enterPointModel

orderModel
เอกสารเผยแพร่
v24

Добавлено:
createOrderPriceByPrice(price, enter_price, commision_prc)
  Parameters:
    price (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByPriceWithCommision(value_with_commision, enter_price, commision_prc)
  Parameters:
    value_with_commision (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffset(offset, enter_price, commision_prc)
  Parameters:
    offset (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffsetWithCommision(offset_with_commision, enter_price, commision_prc)
  Parameters:
    offset_with_commision (float)
    enter_price (float)
    commision_prc (float)

createOrderAmountFromCoins(coins, price)
  Parameters:
    coins (float)
    price (float)

createOrderAmountFromValue(value, price)
  Parameters:
    value (float)
    price (float)

createOrderAmountFromOther(other, price, piece_prc)
  Parameters:
    other (orderAmountModel)
    price (float)
    piece_prc (float)

configureMarketOpenOrderByPrice(src, price_value, amount_value, exchange_fees)
  Parameters:
    src (tradePositionModel)
    price_value (float)
    amount_value (float)
    exchange_fees (exchangeFeesModel)
เอกสารเผยแพร่
v25

Добавлено:
createOrderPriceByValue(side, value, enter_price, commision_prc)
  Parameters:
    side (int): (int) Order side. "1" - buy order, "-1" sell order
    value (float)
    enter_price (float)
    commision_prc (float)

Обновлено:
createOrderPriceByPriceWithCommision(side, value_with_commision, enter_price, commision_prc)
  Parameters:
    side (int)
    value_with_commision (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffset(side, offset, enter_price, commision_prc)
  Parameters:
    side (int)
    offset (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffsetWithCommision(side, offset_with_commision, enter_price, commision_prc)
  Parameters:
    side (int)
    offset_with_commision (float)
    enter_price (float)
    commision_prc (float)

Удалено:
createOrderPriceByPrice(price, enter_price, commision_prc)
เอกสารเผยแพร่
v26
เอกสารเผยแพร่
v27

Обновлено:
createOrderPriceByValue(position_side, order_side, value, enter_price, commision_prc)
  Parameters:
    position_side (int)
    order_side (int)
    value (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByPriceWithCommision(position_side, order_side, value_with_commision, enter_price, commision_prc)
  Parameters:
    position_side (int)
    order_side (int)
    value_with_commision (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffset(order_side, offset, enter_price, commision_prc)
  Parameters:
    order_side (int)
    offset (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffsetWithCommision(order_side, offset_with_commision, enter_price, commision_prc)
  Parameters:
    order_side (int)
    offset_with_commision (float)
    enter_price (float)
    commision_prc (float)
เอกสารเผยแพร่
v28

Добавлено:
configureTrailingStopByStopLoss(src, lag_offset_rr, trigger_offset_rr, exchange_fees)
  Parameters:
    src (tradePositionModel)
    lag_offset_rr (float)
    trigger_offset_rr (float)
    exchange_fees (exchangeFeesModel)

Обновлено:
addTakeProfitByRR(src, rr, position_piece_prc, exchange_fees)
  Parameters:
    src (tradePositionModel)
    rr (float)
    position_piece_prc (float)
    exchange_fees (exchangeFeesModel)

configureBreakevenBySL(src, target_offset, exchange_fees)
  Parameters:
    src (tradePositionModel)
    target_offset (float)
    exchange_fees (exchangeFeesModel)

configureTrailingStop(src, trigger, lag_offset)
  Configures "Trailing Stop"
  Parameters:
    src (tradePositionModel): (orderModel, required) target order model
    trigger (orderPriceModel)
    lag_offset (float): (float, percent, required) Execute stop order if price reverse back on [lag_offset] percents
เอกสารเผยแพร่
v29

Добавлено:
configureBreakevenByValue(src, trigger_price, target_offset, exchange_fees)
  Parameters:
    src (tradePositionModel)
    trigger_price (float)
    target_offset (float)
    exchange_fees (exchangeFeesModel)

configureBreakevenByOffset(src, trigger_offset, target_offset, exchange_fees)
  Parameters:
    src (tradePositionModel)
    trigger_offset (float)
    target_offset (float)
    exchange_fees (exchangeFeesModel)

Обновлено:
configureBreakevenBySL(src, target_offset, rr, exchange_fees)
  Parameters:
    src (tradePositionModel)
    target_offset (float)
    rr (float)
    exchange_fees (exchangeFeesModel)
เอกสารเผยแพร่
v30
เอกสารเผยแพร่
v31

Добавлено:
createPositionView(src, profit_color, loss_color, enter_color)
  Parameters:
    src (tradePositionModel)
    profit_color (simple color)
    loss_color (simple color)
    enter_color (simple color)

disposePositionView(src)
  Parameters:
    src (orderView)

disposePositionViews(src, skip)
  Parameters:
    src (orderView[])
    skip (int)

Удалено:
createOrderView(src, profit_color, loss_color, enter_color)

cleanOrderView(src)
เอกสารเผยแพร่
v32

Добавлено:
createTradePositionView(src, profit_color, loss_color, enter_color)
  Parameters:
    src (tradePositionModel)
    profit_color (simple color)
    loss_color (simple color)
    enter_color (simple color)

disposeTradePositionView(src)
  Parameters:
    src (tradePositionView)

disposeTradePositionViews(src, skip)
  Parameters:
    src (tradePositionView[])
    skip (int)

repaintTradePositionView(src, time_now)
  Parameters:
    src (tradePositionView)
    time_now (int)

repaintTradePositionViews(views, time_now, remove_completed)
  Parameters:
    views (tradePositionView[])
    time_now (int)
    remove_completed (bool)

updateTradePositionState(src, top_price, bottom_price, time_now)
  Parameters:
    src (tradePositionModel)
    top_price (float)
    bottom_price (float)
    time_now (int)

updateTradePositionStates(models, top_price, bottom_price, time_now, remove_completed)
  Parameters:
    models (tradePositionModel[])
    top_price (float)
    bottom_price (float)
    time_now (int)
    remove_completed (bool)

tradePositionView
  Fields:
    enter (|lineView|#OBJ)
    stop_loss (|lineView|#OBJ)
    take_profit_collection (|lineViewCollection|#OBJ)
    is_completed (series__bool)
    model (|tradePositionModel|#OBJ)

Удалено:
createPositionView(src, profit_color, loss_color, enter_color)

disposePositionView(src)

disposePositionViews(src, skip)

repaintView(src, time_now)

repaintViews(views, time_now, remove_completed)

updateOrderState(src, top_price, bottom_price, time_now)

updateOrderStates(models, top_price, bottom_price, time_now, remove_completed)

orderView
เอกสารเผยแพร่
v33

Обновлено:
createOrderPriceByOffset(position_side, order_side, offset, enter_price, commision_prc)
  Parameters:
    position_side (int)
    order_side (int)
    offset (float)
    enter_price (float)
    commision_prc (float)

createOrderPriceByOffsetWithCommision(position_side, order_side, offset_with_commision, enter_price, commision_prc)
  Parameters:
    position_side (int)
    order_side (int)
    offset_with_commision (float)
    enter_price (float)
    commision_prc (float)
เอกสารเผยแพร่
v34
เอกสารเผยแพร่
v35
เอกสารเผยแพร่
v36
เอกสารเผยแพร่
v37

Обновлено:
disposeTradePositionViews(src, completed_only, skip)
  Parameters:
    src (tradePositionView[])
    completed_only (bool)
    skip (int)
เอกสารเผยแพร่
v38
เอกสารเผยแพร่
v39
เอกสารเผยแพร่
v40

Добавлено:
tradeStatisticsModel
  Fields:
    income (series__float)
    error (series__integer)
    completed (series__integer)
    in_progress (series__integer)
    win (series__integer)
    win_partial (series__integer)
    loss (series__integer)

tradeDebugDataModel
  Fields:
    updated_views (series__integer)
    updated_models (series__integer)
    updated_statistics (series__integer)
เอกสารเผยแพร่
v41
เอกสารเผยแพร่
v42
hamster-coderordersstrategies

ไลบรารีไพน์

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนได้เผยแพร่ Pine code นี้เป็นโอเพนซอร์ซไลบรารีเพื่อให้ Pine โปรแกรมเมอร์คนอื่นในชุมชนของเราสามารถนำไปใช้ซ้ำได้ ต้องขอบคุณผู้เขียน! คุณสามารถใช้ไลบรารีนี้ในแบบส่วนตัวหรือในการเผยแพร่แบบโอเพนซอร์สอื่น ๆ แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน

คำจำกัดสิทธิ์ความรับผิดชอบ