脱出日取引戦略

作者: リン・ハーンチャオチャン,日付: 2023-10-09 16:56:21
タグ:

概要

これは,移動平均値に基づいた簡単な日取引戦略で,GBPUSD 1時間タイムフレームに適しています. ロンドンオープンにのみ入場し,ロンドンの閉鎖にのみ退場し,ロンドンのセッション中にトレンドブレイクトレードに最適です.

戦略の論理

この戦略は2つの移動平均を用い,一つは非常に速く,もう一つは非常に遅い.論理は次のとおりです.

  1. 価格が高速MAを突破したときにのみロンドンオープン (8AM) にエントリーする. 快速MAを突破した場合は閉じるか高くなればロング,高速MAを突破した場合は閉じるか低くなればショートする.

  2. 前回のバーが長期にスローMA以上,短期にスローMA以下に閉じることを要求し,トレンドではない動きをフィルタリングします.

  3. ストップ・ロスは50~100ポイントです

  4. 利益は取れない ロンドンの閉店時に無条件に退場する

利点分析

これは非常にシンプルなブレークアウト戦略ですが ロンドンセッションのトレンド特性を適切に活用することで,以下の利点があります.

  1. 明確なトレンドにのみ入って 変動する市場リスクを回避します

  2. ロンドンの波動が強い時期だけ 取引がブレイクされます

  3. 小規模なストップロスは 逆転に耐えられる

  4. 無条件の脱出は 一夜間のリスクを回避します

リスク分析

この戦略にはいくつかのリスクもあります:

  1. ロンドンが明確なトレンドがない場合 長期間にわたって 安定している可能性があります

  2. ストップ・ロスのリスクは,リトラクションで停止されるリスクです.

  3. 強烈な傾向が持続期間を延長させる場合,早期離脱リスク

緩和策には,入場規則の拡大,利益の確保のためにトラッキングストップの使用,市場状況に基づいて出口時間を動的に調整するなどがあります.

オプティマイゼーションの方向性

この戦略はいくつかの分野において改善可能である.

  1. RSIやボリンジャー帯などのフィルターを追加すると 市場が揺らぐことを避けます

  2. 異なるパラメータをテストすることで移動平均の組み合わせを最適化します

  3. 最適範囲を見つけるために 異なるストップ損失サイズをテストする.

  4. 固定時間ではなく価格の動きに基づいて出口時間を動的に調整します.

  5. 他の通貨ペアやタイムフレームをテストします.

  6. リスク管理を追加します 例えば 口座のサイズに基づいて ポジションのサイズを決めます

概要

総じて,これは非常にシンプルで実用的なロンドンセッションブレイアウト戦略である.セッション特性を適切に活用することで,特定の取引リスクを回避することから利益を得ます.強度と収益性を向上させるためのさらなる最適化のための分野もあります.この戦略は,ロンドンセッションブレイアウトを効果的に取引するための有用な枠組みとテンプレートを提供します.


/*backtest
start: 2023-09-08 00:00:00
end: 2023-10-08 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4

// strategy(title="2 ma breakout",shorttitle="2 ma breakout", initial_capital=10000,overlay=true, commission_type = strategy.commission.cash_per_contract, commission_value = 0.00008 )
timeinrange(res, sess) => time(res, sess) != 0

//Change false to false = You have to turn on, won't show up by default
//****Always use lowercase letters

doNYOpen = input(defval=false, type = input.bool, title="NY Open On")
doNYSession = input(defval=false, type = input.bool, title="NY Session On")
doNYClose = input(defval=false, type = input.bool, title="NY Close On")

doAussieOpen = input(defval=false, type = input.bool, title="Aussie Open On")
doAussieSession = input(defval=false, type = input.bool, title="Aussie Session On")
doAussieClose = input(defval=false, type = input.bool, title="Aussie Close On")

doAsiaOpen = input(defval=false, type = input.bool, title="Asia Open On")
doAsiaSession = input(defval=false, type = input.bool, title="Asia Session On")
doAsiaClose = input(defval=false, type = input.bool, title="Asia Close On")

doEurOpen = input(defval=true, type = input.bool, title="Euro Open On")
doEurSession = input(defval=true, type = input.bool, title="Euro Session On")
doEurClose = input(defval=true, type = input.bool, title="Euro Close On")

//You can copy and paste these colors. white - silver - gray - maroon - red - purple - fuchsia - green - lime
//   olive - yellow - navy - blue - teal - aqua - orange 

nySessionStart = color.olive
nySession = color.olive
nySessionEnd = color.olive
asiaSessionStart = color.blue
asiaSession = color.blue
asiaSessionEnd = color.blue
europeSessionStart = color.red
europeSession = color.red
europeSessionEnd = color.red
colorwhite = color.white

//****Note ---- Use Military Times --- So 3:00PM = 1500


bgcolor(doAsiaSession and timeinrange(timeframe.period, "1800-0400") ? asiaSession : na, transp=75)
//bgcolor(timeinrange(timeframe.period, "0000-0300") ? color.white  : na, transp=75)
bgcolor(doEurSession and timeinrange(timeframe.period, "0300-1100") ? europeSession : na, transp=75)
bgcolor(doNYSession and timeinrange(timeframe.period, "0800-1600") ? nySession : na, transp=75)

active = input(true, title="Show On Chart")
pricehigh = security(syminfo.tickerid, '60', high[0])
pricelow = security(syminfo.tickerid, '60', low[0])
//Daily Plots
offs_daily = 0 
hiHighs = 0
loLows = 0
//plot(timeinrange(timeframe.period, "0000-0300") and pricehigh ? pricehigh  : na, title="Previous Daily High", style=plot.style_line, linewidth=2, color=color.gray)
//plot(timeinrange(timeframe.period, "0000-0300") and pricelow ? pricelow : na, title="Previous Daily Low", style=plot.style_linebr, linewidth=2, color=color.gray)

if(timeinrange(timeframe.period, "0000-0300"))
    hiHighs = highest(high, 3)
    loLows = lowest(low, 3)
    

// 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 = 31, title = "To Day", minval = 1, maxval = 31)
toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)
toYear = input(defval = 2020, 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


len = input(2)
src = input(close, title="Source")
out = sma(src, len)

lena = input(200, minval=1, title="Length slow")
srca = input(close, title="Source")
outa = ema(srca, lena)

//tp = input(100, title="tp")
sl = input(66, title="sl")
// if(smabool)
//     out := sma(src, len)
// else if(emabool)
//     out := ema(src, len)
// else if(hmabool)
//     out := hma(src, len)
// else if(vmabool)
//     out := wma(src, len)  
// else if(vwmabool)
//     out := vwma(src, len)   
// else if(smmabool)
//     out := sma(src, len)  
 
plot(out, color=color.white, title="MA")
plot(outa, color=color.white, title="MA")

longC = timeinrange(timeframe.period, "0300-0400") and (crossover(close,out) or crossover(high,out)) and close[1] > outa and time_cond
shortC = timeinrange(timeframe.period, "0300-0400") and (crossunder(close,out) or crossunder(low,out)) and close[1] < outa and time_cond



//inputlondon = input(false, title="london session")
//inputny = input(false, title="new york session")

//if(inputlondon==true)

strategy.initial_capital = 50000

//MONEY MANAGEMENT--------------------------------------------------------------
balance = strategy.netprofit + strategy.initial_capital //current balance
floating = strategy.openprofit          //floating profit/loss
risk = input(1,type=input.float,title="Risk % of equity ")/100           //risk % per trade

temp01 = balance * risk     //Risk in USD
temp02 = temp01/sl        //Risk in lots
temp03 = temp02*100      //Convert to contracts
size = temp03 - temp03%1 //Normalize to 1000s (Trade size)
if(size < 1)
    size := 1         //Set min. lot size


strategy.entry("long",1,when=longC)
//strategy.close("long", when = crossunder(close,out) or not (timeinrange(timeframe.period, "0300-1000")))
strategy.close("long", when =  not (timeinrange(timeframe.period, "0300-0945")))
strategy.exit("x_long","long", loss = sl)
     
    
strategy.entry("short",0,when=shortC)
//strategy.close("short",when = crossover(close,out) or not (timeinrange(timeframe.period, "0300-1000")))
strategy.close("short",when = not (timeinrange(timeframe.period, "0300-0945")))

strategy.exit("x_short","short", loss = sl)

//strategy.exit("closelong", "RSI_BB_LONG" , profit = close * 0.01 / syminfo.mintick, loss = close * 0.01 / syminfo.mintick, alert_message = "closelong")
//strategy.exit("closeshort", "RSI_BB_SHORT" , profit = close * 0.01 / syminfo.mintick, loss = close * 0.01 / syminfo.mintick, alert_message = "closeshort")



もっと