Trendoscope

strategy

Trendoscope Wizard Cập nhật   
Library "strategy"
Library containing few key calculations for strategy involving leveraged limit and stop orders

getQty(entry, stop, riskPercentage)
  calculate qty and leverage based on entry and stop price for given risk percentage.
  Parameters:
    entry: Entry Price
    stop: Stop Price
    riskPercentage: risk percentage per trade
  Returns: - Quantity based on the risk and calculated leverage on position including existing positions

bracketOrder(entry, stop, target, maxLeverage, isLimitOrder, riskPercentage)
  Calculates position size based on risk and creates bracket orders for given entry/stop/target
  Parameters:
    entry: Entry Price
    stop: Stop Price
    target: Target Price
    maxLeverage: Maximum leverage allowed
    isLimitOrder: if true, places limit order for entry, else places stop order.
    riskPercentage: risk percentage per trade
  Returns: orderPlaced - true if orders successfully placed, false otherwise.

order(entry, stop, maxLeverage, isLimitOrder, riskPercentage)
  Calculates position size based on risk and creates order for given entry/stop
  Parameters:
    entry: Entry Price
    stop: Stop Price
    maxLeverage: Maximum leverage allowed
    isLimitOrder: if true, places limit order for entry, else places stop order.
    riskPercentage: risk percentage per trade
  Returns: orderPlaced - true if orders successfully placed, false otherwise.
Phát hành các Ghi chú:
v2

Added:
bracketOrderWithoutLeverage(id, entry, stop, target, isLimitOrder)
  Creates bracket orders for given entry/stop/target without leverage and qty calculation. (Uses the values from strategy definition)
  Parameters:
    id
    entry: Entry Price
    stop: Stop Price
    target: Target Price
    isLimitOrder: if true, places limit order for entry, else places stop order.
  Returns: orderPlaced - true if orders successfully placed, false otherwise.
Phát hành các Ghi chú:
v3
Phát hành các Ghi chú:
v4

Updated:
getQty(entry, stop, riskAmount, riskType)
  calculate qty and leverage based on entry and stop price for given risk percentage.
  Parameters:
    entry: Entry Price
    stop: Stop Price
    riskAmount: risk percentage per trade or risk cash per trade
    riskType: Can be either trategy.percent_of_equity or strategy.cash
  Returns: - Quantity based on the risk and calculated leverage on position including existing positions

bracketOrder(id, entry, stop, target, maxLeverage, isLimitOrder, riskAmount, riskType)
  Calculates position size based on risk and creates bracket orders for given entry/stop/target
  Parameters:
    id
    entry: Entry Price
    stop: Stop Price
    target: Target Price
    maxLeverage: Maximum leverage allowed
    isLimitOrder: if true, places limit order for entry, else places stop order.
    riskAmount: risk percentage per trade or risk cash per trade
    riskType: Can be either trategy.percent_of_equity or strategy.cash
  Returns: orderPlaced - true if orders successfully placed, false otherwise.

order(id, entry, stop, maxLeverage, isLimitOrder, riskAmount, riskType)
  Calculates position size based on risk and creates order for given entry/stop
  Parameters:
    id
    entry: Entry Price
    stop: Stop Price
    maxLeverage: Maximum leverage allowed
    isLimitOrder: if true, places limit order for entry, else places stop order.
    riskAmount: risk percentage per trade or risk cash per trade
    riskType: Can be either trategy.percent_of_equity or strategy.cash
  Returns: orderPlaced - true if orders successfully placed, false otherwise.
Phát hành các Ghi chú:
v5

Corrected calculation logic for newPosition in getQty function. Thanks to @serkany88 for highlighting

Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy chung.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.