fiddlah

DCA Bot Long/Short

Thanks to @TheTradingParrot for the inspiration and knowledge shared.
Thanks to @ericlin0122 for the original DCA Bot Emulator which is the backbone of this strategy.
The script simulates DCA strategy with parameters used in 3commas DCA bots for futures trading. Experiment with parameters
to find your trading setup.
Beware how large your total leveraged position is and how far can market go before you get liquidated!
Do that with the help of futures liquidation calculators you can find online!

I`ve added:

1) an internal average price and profit calculating, instead of TV`s native one, which is subject to severe slippage.
2) I`ve built a graphic interface, so levels are clearly visible and back-test analyzing made easier.
3) now both Long & Short direction of the strategy exist.
4) trailing TP which was featured in the initial script has been removed because TV`s execution model makes
it impossible to know how the real world trailing would have unfolded.
5) the table is self explanatory, and it is there to help you discover what happened and where.
6) vertical colored lines appear when the new maximum deviation from the original price has
been reached
All the trading happens with total account capital, and all order sizes inputs are expressed in percent.


Known issues:

When deviation is small, and the same candle triggers safety AND the close order, the initial orders are closed, but a
new one opens on the next candle. This is "resolved" by closing the unwanted trade forcefully on the next candle, affecting
profit calculating minimally and guaranteeing that what should be closed has been closed.

The code could be improved through use of arrays, making the table flexible so the number of rows should be dynamic depending
on the number of SOs.


!!!!! IMPORTANT!!!!!

This strategy script is made to receive a signal from an exterior study script, which should plot +100 for long or -100 for short
entry (that is by default - values can be changed in the strategy settings menu). That plot should be found in "Enter Trigger" input
dropdown menu at the bottom of strategy settings menu. Removing the "and trigger == long/short_trigger" condition from strategy entry
conditions makes the strategy open trades ASAP.

Cheers!
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, 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 nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

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 tập lệnh này trên biểu đồ?