自定义指标·中性网格策略·低买高卖

CN
1 天前

一、 网格策略核心原理

网格策略是一种简单且有效的量化交易策略,核心思想是利用市场价格上下波动的机会,通过低买高卖的方式,在设定好的区间内反复积累利润。

1、 通俗的例子:

假设我们有一个水果市场的摊位,卖苹果的价格每天波动在$1到$2之间:

 如果有人愿意以$1.5买苹果,我们就卖给他;

 如果价格跌到$1.2,我们就低价进货;

 等价格回涨到$1.7时,又卖出盈利。

即使整个市场的价格是在波动而不是上涨,我们始终通过波动赚取差价,就像网格策略在数字货币市场中的运作原理一样。

2、 核心原理:低买高卖,锁定每段波动的利润

假设你在市场中BTC的价格经常在一定区间内波动(比如$110,000到$130,000之间),但你无法准确判断它是要突破上涨还是下跌。

如果试图一次性买入并等待趋势,你可能会承担较大的风险。此时网格策略的独特优势就显现出来:

 将价格区间($110,000~$130,000)划分为若干“小格子”(比如每$1000是一个格子)。

 每当价格下跌触及某个格子时,就在此买入一定数量

 每当价格上涨触及某个格子时,就在此卖出一定数量

通过这个策略,价格每次在格子间波动,你就捕捉到一次小的利润。而且,不管是横盘震荡还是价格上下大幅波动,只要价格在这个区间内变化,你都能持续获利。

3、 为什么网格策略有效?

从本质上看,很多数字货币价格(如比特币、以太坊)常常呈现波动性强、方向不确定的特性。这种涨涨跌跌的行情,非常适合网格策略,原因有以下几点:

(1)价格不会“一直涨”或“一直跌”:

大多数时间里,市场价格会经历上涨、下跌、震荡的循环。即使价格呈现长期趋势,它们也通常伴随着短期的回调和反弹。网格策略利用这种价格波动,把整体趋势拆分成多个小范围的交易机会。

(2)避免了主观判断:

传统方式下,投资者总是希望“低点买入、高点卖出”,但往往由于判断错误而错失机会。而网格策略基于“机械化买卖”原则,不需要判断行情的具体方向,只要设定好区间和网格,就可以自动操作,排除情绪干扰。

(3)适合震荡市场,消化恐惧与贪婪:

在震荡行情中,普通投资者可能因为害怕价格跌破支撑、不敢买入,或者因担心错过收益、不知道何时卖出。而网格策略正好在每次市场波动中低位买入、高位卖出,帮助投资者轻松获利。

4、 网格策略的运作机制

假设我们通过网格策略操作一个资产,具体可以分为以下步骤:

1)设置价格区间(高点与低点): 比如预计ETH的价格会在$2000到$3000波动。

2)划分网格: 将区间分成若干小段(比如5格,即每$200为一个格子)。

3)设置每笔交易资金: 假设每个格子买入0.05个ETH,总资金控制在合理范围内。

4)网格触发逻辑:当价格从$2200以上跌到$2200时,买入0.05个ETH;

 当价格从$2200反弹到$2400时,卖出0.05个ETH。

 简单来说,每次触发买入或卖出动作,都实现了一次“低买高卖”。

5)自动化执行: 借助交易所的网格机器人或量化工具,全部操作都会被自动化处理。

自定义指标·中性网格策略·低买高卖_aicoin_图1
二、 中性网格策略的优势

1. 网格的种类划分

1)现货网格

现货网格策略是最常见的网格交易模式,通常在现货市场中运行。通过分布式的买入和卖出操作,在震荡市场中捕捉价差。

适用场景:适合震荡市场

2)趋势网格

趋势网格是对传统网格的一种优化,专门用于捕捉单边上涨或下跌的趋势行情。它根据价格走势调整网格动作,比如动态加仓或减仓。

适用场景:适合明确的单边趋势行情(如币价持续上涨或下跌)

3)反转网格

反转网格是一种在价格达到某个高点或低点时自动调整仓位的网格策略,它以捕捉市场反转为目标。

适用场景:适合高波动的市场环境,尤其适合价格在支撑和压力位之间震荡。

4)中性网格

中性网格是一种更高级的网格策略,通过合约交易同时开设多仓和空仓,以双向布局的方式捕捉市场波动,实现市场方向的中性化操作。

适用场景:适合震荡市场、高波动市场或方向不明确的趋势行情。

2. 不同网格的优缺点分析

自定义指标·中性网格策略·低买高卖_aicoin_图2
3. 中性网格的突出优势

优势 1. 双向获利,市场中性化操作

 中性网格策略通过同时开设多仓和空仓,可以有效盈利于价格的上下波动,不需要对市场方向做任何主观判断。

 即使市场呈现单边上涨或下跌,也能通过双向布局锁定一部分盈利。

优势 2. 风险平衡机制

 传统网格策略在单边行情下可能出现亏损,而中性网格通过双向仓位对冲,显著降低整体风险。

 比如,若价格持续上涨,空单可能出现浮亏,但多单的盈利会覆盖亏损。

优势 3. 高资金利用效率

 现货网格策略需要持有大量现货资产,而中性网格依托于合约系统,可以使用杠杆开仓,从而有效降低资金占用率,同时放大收益潜力。

 即便是低资金用户,也可以通过杠杆操作实现更灵活的网格策略。

优势 4. 适用广泛的市场环境

 无论是震荡市场、高波动市场还是方向不明确的市场,中性网格都具有良好的适应性,它能在多种行情中稳定盈利。

 在不确定市场环境中,投资者可以通过中性网格减少判断方向的压力,利用工具实现“策略性获利”。

三、中性网格策略信号效果

自定义指标·中性网格策略·低买高卖_aicoin_图3

图 OKX-BTCUSDT永续合约 1小时周期 信号展示

自定义指标·中性网格策略·低买高卖_aicoin_图4

图 OKX-BTCUSDT永续合约 1小时周期 回测结果

回测亮点:胜率84%

自定义指标·中性网格策略·低买高卖_aicoin_图5

图 OKX-ETHUSDT永续合约 30分钟周期 信号效

自定义指标·中性网格策略·低买高卖_aicoin_图6​​​​​​​

图 OKX-ETHUSDT 永续合约 30分钟周期 回测结果

回测亮点:胜率83%+

四、指标源码

//@version=2

// 在这里创建您的自定义脚本

// 合约中性网格(高于基准价格做空,低于基准价格做多),当前网格上下各10格(共20格),写死在代码里面的。

 

// 基准价格,高于基准价格做空,低于基准价格做多

low_price = 100000

high_price = 130000

 

base_price = (high_price + low_price)/2.0

 

// 每一格的差距,0.01即1%。

gap = (high_price - low_price)/10/base_price

 

ratio = 1.0 //补仓数量比例

amount0 = 0.1 // 初始数量

amount1 = amount0 * ratio

amount2 = amount1 * ratio

amount3 = amount2 * ratio

amount4 = amount3 * ratio

amount5 = amount4 * ratio

amount6 = amount5 * ratio

amount7 = amount6 * ratio

amount8 = amount7 * ratio

amount9 = amount8 * ratio

 

// 是否开了对应的空单,true为开了单。

var short_status0 = false

var short_status1 = false

var short_status2 = false

var short_status3 = false

var short_status4 = false

var short_status5 = false

var short_status6 = false

var short_status7 = false

var short_status8 = false

var short_status9 = false

 

var long_status0 = false

var long_status1 = false

var long_status2 = false

var long_status3 = false

var long_status4 = false

var long_status5 = false

var long_status6 = false

var long_status7 = false

var long_status8 = false

var long_status9 = false

 

long_prices0 = base_price*(1-gap*1)

long_prices1 = base_price*(1-gap*2)

long_prices2 = base_price*(1-gap*3)

long_prices3 = base_price*(1-gap*4)

long_prices4 = base_price*(1-gap*5)

long_prices5 = base_price*(1-gap*6)

long_prices6 = base_price*(1-gap*7)

long_prices7 = base_price*(1-gap*8)

long_prices8 = base_price*(1-gap*9)

long_prices9 = base_price*(1-gap*10)

 

short_prices0 = base_price*(1+gap*1)

short_prices1 = base_price*(1+gap*2)

short_prices2 = base_price*(1+gap*3)

short_prices3 = base_price*(1+gap*4)

short_prices4 = base_price*(1+gap*5)

short_prices5 = base_price*(1+gap*6)

short_prices6 = base_price*(1+gap*7)

short_prices7 = base_price*(1+gap*8)

short_prices8 = base_price*(1+gap*9)

short_prices9 = base_price*(1+gap*10)

 

// Long entry conditions

long0 = close < long_prices0 and not long_status0

long1 = close < long_prices1 and not long_status1

long2 = close < long_prices2 and not long_status2

long3 = close < long_prices3 and not long_status3

long4 = close < long_prices4 and not long_status4

long5 = close < long_prices5 and not long_status5

long6 = close < long_prices6 and not long_status6

long7 = close < long_prices7 and not long_status7

long8 = close < long_prices8 and not long_status8

long9 = close < long_prices9 and not long_status9

 

enterLongAmount(long0, id = 'long0', price='market', amount=amount0)

enterLongAmount(long1, id = 'long1', price='market', amount=amount1)

enterLongAmount(long2, id = 'long2', price='market', amount=amount2)

enterLongAmount(long3, id = 'long3', price='market', amount=amount3)

enterLongAmount(long4, id = 'long4', price='market', amount=amount4)

enterLongAmount(long5, id = 'long5', price='market', amount=amount5)

enterLongAmount(long6, id = 'long6', price='market', amount=amount6)

enterLongAmount(long7, id = 'long7', price='market', amount=amount7)

enterLongAmount(long8, id = 'long8', price='market', amount=amount8)

enterLongAmount(long9, id = 'long9', price='market', amount=amount9)

 

plotText(long0, title='long0', text='多0', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long1, title='long1', text='多1', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long2, title='long2', text='多2', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long3, title='long3', text='多3', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long4, title='long4', text='多4', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long5, title='long5', text='多5', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long6, title='long6', text='多6', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long7, title='long7', text='多7', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long8, title='long8', text='多8', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(long9, title='long9', text='多9', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

 

if long0 {

long_status0 := true

}

if long1 {

long_status1 := true

}

if long2 {

long_status2 := true

}

if long3 {

long_status3 := true

}

if long4 {

long_status4 := true

}

if long5 {

long_status5 := true

}

if long6 {

long_status6 := true

}

if long7 {

long_status7 := true

}

if long8 {

long_status8 := true

}

if long9 {

long_status9 := true

}

 

// Short entry conditions

short0 = close > short_prices0 and not short_status0

short1 = close > short_prices1 and not short_status1

short2 = close > short_prices2 and not short_status2

short3 = close > short_prices3 and not short_status3

short4 = close > short_prices4 and not short_status4

short5 = close > short_prices5 and not short_status5

short6 = close > short_prices6 and not short_status6

short7 = close > short_prices7 and not short_status7

short8 = close > short_prices8 and not short_status8

short9 = close > short_prices9 and not short_status9

 

enterShortAmount(short0, id='short0', price='market', amount=amount0)

enterShortAmount(short1, id='short1', price='market', amount=amount1)

enterShortAmount(short2, id='short2', price='market', amount=amount2)

enterShortAmount(short3, id='short3', price='market', amount=amount3)

enterShortAmount(short4, id='short4', price='market', amount=amount4)

enterShortAmount(short5, id='short5', price='market', amount=amount5)

enterShortAmount(short6, id='short6', price='market', amount=amount6)

enterShortAmount(short7, id='short7', price='market', amount=amount7)

enterShortAmount(short8, id='short8', price='market', amount=amount8)

enterShortAmount(short9, id='short9', price='market', amount=amount9)

 

plotText(short0, title='short0', text='空0', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short1, title='short1', text='空1', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short2, title='short2', text='空2', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short3, title='short3', text='空3', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short4, title='short4', text='空4', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short5, title='short5', text='空5', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short6, title='short6', text='空6', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short7, title='short7', text='空7', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short8, title='short8', text='空8', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(short9, title='short9', text='空9', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

 

if short0 {

short_status0 := true

}

if short1 {

short_status1 := true

}

if short2 {

short_status2 := true

}

if short3 {

short_status3 := true

}

if short4 {

short_status4 := true

}

if short5 {

short_status5 := true

}

if short6 {

short_status6 := true

}

if short7 {

short_status7 := true

}

if short8 {

short_status8 := true

}

if short9 {

short_status9 := true

}

 

// Long exit conditions

exit_long0 = close > base_price and long_status0

exit_long1 = close > long_prices0 and long_status1

exit_long2 = close > long_prices1 and long_status2

exit_long3 = close > long_prices2 and long_status3

exit_long4 = close > long_prices3 and long_status4

exit_long5 = close > long_prices4 and long_status5

exit_long6 = close > long_prices5 and long_status6

exit_long7 = close > long_prices6 and long_status7

exit_long8 = close > long_prices7 and long_status8

exit_long9 = close > long_prices8 and long_status9

 

exitLongAmount(exit_long0, id='exit_long0', price='market', amount=amount0)

exitLongAmount(exit_long1, id='exit_long1', price='market', amount=amount1)

exitLongAmount(exit_long2, id='exit_long2', price='market', amount=amount2)

exitLongAmount(exit_long3, id='exit_long3', price='market', amount=amount3)

exitLongAmount(exit_long4, id='exit_long4', price='market', amount=amount4)

exitLongAmount(exit_long5, id='exit_long5', price='market', amount=amount5)

exitLongAmount(exit_long6, id='exit_long6', price='market', amount=amount6)

exitLongAmount(exit_long7, id='exit_long7', price='market', amount=amount7)

exitLongAmount(exit_long8, id='exit_long8', price='market', amount=amount8)

exitLongAmount(exit_long9, id='exit_long9', price='market', amount=amount9)

 

plotText(exit_long0, title='exit_long0', text='平多0', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long1, title='exit_long1', text='平多1', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long2, title='exit_long2', text='平多2', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long3, title='exit_long3', text='平多3', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long4, title='exit_long4', text='平多4', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long5, title='exit_long5', text='平多5', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long6, title='exit_long6', text='平多6', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long7, title='exit_long7', text='平多7', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long8, title='exit_long8', text='平多8', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

plotText(exit_long9, title='exit_long9', text='平多9', refSeries=high, bgColor='red', color='white', fontSize=14, placement='top', display=true)

 

if(exit_long0) {

long_status0 := false

}

if(exit_long1) {

long_status1 := false

}

if(exit_long2) {

long_status2 := false

}

if(exit_long3) {

long_status3 := false

}

if(exit_long4) {

long_status4 := false

}

if(exit_long5) {

long_status5 := false

}

if(exit_long6) {

long_status6 := false

}

if(exit_long7) {

long_status7 := false

}

if(exit_long8) {

long_status8 := false

}

if(exit_long9) {

long_status9 := false

}

 

// Short exit conditions

exit_short0 = close < base_price and short_status0

exit_short1 = close < short_prices0 and short_status1

exit_short2 = close < short_prices1 and short_status2

exit_short3 = close < short_prices2 and short_status3

exit_short4 = close < short_prices3 and short_status4

exit_short5 = close < short_prices4 and short_status5

exit_short6 = close < short_prices5 and short_status6

exit_short7 = close < short_prices6 and short_status7

exit_short8 = close < short_prices7 and short_status8

exit_short9 = close < short_prices8 and short_status9

 

exitShortAmount(exit_short0, id='exit_short0', price='market', amount=amount0)

exitShortAmount(exit_short1, id='exit_short1', price='market', amount=amount1)

exitShortAmount(exit_short2, id='exit_short2', price='market', amount=amount2)

exitShortAmount(exit_short3, id='exit_short3', price='market', amount=amount3)

exitShortAmount(exit_short4, id='exit_short4', price='market', amount=amount4)

exitShortAmount(exit_short5, id='exit_short5', price='market', amount=amount5)

exitShortAmount(exit_short6, id='exit_short6', price='market', amount=amount6)

exitShortAmount(exit_short7, id='exit_short7', price='market', amount=amount7)

exitShortAmount(exit_short8, id='exit_short8', price='market', amount=amount8)

exitShortAmount(exit_short9, id='exit_short9', price='market', amount=amount9)

 

plotText(exit_short0, title='exit_short0', text='平空0', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short1, title='exit_short1', text='平空1', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short2, title='exit_short2', text='平空2', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short3, title='exit_short3', text='平空3', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short4, title='exit_short4', text='平空4', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short5, title='exit_short5', text='平空5', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short6, title='exit_short6', text='平空6', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short7, title='exit_short7', text='平空7', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short8, title='exit_short8', text='平空8', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

plotText(exit_short9, title='exit_short9', text='平空9', refSeries=low, bgColor='green', color='white', fontSize=14, placement='bottom', display=true)

 

if (exit_short0) {

short_status0 := false

}

if (exit_short1) {

short_status1 := false

}

if (exit_short2) {

short_status2 := false

}

if (exit_short3) {

short_status3 := false

}

if (exit_short4) {

short_status4 := false

}

if (exit_short5) {

short_status5 := false

}

if (exit_short6) {

short_status6 := false

}

if (exit_short7) {

short_status7 := false

}

if (exit_short8) {

short_status8 := false

}

if (exit_short9) {

short_status9 := false

}

plot(base_price, color='gray', lineDash=[2,4])

自定义指标·中性网格策略·低买高卖_aicoin_图7

(该策略需要运行在AiCoin自定义指标板块)

五、综合

网格交易是一种经典的量化策略,从现货网格到趋势网格、反转网格,再到中性网格,每种策略都有各自的特点与适用场景。其中,中性网格凭借其多空双向布局,实现了市场中性化操作,在不同市场环境中表现更为出色。

中性网格的核心优势:

1. 双向盈利,适应多种行情:无论市场震荡还是单边走势,多头与空头仓位都能通过波动捕捉利润,实现更高的容错性。

2. 更高的资金利用率:依托合约杠杆,中性网格减少了现货仓位的资金占用,放大了收益潜力。

3. 自动化与风险平衡:无需主观判断市场方向,靠系统化操作实现稳定输出,适合复杂、高波动市场。

无论您是追求稳健回报的投资新手,还是注重效率和风险控制的资深玩家,中性网格都能为您提供一种高效、灵活、稳健的交易方式。

 

加入我们的社区,一起来讨论,一起变得更强吧!

官方电报(Telegram)社群t.me/aicoincn

AiCoin中文推特https://x.com/AiCoinzh

群聊 - 致富群https://www.aicoin.com/link/chat?cid=10013​​​​​​​

免责声明:本文章仅代表作者个人观点,不代表本平台的立场和观点。本文章仅供信息分享,不构成对任何人的任何投资建议。用户与作者之间的任何争议,与本平台无关。如网页中刊载的文章或图片涉及侵权,请提供相关的权利证明和身份证明发送邮件到support@aicoin.com,本平台相关工作人员将会进行核查。

Bybit:白拿50U新人礼+5000U充值返利,真实到账,羊毛稳稳薅!
廣告
分享至:
APP下載

X

Telegram

Facebook

Reddit

複製鏈接