
この戦略は123反転戦略と心理線戦略を組み合わせて,多要素の量化取引戦略を形成する.この戦略は,技術的形態,市場心理などの複数の次元を総合的に考慮し,市場動向を判断する際により正確な決定を行うことができる.
123反転策は,その日の閉盘価格を前日と比較して判断し,上昇し,ゆっくりとしたK線が50を下回ると,多めに行い,下落し,ゆっくりとしたK線が50以上になると空白する.この策は,短期的な反転の特性を利用して利益を得る.
心理線戦略は,一定の周期内の下落比率を統計する.50%以上の上昇は多頭支配市場を表す.50%未満の上昇は空頭支配市場を表す.下落比率に基づいて市場の心理面を判断する.
この戦略は,上記の2つの戦略を組み合わせた信号で,両者が同方向の信号を与えるときにポジションを開き,異方向の信号を与えるときに平仓する.
この戦略は,複数の要因を組み合わせて,市場動向をより正確に判断し,単一の技術指標による誤判を回避します.同時に,市場心理要因を組み合わせて,戦略をより性があり,より複雑な状況に対応できるようにします.
この戦略の各要素パラメータの設定は,戦略のパフォーマンスに大きな影響を与えるだろう.不合理なパラメータの組み合わせは,戦略の効果を大きく下げるかもしれない.さらに,市場状況が急激に変化した場合も,戦略の失敗につながるだろう.リスクを減らすために,我々は,さまざまな市場の動きを大量に反測して,最適なパラメータを見つけ出す必要がある.同時に,ポジションの規模を制御し,単一損失が過大にならないことを保証する必要があります.
既存の基礎に,波動率,取引量などの判断要因を加え続け,より3次元的な戦略論理を作り出すか,機械学習アルゴリズムを加え,戦略のパラメータを自己適応的に最適化することができます.これは,この戦略のさらなる最適化の方向になります.
この戦略は,技術形態と市場心理などの複数の要因を総合的に考慮し,異なる要因間の検証によってシグナルの有効性を確保する.一方で,多くの最適化スペースを残し,より優れたパフォーマンスを得ることを期待する.これは,長期的に追跡,蓄積,最適化に値する最適化戦略である.
/*backtest
start: 2022-12-20 00:00:00
end: 2023-12-26 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 30/04/2021
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
// The strategy sells at market, if close price is lower than the previous close price
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// Psychological line (PSY), as an indicator, is the ratio of the number of
// rising periods over the total number of periods. It reflects the buying
// power in relation to the selling power.
// If PSY is above 50%, it indicates that buyers are in control. Likewise,
// if it is below 50%, it indicates the sellers are in control. If the PSY
// moves along the 50% area, it indicates balance between the buyers and
// sellers and therefore there is no direction movement for the market.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
vFast = sma(stoch(close, high, low, Length), KSmoothing)
vSlow = sma(vFast, DLength)
pos = 0.0
pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0)))
pos
PLine(Length) =>
pos = 0.0
cof = close > close[1]? 1:0
xPSY = sum(cof,Length) / Length * 100
pos:= iff(xPSY > 50, 1,
iff(xPSY < 50, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & Psychological line", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Psychological line ----")
LengthPLine = input(20, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posPLine = PLine(LengthPLine)
pos = iff(posReversal123 == 1 and posPLine == 1 , 1,
iff(posReversal123 == -1 and posPLine == -1, -1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1 , 1, pos))
if (possig == 1 )
strategy.entry("Long", strategy.long)
if (possig == -1 )
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )