L1 마틴게일 스칼핑 전략

저자:제3192날짜: 2023-10-09 07:06:32
태그:

마틴게일 (MartinGale) 전략 (MartinGale strategy) 은 거래에서 흔히 사용되는 인기 있는 자금 관리 전략이다. 이는 보통 거래자가 손실에 따라 포지션 크기를 늘려 회복을 추구하는 데 사용됩니다. 따라서 마틴게일은 특정 전략이 아니라 포지션, 포지션의 총칭이다.

마틴게일 전략에서는 거래자가 손실을 낸 매매에 따라 포지션 크기를 두 배로 늘리는 것을 원칙으로 한다. 그렇게 하는 목적은 결국 수익을 올리는 거래가 발생하여 이전 손실을 회복하고 이익을 창출하기를 희망하는 것이다.

마틴 게일 전략의 아이디어는 평균 법칙을 활용하는 것이다. 매번의 손실에 따라 포지션 크기를 증가시킴으로써, 이 전략은 결국 수익성있는 거래가 발생한다는 것을 가정하고, 이는 이전 손실을 보상할 뿐만 아니라 수익을 창출할 것이다. 이것은 손실에서 빠르게 회복하려는 거래자에게 특히 매력적일 수 있다.

그러나, 마틴게일 전략에는 상당한 위험이 있다는 점을 주의해야 한다. 거래자가 지속적인 손실 단계 또는 충분한 자금 부족을 경험한다면, 이 전략은 큰 손실을 초래할 수 있다. 이 전략은 유리한 거래가 특정 시간 내에 일어날 것이라는 가정에 의존하고 있으며, 이는 특정 시간 내에 유리한 거래가 발생할 것이라는 보장이 없기 때문에 위험하다. 마틴게일 전략을 실행하는 것을 고려하는 거래자는 자신의 위험 수용 능력을 신중하게 평가하고 잠재적인 단점을 충분히 이해해야 한다. 잠재적인 손실을 완화하기 위해 신뢰할 수 있는 위험 관리 계획을 세우는 것이 매우 중요하다. 또한, 거래자는 이 전략이 모든 시장 상황에 적용되지 않을 수 있고 시장의 변동에 따라 조정할 필요가 있을 수 있음을 인식해야 한다.

간단히 말해서, 마틴게일 전략은 손실 단계에서 회복하기 위해 손실 후 포지션 크기를 증가시키는 것을 포함하는 자금 관리 전략이다. 빠른 회복의 잠재력을 제공 할 수 있지만, 거래자가 이러한 거래 방법을 실행하기 전에 신중하게 고려해야 할 중대한 위험이 있습니다.

이 거래에 대해 동의하지 않지만, 이 주제에 대해 토론하고 있다고 한 개인 메시지는 간단한 38선 프레임워크를 작성했습니다.

마틴게일 모자 포착 전략 (MartinGale grab hat strategy) 은 빈번한 거래로 수익을 창출하는 거래 전략이다. 이 전략은 이동평균의 교차점을 활용하여 입점 및 출구 신호를 생성한다. 이 전략은 트레이딩뷰의 파인 스크립트 언어를 사용하여 구현되었다.

이 전략은 먼저 Stop Loss 및 Stop Loss 레벨과 같은 입력 변수를 정의하고 거래 방식 ("다중장, 빈장, 또는 양방향") 을 설정합니다. 그 다음, 거래 방식이 "다중장"으로 설정된 경우에만 입구를 허용하는 규칙을 설정합니다.

전략 논리는 간단한 이동 평균 (SMA) 의 교차 신호와 교차 신호 정의를 사용한다. 그것은 단기 SMA (SMA3) 와 장기 SMA (SMA8) 를 계산하고 그래프에 그릴 것이다. crossoverSignal과 crossunderSignal 변수는 교차와 교차의 발생을 추적하는 데 사용되며, crossoverState와 crossunderState 변수는 교차와 교차 조건의 상태를 결정한다.

전략은 현재 보유 크기에 기초하여 실행된다. 만약 보유 크기가 0인 경우 (예: 보유가 없는 경우), 전략은 교차와 교차 이벤트를 검사한다. 만약 교차 이벤트가 발생하고 거래 패턴이 많은 헤드 입구를 허용한다면, 다중 헤드 입장에 진입한다. 입점 가격, 중지 손실 가격, 정지 가격 및 정지 손실 가격은 현재 종료 가격과 SMA8값에 기초하여 계산된다. 마찬가지로, 만약 교차 이벤트가 발생하고 거래 패턴이 빈 헤드 입구를 허용한다면, 빈 헤드 입장에 진입하고 그에 따른 가격 계산을 한다. 만약 다중 포지션이 존재하고 현재 클로저 가격이 스톱?? 가격이나 스톱 손실 가격에 도달하고, 교차 사건이 발생하면 다중 포지션이 평형됩니다. 입시 가격, 스톱?? 가격, 스톱?? 가격 및 스톱 손실 가격이 0으로 다시 설정됩니다.

마찬가지로, 만약 빈자리가 존재하고 현재 종료 가격은 정지 가격 또는 정지 손실 가격에 도달하고, 교차 사건이 발생하면 빈자리가 평정되고 가격 변수를 재설정한다.

이 전략은 또한 플롯셰이프 함수를 사용하여 차트에서 입점과 출점을 도출합니다. 그것은 상단 삼각형이 입점을, 아래쪽 삼각형이 입점을, 아래쪽 삼각형이 매출 입점을, 상단 삼각형이 매출 출구를 나타냅니다.

전반적으로, 마틴게일 셰이버 전략은 단기 이동 평균의 교차를 활용하여 작은 이익을 포착하는 것을 목표로 한다. 그것은 Stop Loss 및 Stop Loss 수준으로 위험을 관리하고 다른 거래 모형을 다른 시장 조건에 적응하도록 허용한다.


//@version=5
 strategy('[blackcat] L1 MartinGale Scalping Strategy', overlay=true, pyramiding = 5)
 
 // Define input variables
// martingaleMultiplier = input(2, title="加倍倍数")
 takeProfit = input(1.03, title='Take Profit')
 stopLoss = input(0.95, title='Stop Loss')
 inputTradingMode = input.string(defval='Long', options=['Long', 'Short', 'BiDir'], title='Trading Mode')
 
 //The purpose of this rule is to forbid short entries, only long etries will be placed. The rule affects the following function: 'entry'.
strategy.risk.allow_entry_in(inputTradingMode == 'Long' ? strategy.direction.long : inputTradingMode == 'Short' ? strategy.direction.short : strategy.direction.all)

// Define strategy logic 
entryPrice = 0.0
stopPrice = 0.0
takeProfitPrice = 0.0
stopLossPrice = 0.0

// Define SMA crossover and crossunder signals
sma3 = ta.sma(close, 3)
sma8 = ta.sma(close, 8)
plot(sma3, color=color.yellow)
plot(sma8, color=color.fuchsia)
crossoverSignal = ta.crossover(sma3, sma8)
crossunderSignal = ta.crossunder(sma3, sma8)
crossoverState = sma3 > sma8
crossunderState = sma3 < sma8

if strategy.position_size == 0
    if crossoverState
       strategy.entry('Buy',strategy.long)
       entryPrice := close
       stopPrice := close - stopLoss * sma8[1]
       takeProfitPrice := close + takeProfit * sma8[1]
       stopLossPrice := stopPrice
       stopLossPrice
    if crossunderState
        strategy.entry('Sell', strategy.short)
        entryPrice := close
        stopPrice := close + stopLoss *  sma8[1]
        takeProfitPrice := close - takeProfit *  sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice

if strategy.position_size > 0
    if (close > takeProfitPrice or close < stopLossPrice) and crossunderState
        strategy.close('Buy')
        entryPrice := 0.0
        stopPrice := 0.0
        takeProfitPrice := 0.0
        stopLossPrice := 0.0
        stopLossPrice
    else
        strategy.entry('Buy', strategy.long)
        entryPrice := close
        stopPrice := close - stopLoss *  sma8[1]
        takeProfitPrice := close + takeProfit *  sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice

if strategy.position_size < 0
    if (close > takeProfitPrice or close < stopLossPrice) and crossoverState
        strategy.close('Sell')
        entryPrice := 0.0
        stopPrice := 0.0
        takeProfitPrice := 0.0
        stopLossPrice := 0.0
        stopLossPrice
    else
        strategy.entry('Sell', strategy.short)
        entryPrice := close
        stopPrice := close + stopLoss *  sma8[1]
        takeProfitPrice := close - takeProfit *  sma8[1]
        stopLossPrice := stopPrice
        stopLossPrice

// Plot entry and exit points
plotshape(strategy.position_size > 0 and crossoverSignal, 'Buy Entry', shape.triangleup, location.belowbar, color.new(color.green, 0), size=size.small)
plotshape(strategy.position_size > 0 and (close >= takeProfitPrice or close <= stopLossPrice), 'Buy Exit', shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.small)
plotshape(strategy.position_size < 0 and crossunderSignal, 'Sell Entry', shape.triangledown, location.abovebar, color.new(color.red, 0), size=size.small)
plotshape(strategy.position_size < 0 and (close >= takeProfitPrice or close <= stopLossPrice), 'Sell Exit', shape.triangleup, location.belowbar, color.new(color.green, 0), size=size.small)

더 많은