이 전략은 가격의 이동 평균과 표준 차 CHANNEL을 계산하여 동적인 상하 궤도를 형성하고 최고 가격과 최저 가격의 평균을 결합하여 중하 궤도를 형성하여 현재의 트렌드 방향을 판단합니다. 가격이 상하 궤도를 돌파 할 때 부진하고, 가격이 하하 궤도를 돌파 할 때 부진하여, 트렌드 변화에 따라 거래하는 전략을 구현합니다.
이 전략의 전체적인 아이디어는 명확하고 이해하기 쉽다. 동적 채널을 통해 트렌드를 포착하고, 다중 중도 설계와 결합하여 거래 신호를 생성하여, 트렌드 방향을 효과적으로 추적하여 거래를 할 수 있으며, 더 나은 거래 수익을 얻을 수 있다. 실제 적용에서, 손실을 막는 전략, 자금 관리에 주의를 기울이고, 파라미터에 대해 최적화하여 장기적으로 안정적인 수익을 얻을 수 있다.
/*backtest
start: 2023-09-10 00:00:00
end: 2023-10-10 00:00:00
period: 4h
basePeriod: 15m
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/
// © ErdemDemir
//@version=4
strategy("Lawyers Trend Pro Strategy", shorttitle="Lawyers Trend Pro Strategy", overlay=true)
src = close
mult = 2.0
basis = sma(src, 20)
dev = mult * stdev(src, 20)
upper = basis + dev
lower = basis - dev
offset = 0
lower2 = lowest(20)
upper2 = highest(20)
basis2 = avg(upper2, lower2)
MB= (basis+basis2)/2
col1=close>MB
col3=MB>close
colorE = col1 ? color.blue : col3 ? color.red : color.yellow
p3=plot(MB, color=colorE, linewidth=3)
// Deternine if we are currently LONG
isLong = false
isLong := nz(isLong[1], false)
// Determine if we are currently SHORT
isShort = false
isShort := nz(isShort[1], false)
// Buy only if the buy signal is triggered and we are not already long
buySignal = not isLong and crossover(close,MB)
// Sell only if the sell signal is triggered and we are not already short
sellSignal= not isShort and crossover(MB,close)
if (buySignal)
isLong := true
isShort := false
if (sellSignal)
isLong := false
isShort := true
/// LONG
strategy.entry("long", true , when = buySignal, comment="Open Long")
strategy.close("long", when=sellSignal, comment = "Close Long")
/// SHORT
strategy.entry("short", false, when = sellSignal, comment="Open Short")
strategy.close("short", when=buySignal, comment = "Close Short")