TradingView
fiddlah
20. Sept. 2021 17:49

DCA Bot Long/Short 

Avalanche Perpetual FuturesFTX

Beschreibung

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!
Kommentare
liuqiba
It does't work.
fiddlah
@liuqiba, it does if you know how to feed it signals.
SupanatFrank
@fiddlah, teach me how to use it.
fiddlah
@SupanatFrank, you need to have a study that creates signals/alerts (based on conditions you determine). When the condition is met you should attribute a value 100 or -100 to a variable which in sequence you plot with plot function. That plot needs to be found in the Trigger dropdown menu of the strategy.
nisajev
@fiddlah, Hello! I found that it does nothing when choosing the trigger, because the strategy uses Source (Open, Close etc.) and ignores Triggers. What could i be doing wrong? Also, I only see the strategy doing long (average long) trades and selling at a higher price, however it does not open short trades.
fiddlah
@nisajev, you most likely had another strategy or indicator on that had input.source on. Pine doesn`t allow multiple input.source going on.
CaptainFlusher
@liuqiba, you need to do a little bit of simple coding in pine script and it works - you will need something to trigger the long and shorts such as a divergence indicator, rsi or crossovers etc...
SupanatFrank
Nothing happen or Can you tell me how to use this bot? pls
fiddlah
@SupanatFrank, please read the description.
raphyx91
@fiddlah someone cna explain me step by step how to set the excat study for this bot i would to try this bot but i'm not strong with pin code please? thank you by advance if someone can help and thank you very much for this amazing looking bot :)
Mehr