
この戦略は,固定格子取引の方法を採用し,初期価格と各格子間隔の比率を設定し,その比率に基づいて10層の固定買い値と販売価格を設定し,低買い高売り格子取引戦略を実現する.
この戦略は,まず,初期価格spriceと各層格子間隔の割合gridpercentを設定します. そして,初期価格と比例に基づいて10層の買付と販売価格を計算します.
購入価格の公式は
b1=sprice-(sprice*p1)
b2=sprice-(sprice*p2)
b3=sprice-(sprice*p3)
…
このうち,p1~p10は,gridpercentによって層ごとに計算された比率である.
売る価格の公式は
s1=b1+(sprice*p1)
s2=b2+(sprice*p1)
s3=b3+(sprice*p1)
…
購入条件は,閉店価格が購入価格より低いときに購入を誘発する:
if (close
strategy.entry(“b1”, strategy.long, when=(close
また,閉店価格が販売価格より高いとき,販売が引き出される:
if (close>s1)
strategy.exit(“b1”, when=(close>s1))
固定網の低買高売という戦略が実現した.
固定網の戦略には以下の利点があります.
市場をタイミング化せず,取引の難易度を下げることで,自動で低価格で買い高価格で売れるようになりました.
合理的な格子間隔を設定することで,リスクを効果的にコントロールし,追いつくのを避けることができます.
市場が上昇するか下落するかは別として,利益を得ることができます.
格子パラメータを調整することで異なる市場状況に適応できます.
格子層の数を増やすことで保有規模を拡大することができる.
ストップ・ローズと組み合わせて,極端な状況で大きな損失を回避できます.
この戦略にはいくつかのリスクがあります.
取引が横行すると,取引費が利益を損なう.
スタート価格と格子設定が不適切で,損がつきやすい.
価格が急激に上昇すると,損失が発生する可能性があります.
機械取引システムには取引の並び込みのリスクがあります.
集中爆破事件により損失が拡大した.
解決策は次の通りです
格子パラメータを合理的に設定し,取引費用より利益が大きいことを保証します.
適した初期価格と格子間隔を設定する最適化パラメータを反測する.
リスク管理のためのストップダスの増加
取引価格の適切な緩和により,並び並びを避ける.
リスクコントロールを設定し,最大損失を制限する.
この戦略は以下の方向から最適化できます.
格子間隔を動的に調整し,波動が大きくなると格子間隔を広げ,格子間隔を小さくする.
初期価格の動的調整は,歴史的なデータに基づいて変動範囲を計算します.
価格の動きを予測する機械学習モデルと,動的調整のグリッドを組み込む.
リスクの高いポイントでストップを追加し,歴史的なストップポイントを観察することでストップポジションを最適化します.
資金管理戦略と連携して,利益状況に応じてポジションを動的に調整する.
ポジション管理を最適化し,資金利用の効率を最大化する.
TWAPなどのアルゴリズムを使用して,取引の実行を最適化し,衝撃コストを削減します.
この戦略は,固定格子取引の方法を採用し,初期価格と格子間隔の比率に基づいて買入販売価格を設定し,自動化された低買高売り取引を実現し,市場変動を有効に活用できます. また,リスク管理にも注意し,パラメータ最適化,動的調整および停止により利益をロックし,損失を制御してください. 機械学習と資金管理の高度な手段を組み合わせて,戦略の収益率と勝利率をさらに向上させることができます.
/*backtest
start: 2022-11-09 00:00:00
end: 2023-11-15 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lionkind
//@version=5
strategy("Grid HW", overlay = true, margin_long = 1, margin_short = 1)
// Fix 35k price as starting point and 1% as a distance
sprice=input(40500,"Starting price")
gridpercent=input(1,"Percent")
// calculate the % of the 10 layers
p1=((gridpercent*1)/100)
p2=((gridpercent*2)/100)
p3=((gridpercent*3)/100)
p4=((gridpercent*4)/100)
p5=((gridpercent*5)/100)
p6=((gridpercent*6)/100)
p7=((gridpercent*7)/100)
p8=((gridpercent*8)/100)
p9=((gridpercent*9)/100)
p10=((gridpercent*10)/100)
//set buy prices
b1=sprice-(sprice*p1)
b2=sprice-(sprice*p2)
b3=sprice-(sprice*p3)
b4=sprice-(sprice*p4)
b5=sprice-(sprice*p5)
b6=sprice-(sprice*p6)
b7=sprice-(sprice*p7)
b8=sprice-(sprice*p8)
b9=sprice-(sprice*p9)
b10=sprice-(sprice*p10)
//set sell prices
s1=b1+(sprice*p1)
s2=b2+(sprice*p1)
s3=b3+(sprice*p1)
s4=b4+(sprice*p1)
s5=b5+(sprice*p1)
s6=b6+(sprice*p1)
s7=b7+(sprice*p1)
s8=b8+(sprice*p1)
s9=b9+(sprice*p1)
s10=b10+(sprice*p1)
//Long conditions
lc1=close<b1
lc2=close<b2
lc3=close<b3
lc4=close<b4
lc5=close<b5
lc6=close<b6
lc7=close<b7
lc8=close<b8
lc9=close<b9
lc10=close<b10
//exit conditions
ec1=close>s1
ec2=close>s2
ec3=close>s3
ec4=close>s4
ec5=close>s5
ec6=close>s6
ec7=close>s7
ec8=close>s8
ec9=close>s9
ec10=close>s10
//long orders
if (lc1)
strategy.entry("b1", strategy.long, when=(lc1))
if (lc2)
strategy.entry("b2", strategy.long, when=(lc2))
if (lc3)
strategy.entry("b3", strategy.long, when=(lc3))
if (lc4)
strategy.entry("b4", strategy.long, when=(lc4))
if (lc5)
strategy.entry("b5", strategy.long, when=(lc5))
if (lc6)
strategy.entry("b6", strategy.long, when=(lc6))
if (lc7)
strategy.entry("b7", strategy.long, when=(lc7))
if (lc8)
strategy.entry("b8", strategy.long, when=(lc8))
if (lc9)
strategy.entry("b9", strategy.long, when=(lc9))
if (lc10)
strategy.entry("b10", strategy.long, when=(lc10))
//exit orders
if (ec1)
strategy.exit("b1", when=(ec1), limit=1)
if (ec2)
strategy.exit("b2", when=(ec2), limit=1)
if (ec3)
strategy.exit("b3", when=(ec3), limit=1)
if (ec4)
strategy.exit("b4", when=(ec4), limit=1)
if (ec5)
strategy.exit("b5", when=(ec5), limit=1)
if (ec6)
strategy.exit("b6", when=(ec6), limit=1)
if (ec7)
strategy.exit("b7", when=(ec7), limit=1)
if (ec8)
strategy.exit("b8", when=(ec8), limit=1)
if (ec9)
strategy.exit("b9", when=(ec9), limit=1)
if (ec10)
strategy.exit("b10", when=(ec10), limit=1)
plot(b1,color=color.green)
plot(s1, color=color.red)
plot(b2, color=color.purple)