
In the field of quantitative trading, the rolling position strategy is an attractive yet challenging topic. The core concept of this strategy is to reinvest realized profits back into trades during trending markets, achieving compound growth. This article will explore in depth how to transform the trading idea of rolling positions step by step into executable code logic, focusing on the thought process rather than technical details. It should be noted that while the rolling position strategy amplifies returns, it also amplifies risks. This article is intended for educational and discussion purposes only.
strategy: https://www.fmz.com/strategy/521864
The profit logic of the rolling position strategy is essentially a compound growth model. Let’s understand this with a simplified example:
Traditional single trade (3 consecutive 10% gains):
Rolling position trade (3 consecutive 10% gains):
Calculation: 100 × 3x leverage × 10% gain = 30
Calculation: 130 × 3x leverage × 10% gain = 39
Calculation: 169 × 3x leverage × 10% gain = 50.7
Comparison: Under the same market conditions of 3 consecutive 10% gains:
With the same 3 consecutive 10% gains, a single trade yields 99.3 USDT profit, while rolling positions yield 119.7 USDT profit. This difference is the power of compounding.
Expressed mathematically:
Traditional trading: Final capital = Initial capital × (1 + Leverage × Price change)
Rolling position trading: Final capital = Initial capital × (1 + Leverage × Single price change) ^ Number of rolls
This reveals the essence of rolling positions: transforming linear growth into exponential growth. However, it also exposes the risk: a single stop-loss can wipe out all previous compound gains.
Before writing any code, we need to answer three fundamental questions at the strategy level:
Question 1: When to start? (Initial entry)
This requires identifying the signal for the beginning of a trend.
Question 2: When to continue? (Adding rolling positions)
This is the core of rolling positions: how to determine whether the trend continues after taking profit?
Question 3: When to stop? (Exit and observe)
These three questions determine the entire framework of the strategy. Below, we will transform each of them into code logic one by one.
Let’s first understand the ideal application scenario for rolling position strategies.
**Ideal scenario: **
Imagine if you could enter when SHIB started rising from $0.000001, or establish a position on the eve of an altcoin’s explosive rally. Through consecutive rolling positions, 100 USDT could become 10,000 USDT or even more. This is the ultimate dream of the rolling position strategy—entering before a coin explodes and capturing ten-fold or even hundred-fold returns.
**Harsh reality: **
But the problem is, how do you know which coin will surge? And when will it surge?
For most of us, trying to precisely capture such explosive moments is, frankly speaking, pure luck. We cannot predict the future; we can only use historical data and technical indicators to increase the probability of “getting lucky.”
Since we cannot predict which coin will surge, what we can do is: establish an executable set of entry rules and use technical indicators to simulate “trend initiation” signals.
It’s like fishing in a vast ocean. Although we don’t know where the big fish are, we can:
When multiple signals converge, we believe a trend “might” be starting, so we enter and try. If we’re right, we ride the trend and profit through rolling positions; if we’re wrong, we cut losses promptly and exit.
**Choosing technical tools: **
We use a dual EMA system (EMA5 and EMA10) as our trend identification tool. The reasons for this choice are simple:
**Core logic: **
Capture trend turning points by detecting “golden crosses” (EMA5 crossing above EMA10) and “death crosses” (EMA5 crossing below EMA10):
Code approach:
1. Retrieve data from two consecutive candlesticks
2. Calculate EMA5 and EMA10 for each
3. Compare the change in their relative positions
4. Detect crossover → Determine direction → Open position
We won’t delve into the details of golden and death crosses here, as these are fundamental concepts in trading. The key point is: we need a clear, quantifiable entry signal to trigger the starting point of rolling positions.
The rolling position strategy is essentially a rational adventurer’s game. Let’s understand it through a complete scenario:
Game rules:
1. You take out 100 USDT from your exchange account as adventure capital
2. This 100 USDT is managed independently, isolated from other funds in your account
3. You start trading with this 100 USDT:
- Win → Profits are added to the capital pool, continue trading with larger capital (rolling)
- Lose → Stop-loss triggered, return to empty position
4. Repeat this process until:
- Either you lose all 100 USDT (game over)
- Or you roll to a satisfactory amount (voluntary exit)
The brilliance of this game lies in:
This is the most crucial design concept in the rolling position strategy.
Problems with the traditional approach:
Suppose your exchange account has 1,000 USDT:
Capital pool solution:
Create a virtual "strategy capital pool":
Initialization:
strategyCapital = 100 // Allocate 100 USDT from account
1st trade:
Position size = 100 USDT
Profit after take-profit = 30 USDT
strategyCapital = 100 + 30 = 130 USDT
2nd trade (rolling):
Position size = 130 USDT // Automatically uses profit from 1st trade
Profit after take-profit = 39 USDT
strategyCapital = 130 + 39 = 169 USDT
3rd trade (rolling):
Position size = 169 USDT // Continue compounding
...
Advantages of this design:
This is the soul of the rolling position strategy: after a take-profit order is filled, we must make a critical decision—continue rolling or stop?
Decision scenario:
Suppose we're long on BTC:
- Entry price: 45,000 USDT, opened position with 100 USDT
- Take-profit price: 49,500 USDT (10% increase)
- Take-profit filled, profit of 30 USDT
- Current capital pool: 130 USDT
Here's the question:
Option A: Stop, exit with 130 USDT, return to empty position
Option B: Continue, open another long position with 130 USDT (rolling)
How to choose?
This decision cannot rely on “intuition”; it must have clear criteria. Our judgment logic is: Is the trend still continuing?
Judgment method:
At the moment the take-profit order is filled, recalculate the latest technical indicators (EMA):
If the original direction is long:
Check if EMA5 is still above EMA10?
- Yes → Uptrend not broken → Continue long (rolling)
- No → Trend may be weakening → Stop, end this round
If the original direction is short:
Check if EMA5 is still below EMA10?
- Yes → Downtrend not broken → Continue short (rolling)
- No → Trend may be weakening → Stop, end this round
If the decision is “continue rolling”:
1. Update capital pool
strategyCapital = Original capital + Current profit
2. Reopen position based on new capital pool
New position size = strategyCapital × Leverage
3. Place new take-profit order
New take-profit price = New entry price × (1 + Take-profit ratio)
4. Set new stop-loss price
New stop-loss price = New entry price × (1 - Stop-loss ratio)
5. Increment rolling counter
rolls = rolls + 1
If the decision is “stop”:
1. Save statistics for this round
- Number of rolls
- Total profit
- How much 100 grew to
- Duration
2. Retain capital pool amount
strategyCapital keeps current value
3. Return to empty position
Wait for next entry signal
Key points of this flow:
Let’s feel the power of compounding through a complete example:
Success case:
Initial capital: 100 USDT
Take-profit ratio: 10%
Leverage: 3x
Round 1: 100 USDT → Profit 30 → Capital pool 130
Round 2: 130 USDT → Profit 39 → Capital pool 169
Round 3: 169 USDT → Profit 50.7 → Capital pool 219.7
Round 4: 219.7 USDT → Profit 65.9 → Capital pool 285.6
Round 5: 285.6 USDT → Profit 85.7 → Capital pool 371.3
Rolling 5 consecutive times, 100 becomes 371.3, a 271% increase!
Failure case:
Round 1: 100 USDT → Profit 30 → Capital pool 130
Round 2: 130 USDT → Profit 39 → Capital pool 169
Round 3: 169 USDT → Trend reverses → Stop-loss triggered
Stop-loss ratio 5%, loss: 169 × 3 × 5% = 25.35 USDT
Remaining capital: 169 - 25.35 = 143.65 USDT
Originally rolled from 100 to 169, after one stop-loss only 143.65 remains
This is the double-edged sword of rolling positions:
Active exit: Trend weakening — This situation was already addressed in “Question Two”—after take-profit, if the trend doesn’t support continuation, we actively choose to stop. This is the ideal exit method, leaving with profits.
Passive exit: Stop-loss triggered — This is what we need to focus on now—when the market moves against us, price hits the stop-loss line, and we’re forced to close the position.
Many people dislike stop-losses because:
But in the rolling position strategy, stop-loss is the lifeline for survival. Think about it:
Without stop-loss:
Round 1: 100 → Rolled to 169
Round 2: 169 → Trend reverses, no stop-loss
Price keeps falling: 169 → 150 → 120 → 80 → 50...
Could eventually lose everything, or even get liquidated
With stop-loss:
Round 1: 100 → Rolled to 169
Round 2: 169 → Trend reverses, stop-loss triggered
Stop-loss 5%: Loss of 25.35
Remaining: 143.65
Although a loss occurred, most of the capital is preserved
Can wait for the next opportunity
The essence of stop-loss: Use small, certain losses to avoid large, uncertain risks.
Remember the “rational adventurer’s game” we mentioned? This game has clear ending conditions:
Condition 1: Capital pool reaches zero
If strategyCapital <= 0:
→ Game over
→ This adventure failed
→ 100 USDT completely lost
Condition 2: Voluntary exit
If strategyCapital >= Target amount (e.g., 500):
→ Can choose to exit voluntarily
→ Lock in profits
→ Start a new round with 100 USDT
Condition 3: Maximum rolling count reached
Can set a safety threshold:
If consecutive rolls >= 10:
→ Exit voluntarily even if trend continues
→ Because duration is too long, risk accumulates
→ Quit while you're ahead
The core of the entire rolling position strategy design is finding balance between risk and reward:
Reward side:
Risk side:
Backtest reference:
Analysis of TRUMP_USDT Binance futures listing day backtest (January 20, 2025 to January 21, 2025):

Through the analysis above, we can clearly see that this strategy is essentially simulating:
The trading behavior of a rational adventurer:
Its core logic is:
Limitation 1: Depends on trending markets
This strategy performs poorly in ranging markets because:
Limitation 2: Parameter sensitivity
Parameters like 10% take-profit and 5% stop-loss are not optimal:
Limitation 3: Cannot predict explosive moments
As mentioned earlier, using technical indicators for entry is essentially “relying on luck”:
Direction 1: Combine with workflows to screen coins
Direction 2: Dynamically adjust parameters
Direction 3: Multiple capital pools in parallel
Through the exploration of three core questions, we have fully demonstrated how to transform the trading idea of rolling positions into code logic. The essence of this process is: expressing a rational adventurer’s trading mindset through precise rules and data structures.
Important note:
This is merely a simulated implementation of the rolling position concept. In reality, rolling positions is a trading strategy that requires significant market experience. This strategy is just a tool. When combined with workflows to identify trending or highly explosive coins in the future, using this tool may bring us more surprises.
Remember:
There is no strategy that guarantees profits without losses—rolling positions is just a tool. What truly determines success or failure is whether you can:
Wishing everyone success in finding their own “big break” on the path of quantitative trading!