Skip to main content

RobotradingBody Strategy In-Depth Analysis

Strategy Number: #350 (350th of 465 strategies)
Strategy Type: Candlestick Body Reversal Strategy + Parameter Optimization
Timeframe: 4 hours (4h)


1. Strategy Overview

RobotradingBody is a reversal trading strategy based on candlestick body size. Its core philosophy is: buy when an abnormally large bearish candle appears (considered oversold), sell when a bullish candle appears (considered rebound complete). The strategy design is concise and clear, with less than 100 lines of code — a typical "small but beautiful" strategy.

This strategy originates from a public script on TradingView, ported to the Freqtrade framework by viksal1982.

Core Features

FeatureDescription
Buy Conditions1 independent buy signal (large bearish candle reversal)
Sell Conditions1 basic sell signal (bullish candle appears)
Protection MechanismsFixed stop-loss + ultra-high ROI target
Timeframe4 hours (4h)
Dependenciestalib, qtpylib
Optimizable Parameters2 (body multiplier, SMA period)

2. Strategy Configuration Analysis

2.1 Basic Risk Parameters

# ROI Exit Table
minimal_roi = {
"0": 0.9 # 90% profit target
}

# Stop-loss setting
stoploss = -0.10 # 10% stop-loss

Design Rationale:

  • Ultra-high ROI target: A 90% profit target is very aggressive, meaning the strategy tends to hold long-term waiting for significant profits
  • Moderate stop-loss: 10% stop-loss gives the strategy enough volatility room, avoiding premature stop-outs
  • No trailing stop: trailing_stop = False, the strategy uses fixed take-profit/stop-loss logic

2.2 Order Type Configuration

order_types = {
'buy': 'limit',
'sell': 'limit',
'stoploss': 'market',
'stoploss_on_exchange': False
}

order_time_in_force = {
'buy': 'gtc',
'sell': 'gtc'
}

Configuration Explanation:

  • Both buy and sell use limit orders, ensuring controllable execution prices
  • Stop-loss uses market orders, ensuring fast execution
  • Order validity GTC (Good Till Cancel), valid until filled or cancelled

3. Buy Conditions Explained

3.1 Buy Logic

The strategy has only one buy condition, but the core judgment criteria are relatively refined:

# Buy condition
(
(dataframe['open'] > dataframe['close']) & # Condition 1: Bearish candle
(dataframe['body'] > dataframe['body_sma']) & # Condition 2: Large body
(dataframe['volume'] > 0) # Condition 3: Has volume
)

Condition Analysis:

ConditionLogicMeaning
Condition 1open > closeCurrent candle is bearish (declining)
Condition 2body > body_smaBody larger than historical mean × multiplier
Condition 3volume > 0Has volume (prevents abnormal data)

3.2 Body Size Judgment Mechanism

The strategy uses a dynamic benchmark to judge "large body":

# Calculate body size
dataframe['body'] = (dataframe['close'] - dataframe['open']).abs()

# Calculate body SMA × multiplier
dataframe['body_sma'] = ta.SMA(dataframe['body'], timeperiod=for_sma_length) * for_mult

Judgment Logic:

  • Calculate the absolute body value of each candle
  • Calculate the SMA mean of body sizes
  • Multiply the SMA by an adjustable multiplier
  • When body > adjusted SMA, consider it a "large body"

3.3 Optimizable Parameters

ParameterRangeDefault ValueDescription
for_mult1-203Amplification multiplier for body judgment
for_sma_length20-200100SMA calculation period

Parameter Interpretation:

  • Larger multiplier: Stricter buy conditions, only captures extreme large bearish candles
  • Longer period: More stable benchmark, but slower reaction to recent market changes

4. Sell Logic Explained

4.1 Sell Conditions

The strategy's sell conditions are equally concise:

# Sell condition
(
(dataframe['close'] > dataframe['open']) & # Condition 1: Bullish candle
(dataframe['volume'] > 0) # Condition 2: Has volume
)

Condition Analysis:

ConditionLogicMeaning
Condition 1close > openCurrent candle is bullish (rising)
Condition 2volume > 0Has volume (prevents abnormal data)

4.2 Sell Logic Analysis

Core Idea:

  • Buy timing: Large bearish candle (oversold signal)
  • Sell timing: Bullish candle (rebound signal)
  • Strategy essence is a simplified version of "bottom fishing and top escaping"

Note:

  • Sell condition doesn't require a large bullish candle — any bullish candle triggers
  • This means the strategy may sell early during the initial rebound, missing larger gains

4.3 Take-Profit and Stop-Loss Mechanism

Exit Mechanism       Trigger Condition
────────────────────────────────────────
ROI Take-Profit Profit ≥ 90%
Stop-Loss Exit Loss ≥ 10%
Signal Sell Bullish candle appears

5. Technical Indicator System

5.1 Core Indicators

Indicator CategorySpecific IndicatorPurpose
Candlestick PatternOpen Price, Close PriceJudge bullish/bearish candles
Body IndicatorBody (absolute value)Measure candlestick body size
Trend IndicatorSMA (body)Dynamic benchmark judgment
VolumeVolumeFilter abnormal data

5.2 Indicator Calculation

# Body size (absolute value)
dataframe['body'] = (dataframe['close'] - dataframe['open']).abs()

# Body SMA × multiplier
dataframe['body_sma'] = ta.SMA(dataframe['body'], timeperiod=for_sma_length) * for_mult

Design Features:

  • Uses only the most basic candlestick data
  • No reliance on complex technical indicators (such as RSI, MACD, Bollinger Bands, etc.)
  • Code is concise, easy to understand and verify

6. Risk Management Features

6.1 Fixed Stop-Loss Mechanism

The strategy uses a fixed 10% stop-loss:

stoploss = -0.10  # 10% stop-loss

Characteristics:

  • Simple and direct, no dynamic calculation needed
  • Gives the strategy enough volatility room
  • Avoids premature stop-outs due to normal fluctuations

6.2 Ultra-High ROI Target

minimal_roi = {"0": 0.9}  # 90% target

Design Intent:

  • Strategy pursues significant profits, not satisfied with small gains
  • Combined with signal selling, actual exit may occur much earlier than 90%
  • ROI is more of an "insurance" than a "target"

6.3 Risk Exposure

Risk PointDescription
Trend RiskStrategy has no trend filtering, may repeatedly bottom-fish during downtrends
False BreakoutsBullish candle sell may be too early, missing larger gains
Parameter SensitivityBody multiplier and SMA period have significant impact on results

7. Strategy Advantages and Limitations

✅ Advantages

  1. Extremely Simple Code: Less than 100 lines, easy to understand and verify
  2. Clear Logic: Buy on large bearish candles, sell on bullish candles — straightforward reversal logic
  3. Optimizable Parameters: 2 parameters can be optimized through hyperparameter optimization to find optimal configuration
  4. Efficient Calculation: No complex indicator calculations, fast execution

⚠️ Limitations

  1. Single Signal Source: Relies only on candlestick patterns, lacks multiple confirmations
  2. No Trend Judgment: May trade against the trend, frequently stop out in downtrends
  3. Loose Sell Conditions: Any bullish candle triggers sell, may exit too early
  4. Wide Stop-Loss: 10% stop-loss may be too large for high-frequency strategies

8. Applicable Scenario Recommendations

Market EnvironmentRecommended ConfigurationDescription
Ranging MarketDefault ParametersFrequent rebounds in ranging markets, suitable for bottom-fishing strategies
DowntrendUse CautiouslyMay repeatedly fail to bottom-fish, recommend reducing position size
UptrendNot RecommendedStrategy designed for bottom-fishing, no use in uptrends
High Volatility MarketIncrease MultiplierRaise buy threshold, filter false signals

9. Suitable Market Environment Explained

RobotradingBody is a typical reversal bottom-fishing strategy. Based on its code architecture, it is most suitable for high-volatility ranging markets and performs poorly in one-way downtrends.

9.1 Strategy Core Logic

  • Bottom-Fishing Mindset: Buy during extreme declines, expect rebound
  • Quick Take-Profit: Sell on any bullish candle, not greedy
  • Dynamic Benchmark: Body size compared to historical mean, adapts to different instruments

9.2 Performance in Different Market Environments

Market TypePerformance RatingReason Analysis
📈 One-Way Uptrend⭐⭐☆☆☆Strategy looks for decline opportunities, few entry points in uptrends
🔄 High-Volatility Ranging⭐⭐⭐⭐⭐Frequent rebounds after large bearish candles, perfectly matches strategy logic
📉 One-Way Downtrend⭐☆☆☆☆High bottom-fishing failure rate, may have consecutive stop-outs
⚡️ Low-Volatility Sideways⭐⭐☆☆☆Bodies too small, difficult to satisfy buy conditions

9.3 Key Configuration Recommendations

Configuration ItemRecommended ValueDescription
for_mult2-4Balance signal quantity and quality
for_sma_length50-150Medium period, balances stability and flexibility
Stop-Loss-0.08 to -0.12Adjust based on instrument volatility
Timeframe4h-1dOriginal design timeframe, not recommended to reduce

10. Important Reminder: The Cost of Complexity

10.1 Learning Curve

This strategy has an extremely low learning curve:

  • Only about 80 lines of code
  • No complex indicators
  • Intuitive and easy to understand logic

10.2 Hardware Requirements

Number of Trading PairsMinimum RAMRecommended RAM
1-20 pairs512MB1GB
20-50 pairs1GB2GB
50+ pairs2GB4GB

Strategy calculation volume is extremely small, hardware requirements are very low.

10.3 Backtesting vs Live Trading Differences

Need to Note:

  • Backtesting may show high win rates, but slippage and fees in live trading will erode profits
  • 90% ROI target may trigger rarely in backtesting, mainly relies on signal selling
  • Candle close confirmation has delays in live trading

10.4 Manual Trader Recommendations

If you want to use this strategy's logic for manual trading:

  1. Wait for a large bearish candle on 4-hour or daily chart
  2. Confirm body is significantly larger than recent average body
  3. Buy and wait for bullish candle to appear
  4. Set 10% stop-loss for protection

11. Summary

RobotradingBody is an extremely simple reversal bottom-fishing strategy. Its core value lies in:

  1. Simple Code: Clear logic, easy to understand and modify
  2. Adjustable Parameters: Two optimizable parameters, adapts to different instruments
  3. Efficient Calculation: No complex indicators, fast execution

For quantitative traders, this is a suitable introductory strategy for learning, and also suitable as a foundational framework for more complex strategies. However, note that the strategy lacks trend filtering and multi-factor confirmation, and may perform poorly in one-way downtrend markets.

It is recommended to verify through backtesting, then combine with other indicators (such as trend filters, volatility indicators) for improvement, or use it as part of a portfolio strategy.