OPEN-SOURCE SCRIPT

3Commas Bollinger Strategy

已更新
This strategy is intended for use as a way of backtesting various parameters available on 3commas.io composite bot using a bollinger band type trading strategy. While it's primary intention is to provide users a way of backtesting bot parameters, it can also be used to trigger a deal start by either using the {{strategy.open.alert_message}} field in your alert and providing the bot details in the configuration screen for the strategy or by including the usual deal start message provided by 3commas. You can find more information about how to do this from help.3commas.io/en/articles/3108938-how-to-use-tradingview-custom-signals.

快照

The primary inputs for the strategy are:

// USER INPUTS
Short MA Window - The length of the Short moving average
Long MA Window - The length of the Long moving average
Upper Band Offset - The offset to use for the upper bollinger offset
Lower Band Offset - The offset to use for the lower bollinger offset
Long Stop Loss % - The stop loss percentage to test
Long Take Profit % - The Take profit percentage to test
Initial SO Deviation % - The price deviation percentage required to place to first safety order
Safety Order Vol Step % - The volume scale to test
3Commas Bot ID - (self explanatory)
Bot Email Token - Found in the deal start message for your bot (see link in previous section for details)
3Commas Bot Trading Pair - The pair to include for composite bot start deals (should match format of 3commas, not TradingView IE. USDT_BTC not BTCUSDT)

Start Date, Month, Year and End Date, Month and Year all apply to the backtesting window. By default it will use as much data as it can given the current period select (there is less historical data available for periods below 1H) back as far as 2016 (there appears to be no historical data on Trading view much before this). If you would like to test a different period of time, just change these values accordingly.

Known Issues
Currently there are a couple of issues with this strategy that you should be aware of. I may fix them at some point in the future but they don't really bug me so this is more for informational purposes than a promise that they may one day be fixed.
  • Does not test trailing take profit
  • Number of safety orders and Safety Order Step Scale are currently not user configurable (must edit source code)
  • Using the user configuration to generate deal start message assumes you are triggering a composite bot, not a simple bot.

發布通知
Remove some dead code, fix some comment typos, cleanup some formatting inconsistencies and remove a forgotten integer value used during some tests
發布通知
Increasing the strategy default_qty_value and initial_capital values to values that work on the regular stock market where whole shares must be purchased and cost more than 100USD. Previous version required manual editing for adaptation outside of crypto trading.

Additionally, I must apologize and make a correction to the documentation. I had previously stated that you could use either {{strategy.order.alert_message}} OR the start message provided by 3commas. This is not correct. Alerts will be triggered for all strategy actions (take profit, stop loss, entry and safety orders). If you do not use {{strategy.order.alert_message}}, the message message in the alert will be incorrect and deals will be opened at incorrect times, specifically on a take profit trigger. You MUST use the strategy settings to configure the bot information and trading pair and use {{strategy.order.alert_message}} in the alert message field.
發布通知
Add toggle for triggering one crossing over as well as crossing under the lower band.
發布通知
* Allow customizing number of safety orders from user settings
* Automatically detect trading pair to eliminate the need for the trading pair user setting (easier alert creation)

I also received a question that I will answer here in case others have the same:

Q: How can I make alerts with this strategy? Do I need to convert it to a study first?
A: No! The alert message is generated automatically in the format needed to start a 3commas composite long bot! As long as you provide the bot ID and Email Token in the user settings for the strategy (click the gear next to the strategy on the chart), all you need to do is add an alert, select the strategy from the drop down in the alert box, and use (without quotes) "{{strategy.order.alert_message}}" as the message body text NOTHING ELSE.
發布通知
This update fixes the deal entry message. The previous update to automatically detect and use the currently selected currency pair in the alert message was improperly formatted. This issue should now be fixed.
發布通知
This release improves code readability as well as provides better estimates for safety order accuracy.

* Group bot settings in code together more clearly
* Allow user configurable safety step scale
* More accurately calculate safety order volume (still work in progress but should be close now)
3commas3commasiobacktestBollinger Bands (BB)cryptoCryptocurrency

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?


更多:

免責聲明