Run DCA bot
Last updated
Last updated
This is a sample Pine Script and a corresponding alert message to run a DCA(Dollar-Cost Averaging) bot with the following conditions as an example.
Execute BTC-USD Long order daily with 200 USD when close price < 20,000 until total position size is less than 1 BTC
Execute close(short) order when daily close price > 24,000
All of the above values are parameterized and you can customize them.
Select market you want to run DCA bot and set arbitrary time-interval(the above example is 1D)
2. Open "Pine Editor" tab and paste the following script after deleting shown original script. Then click "Add to chart"
In the above script, We assume
No remaining positions/orders in the target market running this bot.
Enough amount of collateral is already in place to avoid liquidation.
3. Click Alert button and paste the following code into message field.