Alerts from Tradingview.com do not select sides (BUY/SELL) and get copied multiple 5 times each with capitalise.ai

I created a tradingview.com strategy that is ready to automate. And I have found that capitalize.ai (cap.ai from here) is able to execute my trades from tradingview (TV from hereon), via an API to Avatrade and Interactive Brokers.

The problem however is limited to webhook alerts from TV to cap.ai.

I enclose my alert and tradelogic code below. Does any one know of why I get 10 (5 SELL and 5 BUY alerts, every time the alert triggers. And cap.ai does not trigger on my alerts/webhooks, which have proper msg and URL).

My code for alerts and tradelogic

// Alert Messages long
ANDstartLongTradeMessage = input.string(title = "Long Entry Webhook Message", defval = "", group = "Long Webhook Messages")
ANDendLongTradeMessage = input.string(title = "Close Long Webhook Message", defval = "", group = "Long Webhook Messages")

// Alert Messages short
ANDstartShortTradeMessage = input.string(title = "Short Entry Webhook Message", defval = "", group = "Short Webhook Messages")
ANDendShortTradeMessage = input.string(title = "Close Short Webhook Message", defval = "", group = "Short Webhook Messages")

// ------------------- Trading signals and Alerts  -----------------  See section on alerts above ANDTradelogic
// All orders have the same but dynamic text, that will show the direction of order
alertsyntax = '{{strategy.order.action}}  - - - Machine Learning: Logistic Regression (ME v.6 - DynTP & SL) (Close, , 3, 2, 0.0009, 1000, None, 5, 7, 1, 2023, 1, 1, 2029, 6, 0.01): 
     order {{strategy.order.action}} @ {{strategy.order.contracts}} filled on {{ticker}}. New strategy position is {{strategy.position_size}}' 
// Alerts in TV GUI will work with this message: {{ticker}} - {{strategy.order.action}} {{strategy.order.contracts}} @ {{strategy.order.price}}. New strategy position is {{strategy.position_size}} {{strategy.order.alert_message}}


// -------------------------------------------------------------------------

// ----------------   ANDTradelogic Fct   ------------------------------  Bruges nu til handler for at minimere antal trades 

ANDTradelogic(close) =>
    if ANDstartLongTrade
        strategy.entry('Long', strategy.long) //
        if use_TP 
            strategy.exit("Exit Long, TP", from_entry="Long", limit=high * (1+(tpPercent/100)))
        alert(message=alertsyntax, freq=alert.freq_all)   //, freq=alert.freq_once_per_bar_close)   
        alert(ANDendShortTradeMessage, freq = alert.freq_once_per_bar)
        alert(ANDstartLongTradeMessage, freq = alert.freq_once_per_bar)

    if ANDstartShortTrade
        strategy.entry('Short', strategy.short)
        if use_TP 
            strategy.exit("Exit Short, TP", from_entry="Short", limit=low * (1-(tpPercent/100)))
        alert(message=alertsyntax, freq=alert.freq_all) //, freq=alert.freq_once_per_bar_close)   
        alert(ANDendLongTradeMessage, freq = alert.freq_once_per_bar)
        alert(ANDstartShortTradeMessage, freq = alert.freq_once_per_bar)

    // Final decision of when to trade
    if ANDendShortTrade
        strategy.close('Long', 'Long')
        alert(message=alertsyntax) //, freq=alert.freq_once_per_bar_close)   
        alert(ANDendShortTradeMessage, freq = alert.freq_once_per_bar)

    if ANDendLongTrade
        strategy.close('Short', 'Short')
        alert(message=alertsyntax) //, freq=alert.freq_once_per_bar_close)   
        alert(ANDendLongTradeMessage, freq = alert.freq_once_per_bar)


if window()  // if in timewindow of trading/backtest

    // Run ANDTradelogic Fct.
    ANDTradelogic (close)

I am expecting that cap.ai can use my alerts to dynamically from my TV strategy code, get the direction of the trade (BUY/SELL) and the quantity, which change over time. So a hardcoded cap.ai will not do. This is too constrained.

When I do backtest of this strategy on TV, the backtest properly trades both ways, and the quantity evolves like so: BUY x, Short 2x, buy 2x, short 2x…. etc.

1

Check out the documentation and examples posted on the Capitalise web

Use only box input strings

something like this:

// Alert Messages long
ANDstartLongTradeMessage  = input.string(title = "Long Entry Webhook Message", defval = "", group = "Long Webhook Messages")
ANDendLongTradeMessage    = input.string(title = "Close Long Webhook Message", defval = "", group = "Long Webhook Messages")

// Alert Messages short
ANDstartShortTradeMessage = input.string(title = "Short Entry Webhook Message", defval = "", group = "Short Webhook Messages")
ANDendShortTradeMessage   = input.string(title = "Close Short Webhook Message", defval = "", group = "Short Webhook Messages")

if ANDstartLongTrade
    strategy.entry('Long', strategy.long) //
    alert(ANDstartLongTradeMessage, freq = alert.freq_once_per_bar)

if ANDendLongTrade
    strategy.close('Long', 'Long')
    alert(ANDendLongTradeMessage, freq = alert.freq_once_per_bar)

if ANDstartShortTrade
    strategy.entry('Short', strategy.short)
    alert(ANDstartShortTradeMessage, freq = alert.freq_once_per_bar)

if ANDendShortTrade
    strategy.close('Short', 'Short')
    alert(ANDendShortTradeMessage, freq = alert.freq_once_per_bar)

4

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật