시장 전 브레이크업 거래 전략

저자:차오장, 날짜: 2023-09-13 11:46:20
태그:

이 전략은 시장 전 시간 동안 브레이크아웃을 거래하며, 이동 평균 및 동력 지표를 사용하여 최대 변동성에서 거래하는 단기 트렌드를 결정합니다. 이것은 전형적인 쇼트 스칼핑 전략입니다.

전략 논리:

  1. 시장 전 범위는 오픈 후 1시간 이내에 정의합니다.

  2. 50주기 EMA를 사용하여 공정한 가격 범위를 측정합니다.

  3. SMI 크로스오버가 낮은 신호로 긴 진입을 나타냅니다.

  4. EMA 아래로 닫는 것은 손해를 멈추는 신호입니다.

  5. 단기 스칼핑을 위한 고정 수익 목표를 생각해보세요.

장점:

  1. 단기 EMA를 깨는 것은 내일 트렌드를 보여줍니다.

  2. SMI는 바닥 반전을 확인합니다.

  3. 제한된 백테스트 매개 변수는 라이브 트레이딩을 간단하게 합니다.

위험성:

  1. 시장이 열리기 전의 함정에 빠질 가능성이 높습니다. 역전에서 조심하세요.

  2. 일일 한 번의 세션으로 틈을 방어 할 수 없습니다.

  3. 단단한 정류는 잘못 정렬되면 조기 출구로 향합니다.

요약하자면, 이것은 높은 변동성 브레이크오웃을 타기 위해 EMA/SMI를 이용한 전형적인 시장 전 쇼트 스칼핑 전략입니다. 그러나 시장 전 함정에 대한 위험이 높으며, 작은 포지션 사이즈와 규율된 스톱 로스를 필요로 합니다.


/*backtest
start: 2022-09-12 00:00:00
end: 2023-09-12 00:00:00
period: 4d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["v_input_7",65]]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Trading_Bites
//@version=5

// strategy('Morning Scalp', overlay=false, pyramiding=2, initial_capital=3000, default_qty_value=0, commission_value=0.02, max_labels_count=500)

                    // Initial Inputs

StartDate =         timestamp('15Aug 2022 14:00 +0000')
EndDate =           timestamp('15Aug 2022 20:00 +0000')
testPeriodStart =   input(StartDate, 'Start of trading')
testPeriodEnd =     input(EndDate, 'End of trading')
QuantityOnLong =    input(title="Quantity", defval=100,  minval=1)
QuantityOnClose =   QuantityOnLong

//////////////////////////////////////////////////////////////////////
//-- Time In Range
timeinrange(res, sess) =>
    not na(time(res, sess))

                //Market Open//
marketopen = '0930-1600'
MarketOpen = timeinrange(timeframe.period, marketopen)
//////////////////////////////////////////////////////////////////////
                //Market Hour//
morning =   '1000-1210'
Morning =   timeinrange(timeframe.period, morning)


//////////////////////////////////////////////////////////////////////////
               //STOCK MOMENTUM INDEX//
a = input(5, 'Percent K Length')
b = input(3, 'Percent D Length')
ovrsld = input.float(40, 'Over Bought')
ovrbgt = input(-40, 'Over Sold')
//lateleave = input(14, "Number of candles", type=input.integer)

// Range Calculation
ll = ta.lowest(low, a)
hh = ta.highest(high, a)
diff = hh - ll
rdiff = close - (hh + ll) / 2
// Nested Moving Average for smoother curves
avgrel = ta.ema(ta.ema(rdiff, b), b)
avgdiff = ta.ema(ta.ema(diff, b), b)
// SMI calculations
SMI = avgdiff != 0 ? avgrel / (avgdiff / 2) * 100 : 0
SMIsignal = ta.ema(SMI, b)

CrossoverIndex = ta.crossover(SMI, SMIsignal)
CrossunderIndex = ta.crossunder(SMI, SMIsignal)

plot1 = plot(SMI, color=color.new(color.aqua, 0), title='Stochastic Momentum Index', linewidth=1, style=plot.style_line)
plot2 = plot(SMIsignal, color=color.new(color.red, 0), title='SMI Signal Line', linewidth=1, style=plot.style_line)
hline = plot(ovrsld, color=color.new(color.red, 0), title='Over Bought')
lline = plot(ovrbgt, color=color.new(color.green, 0), title='Over Sold')

plot(CrossoverIndex ? close : na, color=color.new(color.aqua, 0), style=plot.style_cross, linewidth=2, title='RSICrossover')

mycol1 = SMIsignal > -ovrbgt ? color.red : na
mycol2 = SMIsignal < -ovrsld ? color.green : na

fill(plot1, hline, color=color.new(mycol1, 80))
fill(plot2, lline, color=color.new(mycol2, 80))

//////////////////////////////////////////////////////////////////////
                // Input EMA9 and EMA21 
EMA50Len      = input( 50 )
EMA50         = ta.ema(close, EMA50Len)
//////////////////////////////////////////////////////////////////////////

                // -------- VWAP  ----------//
vwapLine =      ta.vwap(close)
////////////////////////////////////////////////////////////////////////

                        //PROFIT TARGET//

longProfitPer   = input(10.0, title='Take Profit %') / 100
TargetPrice     = strategy.position_avg_price * (1 + longProfitPer) 
//plot              (strategy.position_size > 0 ? TargetPrice : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Price Target") 
 
                    //BUY STRATEGY CONDITION//

condentry =     ta.crossover(SMI, SMIsignal) and SMI < 0
profittarget =  TargetPrice
stoploss =     close < EMA50

///////////////////////////STRATEGY BUILD//////////////////////////////////////

if MarketOpen
    
    if close > EMA50 

        if (condentry) and Morning
            strategy.entry('Long', strategy.long)
            
        if profittarget and strategy.position_size > 0 
            strategy.exit(id="Long", limit=TargetPrice) 
                
if stoploss
    strategy.close('Long' )


더 많은