资源加载中... loading...

Multi-level Batch Take Profit BTC Robot Trading Strategy

Author: ChaoZhang, Date: 2023-10-18 11:12:39
Tags:

img

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

  1. Find entry signals: Generate buy signals when the CC indicator crosses below 0. Buy long positions at this point.

  2. Set stop loss: Set stop loss percentage through input, convert to price level for stop loss.

  3. Set multiple take profit points: 4 exit points, set take profit percentage for each point through input, convert to price levels.

  4. 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:

  1. Reliable entry signal by buying at the lowest point, avoiding buying at highs.

  2. Multi-level take profit locks in partial profits while keeping some profits running.

  3. Stop loss controls risk and limits losses to a certain range.

  4. Batch exits disperses risks, avoiding full losses all at once.

  5. Drawdown can be controlled to some extent.

Risk Analysis

The risks of this strategy are:

  1. CC indicator cannot fully ensure the lowest point, may miss buying opportunities.

  2. Improper stop loss setting may cause unnecessary stop loss.

  3. Improper batch exits may also lead to loss of profits.

  4. Take profit is more difficult in ranging markets.

  5. It may be hard to stop loss in sharp reversals.

Optimization Directions

Potential optimizations:

  1. Optimize entry signals with more indicators or machine learning for better timing.

  2. Optimize stop loss strategy to make it more elastic against market moves.

  3. Optimize exits for better adaptation in ranging and trending markets.

  4. Add trailing stops for more flexible take profits.

  5. 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.


/*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)


More