Strategy vault / Machine learning
Multi level Batch Take Profit BTC Robot Trading Strategy
This is a multi-level batch take profit BTC robot trading strategy. It enters long positions by finding the lowest point and sets multiple take profit points for batch exits. It also sets a stop loss point for risk…

Overview
This is a multi-level batch take profit BTC robot trading strategy. It enters long positions by finding the lowest point and sets multiple take profit points for batch exits. It also sets a stop loss point for risk control. This strategy is suitable when being bullish on BTC.
Strategy Logic
Find entry signals: Generate buy signals when the CC indicator crosses below 0. Buy long positions at this point.
Set stop loss: Set stop loss percentage through input, convert to price level for stop loss.
Set multiple take profit points: 4 exit points, set take profit percentage for each point through input, convert to price levels.
Risk control: Set maximum position size, set exit percentage for each exit point through input for risk dispersion.
Advantage Analysis
The advantages of this strategy are:
Reliable entry signal by buying at the lowest point, avoiding buying at highs.
Multi-level take profit locks in partial profits while keeping some profits running.
Stop loss controls risk and limits losses to a certain range.
Batch exits disperses risks, avoiding full losses all at once.
Drawdown can be controlled to some extent.
Risk Analysis
The risks of this strategy are:
CC indicator cannot fully ensure the lowest point, may miss buying opportunities.
Improper stop loss setting may cause unnecessary stop loss.
Improper batch exits may also lead to loss of profits.
Take profit is more difficult in ranging markets.
It may be hard to stop loss in sharp reversals.
Optimization Directions
Potential optimizations:
Optimize entry signals with more indicators or machine learning for better timing.
Optimize stop loss strategy to make it more elastic against market moves.
Optimize exits for better adaptation in ranging and trending markets.
Add trailing stops for more flexible take profits.
Test different assets for best parameter sets.
Conclusion
In summary, this is a BTC trading strategy based on buying at lowest points with multi-level take profits and stop loss. It has certain advantages and also areas that can be improved. Further optimizations on drawdown control and take profit could make the strategy perform better. Overall it provides a viable approach for BTC algorithmic trading.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 0 | Strategy Direction: long | short | all |
| v_input_2 | W | higherTF |
| v_input_3 | 2 | factor |
| v_input_4 | 21 | length |
| v_input_5 | 15 | stop loss |
| v_input_6 | 25 | qty_percent1 |
| v_input_7 | 25 | qty_percent2 |
| v_input_8 | 25 | qty_percent3 |
| v_input_9 | 3 | Take profit1 |
| v_input_10 | 5 | Take profit2 |
| v_input_11 | 7 | Take profit3 |
| v_input_12 | 10 | Take profit4 |
Source Pine Script
/*backtest
start: 2023-09-17 00:00:00
end: 2023-10-17 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["v_input_1",2]]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RafaelZioni
// © theCrypster 2020
//@version=4
// strategy(title = "BTC bot", overlay = true, pyramiding=1,initial_capital = 10000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.075)
strat_dir_input = input(title="Strategy Direction", defval="long", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)
//INPUTS
higherTF = input("W", type=input.resolution)
pc = security(syminfo.tickerid, higherTF, close[1], lookahead=true)
ph = security(syminfo.tickerid, higherTF, high[1], lookahead=true)
pl = security(syminfo.tickerid, higherTF, low[1], lookahead=true)
PP = 0.0,R1 = 0.0, R2 = 0.0, R3 = 0.0,S1 = 0.0, S2 = 0.0, S3 = 0.0
PP := (ph + pl + pc) / 3
R1 := PP + (PP - pl)
S1 := PP - (ph - PP)
R2 := PP + (ph - pl)
S2 := PP - (ph - pl)
factor=input(2)
R3 := ph + factor * (PP - pl)
S3 := pl - 2 * (ph - PP)
//
length=input(21)
//
p = close
vrsi = rsi(p, length)
pp=ema(vrsi,length)
d=(vrsi-pp)*5
cc=(vrsi+d+pp)/2
//
low1=crossover(cc,0)
sell=crossover(close[1],R3)
//
l = low1
s=sell
if l
strategy.entry("buy", strategy.long)
if s
strategy.entry("sell", strategy.short)
per(pcnt) =>
strategy.position_size != 0 ? round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)
stoploss=input(title=" stop loss", defval=15, minval=0.01)
los = per(stoploss)
q1=input(title=" qty_percent1", defval=25, minval=1)
q2=input(title=" qty_percent2", defval=25, minval=1)
q3=input(title=" qty_percent3", defval=25, minval=1)
tp1=input(title=" Take profit1", defval=3, minval=0.01)
tp2=input(title=" Take profit2", defval=5, minval=0.01)
tp3=input(title=" Take profit3", defval=7, minval=0.01)
tp4=input(title=" Take profit4", defval=10, minval=0.01)
strategy.exit("x1", qty_percent = q1, profit = per(tp1), loss = los)
strategy.exit("x2", qty_percent = q2, profit = per(tp2), loss = los)
strategy.exit("x3", qty_percent = q3, profit = per(tp3), loss = los)
strategy.exit("x4", profit = per(tp4), loss = los)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-18. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Multi-level-Batch-Take-Profit-BTC-Robot-Trading-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- AI Driven Dynamic Volatility Adaptive Trend Breakout Trading StrategyPine Script · Machine learning · 2d
- EMA and RSI Quantitative Trading StrategyPine Script · Machine learning · 1h
- MACD Robot Trading StrategyPine Script · Machine learning · 1d
- Multi Indicator Dynamic Adaptive Quantitative Trading StrategyPine Script · Machine learning · 1h
- Triple Moving Average Combined with MACD Quantitative StrategyPine Script · Machine learning · 1d
- kNN based Trend Following StrategyPine Script · Machine learning · 1h