CustomStoplossWithPSAR Strategy: A "Textbook Example" of Stoploss
Nickname: Stoploss Textbook
Day Job: Quant world's "tutor" — specializes in teaching custom stoploss
Timeframe: 1 hour (no need to stare at screens)
1. What's This Strategy?
Simply put, CustomStoplossWithPSAR is:
- An educational example strategy (not for making money, for learning)
- Demonstrates how to use the
custom_stoploss()function - Shows how to use PSAR for dynamic stoploss
Like a driving school car: "Don't mind me going slow, I'm here to teach you how to drive!" 🚗
2. Core Settings: It's a "Learning Template"
Stoploss Rules
Hard stoploss: Cut at -20% loss (safety net)
Custom stoploss: PSAR dynamic stoploss (the main event!)
Translation: This strategy's focus is teaching you how to implement dynamic stoploss with custom_stoploss(). The trading logic is secondary.
3. When to Buy: Simple to the Point of Pain
🎯 Buy When PSAR Drops
Core Logic: PSAR decreasing
In Plain English:
"PSAR switched from rising to falling, trend might be reversing, buy!"
Code Translation:
# Entry condition
PSAR < PSAR from previous candle
Roast: This entry condition is so simple it hurts, but hey, it's an example strategy — the focus is teaching stoploss techniques! 🤣
4. Stoploss Mechanism: This Is the Star
4.1 PSAR Dynamic Stoploss
Trigger: Price drops below PSAR
In Plain English:
"PSAR is a parabolic indicator that follows price. When price rises, PSAR rises with it. When price falls, PSAR becomes your stoploss level!"
Code Translation:
# Custom stoploss function
def custom_stoploss(...):
Get latest PSAR value
Calculate stoploss ratio = (current price - PSAR) / current price
Return stoploss ratio
Classic Lines:
- "This is the main character, entry logic is just the sidekick!"
- "Learn this and you can write your own dynamic stoploss!"
4.2 Hard Stoploss Safety Net
Lost 20%? → Cut it (last line of defense)
In Plain English:
- When PSAR stoploss fails, there's still -20% as backup
5. Exit Logic: No Technical Exits
5.1 Technical Exit: Doesn't Exist
# Exit signal
dataframe.loc[:, "sell"] = 0 # No sell signals set
In Plain English:
"I exit via stoploss, who needs sell signals?"
Roast: This strategy is truly "minimalist" — it even skipped sell signals 🤣
6. This Strategy's "Personality"
✅ Pros (Praise Time)
- High learning value: Top choice for learning
custom_stoploss() - Clean code: 70+ lines, understandable in 30 minutes
- PSAR application: Shows the right way to use PSAR for stoploss
- 1-hour friendly: No screen-staring, perfect for office workers learning
- Clear comments: Well-commented code, conscientious example
⚠️ Cons (Roast Time)
- Not for live trading: Entry logic too simple, will lose money
- No trend filter: Buys regardless of up or down trend
- No BTC correlation: Doesn't care if Bitcoin crashes
- No technical exit: Exits purely via stoploss
- Example nature: It was never meant to make money
7. When to Use It?
| Purpose | Recommendation | Reason |
|---|---|---|
| Learning custom stoploss | Highly recommended | This is what it was designed for |
| Learning PSAR application | Highly recommended | Standard PSAR stoploss example |
| Live trading | Not recommended | Entry logic too simple |
| Modified for live | Maybe | Add more conditions and protections |
8. Bottom Line: How's This Strategy?
One-Liner
"A textbook example that can't make money but can teach you to make money"
Who Should Use It?
- ✅ People wanting to learn
custom_stoploss() - ✅ People wanting to learn PSAR application
- ✅ Quant newbies (simple code)
- ✅ People wanting to develop their own strategies
Who Should NOT Use It?
- ❌ People wanting to make money directly in live trading
- ❌ People looking for mature strategies
- ❌ People who don't want to modify code
My Advice
- Learning first: Don't think about live trading, learn first
- Understand the principles: Get how
custom_stoploss()works - Modify and improve: Add your own logic on top
- Test live: Consider live trading only after modifications
9. What Can You Learn?
9.1 Core Tech: custom_stoploss()
This is one of Freqtrade's official examples, specifically demonstrating custom_stoploss() usage.
You'll Learn:
custom_stoploss()function signature and parameters- How to get latest candle data
- How to calculate and return dynamic stoploss values
custom_infodata storage tricks
9.2 Performance in Different Markets (Plain English Version)
| Market Type | Rating | Plain English Explanation |
|---|---|---|
| 📈 Slow bull /ranging upward | ⭐⭐⭐☆☆ | PSAR stoploss follows trend, but entry logic is simple |
| 🔄 Wide-range oscillation | ⭐⭐☆☆☆ | PSAR triggers frequent stoploss in ranging markets |
| 📉 One-way crash | ⭐☆☆☆☆ | No trend filter, prone to consecutive losses |
| ⚡️ Extreme sideways | ⭐☆☆☆☆ | PSAR crosses frequently, signals chaotic |
One-Liner Summary: Good for learning, skip for live trading
10. Want to Run This? Check These Settings First
10.1 Pair Configuration
| Setting | Suggested Value | Roast |
|---|---|---|
| Number of pairs | 10-20 | It's an example, don't overdo it |
| Quote currency | USDT | Don't use BTC/ETH as quote |
| Max open trades | 1-3 | Control risk |
| Timeframe | 1h | Mandatory, can't change |
10.2 Hardware Requirements (This Strategy Is Friendly!)
Minimal computation, very low VPS requirements:
| Pairs | Min RAM | Recommended RAM | Experience |
|---|---|---|---|
| 10-20 pairs | 512MB | 1GB | Runs easily |
Warning: This is one of the few quant strategies that can run on a Raspberry Pi 😅
10.3 Backtest vs Live
custom_info behaves differently in live vs backtest:
In Backtest:
- Can use
current_timefor indexing directly - Data is pre-loaded
In Live:
- Need to use
get_analyzed_dataframe()to get data - Data updates in real-time
Suggested Workflow:
- Understand the code logic first
- Backtest to see stoploss effect
- Paper trade to observe live behavior
- Modify and improve before considering live
11. Easter Eggs: The Author's "Little Tricks"
Look closely at the code and you'll find some fun stuff:
-
Detailed comments: Lots of comments in the code
"Afraid you won't understand, I'll make it clear!"
-
Entry logic ridiculously simple: Just PSAR decreasing
"I'm focused on teaching stoploss, entry logic is just thrown together!"
-
Sell signal set to 0:
dataframe.loc[:, "sell"] = 0"Who needs sell signals? Stoploss isn't good enough?"
12. Final Thoughts
One-Liner
"A textbook that can't make money but can teach you to make money"
Who Should Use It?
- ✅ People wanting to learn custom stoploss
- ✅ Quant newbies
- ✅ People wanting to develop their own strategies
Who Should NOT Use It?
- ❌ People wanting to make money directly in live trading
- ❌ People who don't want to modify code
Manual Trader Tips
Manual traders can learn the PSAR stoploss approach:
- PSAR can serve as dynamic stoploss reference
- When price rises, PSAR rises with it
- Consider exiting when price breaks below PSAR
13. ⚠️ Risk Reminder (Must Read This Section)
This Is an Example Strategy!
CustomStoplossWithPSAR is an educational example, not a production strategy:
This strategy's entry logic is overly simple, live trading may result in losses.
Simply put: It's a training car, not a race car!
Hidden Risks of Example Strategies
In live trading, simple logic can lead to:
- Consecutive losses: Entry conditions too simple, win rate may be low
- Ranging market beatdown: PSAR triggers frequent stoploss in sideways markets
- No trend protection: Will buy even in downtrends
My Advice (Real Talk)
1. Treat this as a textbook, don't trade live directly
2. Understand how custom_stoploss() works
3. Add your own entry logic on top
4. Add trend filters, BTC correlation, and other protections
5. Consider live trading only after improvements
Remember: This is a training car. After learning to drive, you need to build your own race car!
Final Reminder: No matter how good the strategy, the market won't say hi before teaching you a lesson. Light position testing, staying alive is most important! 🙏