# Perplexity × MT5: AI Trading Bot, No Pixie Dust

**URL:** <https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285>\
**Category:** Tutorials & Methods\
**Tags:** programming, tips-tricks, trading\
**Created:** [August 31, 2025, 4:15pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285 "2025-08-31T16:15:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fake\_Guy](https://onehack.st/user_avatar/onehack.st/fake_guy/32/132828_2.png) [@Fake\_Guy](https://onehack.st/u/Fake_Guy)\
**Post date:** [August 31, 2025, 4:15pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285/1 "2025-08-31T16:15:03Z")

</div>

# Simple AI Trading Bot (Perplexity + MT5)

**🗺 One-Line Flow:** Ask Perplexity “what’s the vibe?” → Check MT5 charts → Decide BUY/SELL/WAIT → Execute (safely)

 ![image](https://onehack.st/uploads/default/original/3X/3/e/3eb70e68c4562fa6e6480097e8147182a74ac84d.jpeg)

* * *

## 🧪 What This Bot Really Does

**Step 1:** Ask Perplexity → “What’s the vibe on EURUSD?” (fundamentals & news)  
**Step 2:** Ask MT5 → “Show me the candles + indicators” (technicals)  
**Step 3:** Mix both answers → decide BUY / SELL / WAIT  
**Step 4:** Run in paper mode (demo money) → later flip to real mode

Think of it like a **GPS for trading** : Perplexity = traffic news, MT5 = street map, Bot = driver that won’t speed into a wall.

* * *

## ⚡ Why It’s Awesome

✅ **You don’t need to guess** → news + charts fuse together  
✅ **Risk rules** stop you from blowing the account  
✅ **Starts simple** → you can add more fancy tricks later  
✅ **Paper trading first** → practice with fake money

* * *

## 🚀 Quick Setup (15 Minutes)

### 1. Install Python Libraries

```auto
pip install requests pandas numpy MetaTrader5 ta

```

### 2. Get Your Keys

- **Perplexity API:** Sign up at [perplexity.ai](https://perplexity.ai) → get API key
- **MT5 Broker:** Open demo account → get login details

### 3. Set Environment Variables

```auto
export PPLX_API_KEY="your_perplexity_key"
export MT5_ACCOUNT=12345678
export MT5_PASSWORD="your_password"  
export MT5_SERVER="broker_server_name"

```

### 4. Run The Bot

```auto
python simple_bot.py --symbol EURUSD --mode paper

```

* * *

## 💻 The Simple Code

### Basic Bot Structure

```auto
import requests
import MetaTrader5 as mt5
import os

# Connect to Perplexity
def ask_perplexity(symbol):
    url = "https://api.perplexity.ai/chat/completions"
    headers = {"Authorization": f"Bearer {os.getenv('PPLX_API_KEY')}"}
    
    prompt = f"Is {symbol} bullish or bearish? Answer: bullish/bearish/neutral"
    
    data = {
        "model": "sonar",
        "messages": [{"role": "user", "content": prompt}]
    }
    
    response = requests.post(url, headers=headers, json=data)
    answer = response.json()["choices"]["message"]["content"]
    
    return "bullish" if "bullish" in answer.lower() else "bearish" if "bearish" in answer.lower() else "neutral"

# Connect to MT5
def get_mt5_signal(symbol):
    mt5.initialize()
    rates = mt5.copy_rates_from_pos(symbol, mt5.TIMEFRAME_H1, 0, 50)
    
    # Simple moving average crossover
    prices = [r['close'] for r in rates]
    short_ma = sum(prices[-10:]) / 10 # 10-period average
    long_ma = sum(prices[-30:]) / 30 # 30-period average
    
    if short_ma > long_ma:
        return "bullish"
    else:
        return "bearish"

# Make Decision
def decide_trade(symbol):
    perplexity_view = ask_perplexity(symbol)
    mt5_view = get_mt5_signal(symbol)
    
    # Both agree = strong signal
    if perplexity_view == "bullish" and mt5_view == "bullish":
        return "BUY"
    elif perplexity_view == "bearish" and mt5_view == "bearish":
        return "SELL"
    else:
        return "WAIT"

# Main
symbol = "EURUSD"
decision = decide_trade(symbol)
print(f"{symbol}: {decision}")

```

* * *

## 🎯 How Decisions Work

| Perplexity Says | MT5 Charts Say | Bot Decision |
| --- | --- | --- |
| Bullish | Bullish | **BUY** 🟢 |
| Bearish | Bearish | **SELL** 🔴 |
| Mixed signals | Mixed signals | **WAIT** 🟡 |

**Simple rule:** Only trade when both brains agree.

* * *

## ⚙ Essential Settings

```auto
# config.yaml
symbols: ["EURUSD", "GBPUSD", "USDJPY"]
risk_per_trade: 1% # Never risk more than 1% per trade  
max_trades_per_day: 3 # Don't overtrade
mode: "paper" # Start with fake money
check_every: 60 # Minutes between checks

```

* * *

## 🛡 Safety First

### Built-in Protections

- **Paper trading mode** → Practice with demo money first
- **Risk limits** → Never bet more than 1% per trade
- **Daily limits** → Max 3 trades per day (avoid overtrading)
- **Stop losses** → Auto-exit if trade goes wrong

### Reality Checks

❌ **This is not magic** → You will have losing trades  
❌ **Start small** → Even experts lose money learning  
❌ **Test everything** → Paper trade for at least 1 month  
✅ **Stay patient** → Good trades are rare, bad trades are common

* * *

## 📚 Learn More

**Essential Links:**

- [Perplexity API Docs](https://docs.perplexity.ai/getting-started/quickstart)
- [MetaTrader5 Python](https://www.mql5.com/en/docs/python_metatrader5)
- [Trading Basics](https://www.babypips.com/learn/forex) (Free course)

**Upgrade Path:**

1. **Week 1-2:** Run this simple version, understand the basics
2. **Week 3-4:** Add more indicators (RSI, MACD)
3. **Month 2:** Add proper risk management
4. **Month 3:** Consider live trading (if profitable on paper)

* * *

## 🏁 Next Steps

1. **Copy the code** → Save as `simple_bot.py`
2. **Get your API keys** → Perplexity + MT5 demo account
3. **Run in paper mode** → Let it trade fake money for 2 weeks
4. **Track results** → Are you making fake profits consistently?
5. **Only then** → Consider real money (start with $100)

**Remember:** The goal isn’t to get rich quick. The goal is to build a system that makes more good trades than bad trades over time.

* * *

# EDITED BY @SRZ **Everything is complete.** 🤖

```auto

```

---

<div class="post-metadata">

**Author:** ![ChickN](https://onehack.st/user_avatar/onehack.st/chickn/32/115176_2.png) [@ChickN](https://onehack.st/u/ChickN)\
**Post date:** [August 31, 2025, 7:10pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285/2 "2025-08-31T19:10:11Z")

</div>

Any idea on how to setup the stop loss?

---

<div class="post-metadata">

**Author:** ![pintas\_m](https://onehack.st/user_avatar/onehack.st/pintas_m/32/162057_2.png) [@pintas\_m](https://onehack.st/u/pintas_m)\
**Post date:** [September 26, 2025, 8:59pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285/3 "2025-09-26T20:59:33Z")

</div>

**VERY** important question.

---

<div class="post-metadata">

**Author:** ![SRZ](https://onehack.st/user_avatar/onehack.st/srz/32/146132_2.png) [@SRZ](https://onehack.st/u/SRZ)\
**Post date:** [September 26, 2025, 10:49pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285/4 "2025-09-26T22:49:20Z")

</div>

> [@ChickN](#):
>
> Any idea on how to setup the stop loss?

Look, stop loss is just “exit when you’re wrong” - not rocket science.

**Step 1:** Get recent prices from MT5  
**Step 2:** Calculate how much the price normally wiggles (that’s ATR)  
**Step 3:** Set your exit 2× that wiggle away from your entry  
**Step 4:** Tell MT5 “sell my stuff if it hits this price”

**Code (because apparently we need to spell everything out):**

```python
# Get ATR (price wiggle amount)
atr = talib.ATR(highs, lows, closes, timeperiod=14)[-1]

# Set stop loss 
if action == "BUY":
    stop_loss = entry_price - (atr * 2) # Exit if price drops too much
else:
    stop_loss = entry_price + (atr * 2) # Exit if price rises too much

```

There. Your bot won’t blow up your account in one bad trade. You’re welcome.

---

<div class="post-metadata">

**Author:** ![James\_Jason](https://onehack.st/user_avatar/onehack.st/james_jason/32/158326_2.png) [@James\_Jason](https://onehack.st/u/James_Jason)\
**Post date:** [September 30, 2025, 7:59pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285/5 "2025-09-30T19:59:25Z")

</div>

Thx for sharing 👏 🙏 🤝 on testing already 😁 😁 😁

 ![Capture](https://onehack.st/uploads/default/original/3X/a/3/a3d157f4a65ba2e17ecfc704dac2edd910fa333b.png)

---

<div class="post-metadata">

**Author:** ![Al\_Kriss](https://onehack.st/user_avatar/onehack.st/al_kriss/32/140598_2.png) [@Al\_Kriss](https://onehack.st/u/Al_Kriss)\
**Post date:** [September 30, 2025, 8:45pm UTC](https://onehack.st/t/perplexity-x-mt5-ai-trading-bot-no-pixie-dust/310285/6 "2025-09-30T20:45:54Z")

</div>

> [@Fake\_Guy](#):
>
> **MT5 Broker:** Open demo account

i can’t get a free API from perplexity
