# DragonX Bot

DragonX is a bot that receives alerts from TradingView and trades automatically on BingX.

## How to Use

1. **Configure Settings**
   - Edit `config.md` to set your BingX API keys, trading symbol, margin, leverage, and other settings.
   - Example:
     ```
     BINGX_API_KEY=your_api_key
     BINGX_API_SECRET=your_api_secret
     TRADE_SYMBOL=XAUT-USDT
     TRADE_MARGIN=1000
     TRADE_LEVERAGE=10
     TRADE_TP_PERCENT=3
     TRADE_SL_PERCENT=1.5
     TRADE_DELAY=20
     TRADE_ORDER_TYPE=MARKET
     ```

2. **Host the Bot**
   - Place the project in your web server directory (e.g., Laragon, XAMPP, etc).
   - Make sure `index.php` is accessible via a public URL (this is your webhook URL).

3. **TradingView Alert Setup**
   - Go to TradingView and create an alert.
   - Set the webhook URL to your bot's public URL (e.g., `http://yourdomain.com/dragonx/index.php`).
   - Use this message format:
     ```
     symbol: {{ticker}}, price: "{{close}}", time: "{{time}}", buy: {{plot("Buy Signal")}}, sell: {{plot("Sell Signal")}}
     ```
   - Example:
     ```
     symbol: XAUT-USDT, price: "2345.67", time: "2026-03-13T12:34:56Z", buy: 1, sell: 0
     ```

## Notes
- Only one trade is processed at a time (auto lock).
- Only signals from BingX IPs are accepted.
- All trades and requests are logged.

## Quick Start
1. Edit `config.md` with your info.
2. Host the bot and get your webhook URL.
3. Set up TradingView alert with the correct message and webhook.

---
For any issues, check `error.log` and `trades.log` in the bot folder.
