
利略平均線交差策 (Galileo’s line-crossing strategy) は,移動平均線に基づく取引策である.この策は,一定の周期の指数移動平均を計算し,価格と交差比較することで取引シグナルを生成する.価格が上方から下方へと平均線を破るとき,売りシグナルを生成する.価格が下方から平均線を破るとき,買いシグナルを生成する.この策の名前は,利略・利略に由来する.
ガリレオ平均線交差策の核心は指数移動平均 (EMA) である.EMAは,最近の価格により大きな重みを与える傾向にある移動平均アルゴリズムである.その計算式は次のとおりである.
EMA 今日 = (今日閉店価格×平滑常数) + (昨日EMA×−平滑常数))
その中,平滑常数α=(2/(周期数+1)) 。
この戦略は,ユーザの入力された周期長から,リアルタイムでEMA値を計算する. そして,価格とEMAを比較し,両者の交差を判断し,買入と売却の信号として:
価格が上から下へと落ちてEMAを下回ったとき,セールシグナルを生じ,ショートライン操作を行う.
価格が下方からEMAを突破すると,買取シグナルが生み出され,多操作が行われます.
この戦略は,EMA線と,買入シグナルを示す矢印を同時に描きます.
ガリレオの均線交差策には以下の利点がある.
ガリレオの均線交差策には以下のリスクがあります.
ガリレオの均線交差策は以下の方向から最適化できる.
他の指標と組み合わせて,複合戦略を構築し,偽信号を回避し,安定性を高めます.例えば,取引量,トレンド指標などを追加します.
ストップ・ロスを追加し,移動ストップまたはパーセンテージ・ストップを設定し,単一損失を制御する.
EMAの異なるパラメータの効果をテストし,最適なパラメータの組み合わせを選択します. 他のタイプの移動平均もテストできます.
価格の逆転に伴う再入場を評価し,利率を向上させる.
ガリレオの均線交差戦略は,シンプルで実用的な取引戦略で,考え方が明確で,操作が簡単で,量化取引の初心者向けである.継続的な最適化と改善とともに,その効果がますます良くなるだろうと信じられ,推奨される.
/*backtest
start: 2022-12-11 00:00:00
end: 2023-12-17 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/
// © armigoldman
//@version=3
strategy(title="Galileo Galilei", shorttitle="Galileo Galilei", overlay=true, initial_capital = 100000, default_qty_type=strategy.cash, default_qty_value = 100000)
len = input(11, minval=1, title="Length")
src = input(open, title="Source")
out = ema(src, len)
plot(out, title="EMA", color=yellow)
//last8h = highest(close, 8)
//lastl8 = lowest(close, 8)
//plot(last8h, color=red, linewidth=2)
//plot(lastl8, color=green, linewidth=2)
////////////////////////////////////////////////////////////////////////////////
// BACKTESTING RANGE
// From Date Inputs
fromDay = input(defval=1, title="From Day", minval=1, maxval=31)
fromMonth = input(defval=1, title="From Month", minval=1, maxval=12)
fromYear = input(defval=2020, title="From Year", minval=1970)
// To Date Inputs
toDay = input(defval=1, title="To Day", minval=1, maxval=31)
toMonth = input(defval=12, title="To Month", minval=1, maxval=12)
toYear = input(defval=2021, title="To Year", minval=1970)
// Calculate start/end date and time condition
startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)
finishDate = timestamp(toYear, toMonth, toDay, 00, 00)
time_cond = true
bearish = cross(close, out) == 1 and close[1] > close
bullish = cross(close, out) == 1 and close[1] < close
plotshape(bearish, color=white, style=shape.arrowdown, text="BEAR", location=location.abovebar)
plotshape(bullish, color=white, style=shape.arrowup, text="BULL", location=location.belowbar)
buy = if cross(close, out) == 1 and close[1] < close
strategy.entry("BUY", strategy.long, when=time_cond)
//strategy.close_all(when=bearish)
// strategy.exit("exit", "Long", profit =, loss = 35)
sell = if cross(close, out) == 1 and close[1] > close
strategy.entry("SELL", strategy.short, when=time_cond)
//sell = if bearish
//strategy.close_all(when=bullish)
// strategy.exit("exit", "Long", profit = bullish, loss = 100)
profit = strategy.netprofit
if not time_cond
strategy.close_all()
//plotshape(true, style=shape.triangleup, location=location.abovebar)