유튜브의 신인 '마법적인 이중 EMA 동선 전략'

저자:작은 꿈, 창작: 2022-10-09 15:56:22, 업데이트: 2023-09-15 20:50:38

img

유튜브의 신인 '마법적인 이중 EMA 동선 전략'

이 기사에서는 유튜브에서 유래한 "마법적인 이중 EMA 일직선 전략"에 대해 이야기합니다. 이 전략은 주식 및 암호화폐 시장 살인자 요동이라고 불립니다. 이 비디오를 보면서 이 전략이 트레이딩 뷰의 파인 언어 전략이라는 것을 알게되었습니다. 이 비디오의 재고 효과는 매우 좋았습니다. FMZ는 트레이딩 뷰의 파인 언어를 지원합니다.

전략에서 사용되는 지표

1 EMA 지표

간단한 디자인으로, 우리는 비디오에서 언급한 이동 평균 기하수를 사용하지 않습니다. 우리는 트레이딩 뷰에서 내장된 ta.ema를 사용했습니다.

두 번째, 스윙프리 지표

이 지표는 트레이딩 뷰에 있는 지표입니다. 우리는 트레이딩 뷰에 가서 소스 코드를 다운로드해야 합니다.

img

스윙 무료 코드:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// Credits to the original Script - Range Filter DonovanWall https://www.tradingview.com/script/lut7sBgG-Range-Filter-DW/
// This version is the old version of the Range Filter with less settings to tinker with

//@version=4
study(title="Range Filter - B&S Signals", shorttitle="RF - B&S Signals", overlay=true)

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Size Function
rng_size(x, qty, n)=> 
//    AC       = Cond_EMA(abs(x - x[1]), 1, n)
    wper      = (n*2) - 1
    avrng     = ema(abs(x - x[1]), n)
    AC = ema(avrng, wper)*qty
    rng_size = AC

//Range Filter Function
rng_filt(x, rng_, n)=>
    r          = rng_
    var rfilt  = array.new_float(2, x)
    array.set(rfilt, 1, array.get(rfilt, 0))
    if x - r > array.get(rfilt, 1)
        array.set(rfilt, 0, x - r)
    if x + r < array.get(rfilt, 1)
        array.set(rfilt, 0, x + r)
    rng_filt1 = array.get(rfilt, 0)
    
    hi_band   = rng_filt1 + r
    lo_band   = rng_filt1 - r
    rng_filt  = rng_filt1
    [hi_band, lo_band, rng_filt]
 
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Source
rng_src = input(defval=close, type=input.source, title="Swing Source")

//Range Period
rng_per = input(defval=20, minval=1, title="Swing Period")

//Range Size Inputs
rng_qty   = input(defval=3.5, minval=0.0000001, title="Swing Multiplier")

//Bar Colors
use_barcolor = input(defval=false, type=input.bool, title="Bar Colors On/Off")

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Filter Values
[h_band, l_band, filt] = rng_filt(rng_src, rng_size(rng_src, rng_qty, rng_per), rng_per)

//Direction Conditions
var fdir = 0.0
fdir    := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward   = fdir==1 ? 1 : 0
downward = fdir==-1 ? 1 : 0

//Trading Condition
longCond = rng_src > filt and rng_src > rng_src[1] and upward > 0 or rng_src > filt and rng_src < rng_src[1] and upward > 0 
shortCond = rng_src < filt and rng_src < rng_src[1] and downward > 0 or rng_src < filt and rng_src > rng_src[1] and downward > 0

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1

//Colors
filt_color = upward ? #05ff9b : downward ? #ff0583 : #cccccc
bar_color  = upward and (rng_src > filt) ? (rng_src > rng_src[1] ? #05ff9b : #00b36b) :
             downward and (rng_src < filt) ? (rng_src < rng_src[1] ? #ff0583 : #b8005d) : #cccccc

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Filter Plot
filt_plot = plot(filt, color=filt_color, transp=67, linewidth=3, title="Filter")

//Band Plots
h_band_plot = plot(h_band, color=color.new(#05ff9b, 100), title="High Band")
l_band_plot = plot(l_band, color=color.new(#ff0583, 100), title="Low Band")

//Band Fills
fill(h_band_plot, filt_plot, color=color.new(#00b36b, 92), title="High Band Fill")
fill(l_band_plot, filt_plot, color=color.new(#b8005d, 92), title="Low Band Fill")

//Bar Color
barcolor(use_barcolor ? bar_color : na)

//Plot Buy and Sell Labels
plotshape(longCondition, title = "Buy Signal", text ="BUY", textcolor = color.white, style=shape.labelup, size = size.normal, location=location.belowbar, color = color.new(color.green, 0))
plotshape(shortCondition, title = "Sell Signal", text ="SELL", textcolor = color.white, style=shape.labeldown, size = size.normal, location=location.abovebar, color = color.new(color.red, 0))

//Alerts
alertcondition(longCondition, title="Buy Alert", message = "BUY")
alertcondition(shortCondition, title="Sell Alert", message = "SELL")

전략적 논리

EMA 지표: 전략은 두 개의 EMA 평행선을 사용합니다. 빠른 라인 (작은 주기 매개 변수), 느린 라인 (큰 주기 매개 변수). 이중 EMA 평행선의 역할은 시장 트렌드 방향을 판단하는 데 도움이 됩니다.

  • 다목적 순서 : : : : : : : :

  • 빈 랭킹 : : : : : : : :

VuManChu Swing Free 지표: VuManChu Swing Free 지표는 시그널을 발송하여 다른 조건과 결합하여 거래가 이루어지는지 여부를 결정하는 데 사용됩니다. VuManChu Swing Free 지표의 소스 코드에서 볼 수 있습니다: longCondition 변수는 구매 신호를 대표하고, shortCondition 변수는 판매 신호를 대표합니다. 후속 작성된 주문 조건은 두 변수를 사용합니다.

이제 전략적으로 특정 거래 신호를 유발하는 조건에 대해 이야기 해 보겠습니다.

1, 다중 출입 규칙: 양 K 라인의 닫기 가격은 EMA 빠른 라인의 위에 있어야 하며, 두 개의 평균 EMA 라인은 다목적 배열을 나타내야 하며, VuManChu Swing Free 지표는 구매 신호를 표시해야 합니다. 세 가지 조건이 있습니다.

두 번째, 빈 머리에 들어가는 규칙 (다중 머리와는 반대) 음 K 라인의 폐쇄 가격은 EMA 빠른 라인의 아래에 있어야 하며, 두 개의 평균 EMA 라인은 빈 헤드 배열을 보여야 한다 (빠른 라인은 느린 라인의 아래에 있으며), VuManChu Swing Free 지표는 파는 신호가 나타나야 한다 (단기 조건이 사실이다). 세 가지 조건이 충족된다.

거래 논리는 매우 간단하지 않습니다. 출현 비디오에서 정지 스톱 손실에 대한 구체적인 설명이 없기 때문에, 작가는 여기에 비교 중심을 정지 스톱 손실 방법을 사용 하 여 자유로이 놀 수 있습니다. 고정 점수 스톱 손실을 사용 하 여, 스톱 손실을 추적.

코드 디자인

우리는 VuManChu Swing Free 지표에 대한 코드를 원본으로 직접 입력하고 우리의 전략 코드에 그대로 넣었습니다.

img

그리고 나서 우리는 파인 언어의 코드를 작성하여 트랜잭션 기능을 구현했습니다.

// extend
fastEmaPeriod = input(50, "fastEmaPeriod")         // 快线周期
slowEmaPeriod = input(200, "slowEmaPeriod")        // 慢线周期
loss = input(30, "loss")                           // 止损点数
trailPoints = input(30, "trailPoints")             // 移动止盈触发点数
trailOffset = input(30, "trailOffset")             // 移动止盈偏移量(点数)
amount = input(1, "amount")                        // 下单量

emaFast = ta.ema(close, fastEmaPeriod)             // 计算快线EMA
emaSlow = ta.ema(close, slowEmaPeriod)             // 计算慢线EMA

buyCondition = longCondition and emaFast > emaSlow and close > open and close > emaFast         // 做多入场条件
sellCondition = shortCondition and emaFast < emaSlow and close < open and close < emaFast       // 做空入场条件

if buyCondition and strategy.position_size == 0
    strategy.entry("long", strategy.long, amount)
    strategy.exit("exit_long", "long", amount, loss=loss, trail_points=trailPoints, trail_offset=trailOffset)
if sellCondition and strategy.position_size == 0
    strategy.entry("short", strategy.short, amount)
    strategy.exit("exit_short", "short", amount, loss=loss, trail_points=trailPoints, trail_offset=trailOffset)

A.可以看到,当buyCondition为真时即:

1,longCondition 변수는 true (VuManChu Swing Free 지표가 더 많은 신호를 발산한다) ᅳ 2,emaFast > emaSlow (EMA 다중 배열) ∙ 3, close > open (현재의 BAR는 일선), close > emaFast (폐쇄 가격은 EMA 급선 위에 있다).

더 많은 것을 할 수 있는 세 가지 조건이 충족됩니다.

B.当sellCondition为真时,则做空的三个条件成立(这里不再赘述)。

다음 if 조건 판단 신호가 발사되면, 전략.출입 함수를 사용하여 입장을 개척하고, 전략.출출 함수를 중지, 추적 중지로 설정합니다.

전체 코드

/*backtest
start: 2022-01-01 00:00:00
end: 2022-10-08 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT"}]
args: [["ZPrecision",0,358374]]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// Credits to the original Script - Range Filter DonovanWall https://www.tradingview.com/script/lut7sBgG-Range-Filter-DW/
// This version is the old version of the Range Filter with less settings to tinker with

//@version=4
study(title="Range Filter - B&S Signals", shorttitle="RF - B&S Signals", overlay=true)

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Functions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Size Function
rng_size(x, qty, n)=> 
//    AC       = Cond_EMA(abs(x - x[1]), 1, n)
    wper      = (n*2) - 1
    avrng     = ema(abs(x - x[1]), n)
    AC = ema(avrng, wper)*qty
    rng_size = AC

//Range Filter Function
rng_filt(x, rng_, n)=>
    r          = rng_
    var rfilt  = array.new_float(2, x)
    array.set(rfilt, 1, array.get(rfilt, 0))
    if x - r > array.get(rfilt, 1)
        array.set(rfilt, 0, x - r)
    if x + r < array.get(rfilt, 1)
        array.set(rfilt, 0, x + r)
    rng_filt1 = array.get(rfilt, 0)
    
    hi_band   = rng_filt1 + r
    lo_band   = rng_filt1 - r
    rng_filt  = rng_filt1
    [hi_band, lo_band, rng_filt]
 
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Inputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Source
rng_src = input(defval=close, type=input.source, title="Swing Source")

//Range Period
rng_per = input(defval=20, minval=1, title="Swing Period")

//Range Size Inputs
rng_qty   = input(defval=3.5, minval=0.0000001, title="Swing Multiplier")

//Bar Colors
use_barcolor = input(defval=false, type=input.bool, title="Bar Colors On/Off")

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Definitions
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Range Filter Values
[h_band, l_band, filt] = rng_filt(rng_src, rng_size(rng_src, rng_qty, rng_per), rng_per)

//Direction Conditions
var fdir = 0.0
fdir    := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir
upward   = fdir==1 ? 1 : 0
downward = fdir==-1 ? 1 : 0

//Trading Condition
longCond = rng_src > filt and rng_src > rng_src[1] and upward > 0 or rng_src > filt and rng_src < rng_src[1] and upward > 0 
shortCond = rng_src < filt and rng_src < rng_src[1] and downward > 0 or rng_src < filt and rng_src > rng_src[1] and downward > 0

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1

//Colors
filt_color = upward ? #05ff9b : downward ? #ff0583 : #cccccc
bar_color  = upward and (rng_src > filt) ? (rng_src > rng_src[1] ? #05ff9b : #00b36b) :
             downward and (rng_src < filt) ? (rng_src < rng_src[1] ? #ff0583 : #b8005d) : #cccccc

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------
//Outputs
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------

//Filter Plot
filt_plot = plot(filt, color=filt_color, transp=67, linewidth=3, title="Filter")

//Band Plots
h_band_plot = plot(h_band, color=color.new(#05ff9b, 100), title="High Band")
l_band_plot = plot(l_band, color=color.new(#ff0583, 100), title="Low Band")

//Band Fills
fill(h_band_plot, filt_plot, color=color.new(#00b36b, 92), title="High Band Fill")
fill(l_band_plot, filt_plot, color=color.new(#b8005d, 92), title="Low Band Fill")

//Bar Color
barcolor(use_barcolor ? bar_color : na)

//Plot Buy and Sell Labels
plotshape(longCondition, title = "Buy Signal", text ="BUY", textcolor = color.white, style=shape.labelup, size = size.normal, location=location.belowbar, color = color.new(color.green, 0))
plotshape(shortCondition, title = "Sell Signal", text ="SELL", textcolor = color.white, style=shape.labeldown, size = size.normal, location=location.abovebar, color = color.new(color.red, 0))

//Alerts
alertcondition(longCondition, title="Buy Alert", message = "BUY")
alertcondition(shortCondition, title="Sell Alert", message = "SELL")


// extend
fastEmaPeriod = input(50, "fastEmaPeriod")
slowEmaPeriod = input(200, "slowEmaPeriod")
loss = input(30, "loss")
trailPoints = input(30, "trailPoints")
trailOffset = input(30, "trailOffset")
amount = input(1, "amount")

emaFast = ta.ema(close, fastEmaPeriod)
emaSlow = ta.ema(close, slowEmaPeriod)

buyCondition = longCondition and emaFast > emaSlow and close > open and close > emaFast
sellCondition = shortCondition and emaFast < emaSlow and close < open and close < emaFast

if buyCondition and strategy.position_size == 0
    strategy.entry("long", strategy.long, amount)
    strategy.exit("exit_long", "long", amount, loss=loss, trail_points=trailPoints, trail_offset=trailOffset)
if sellCondition and strategy.position_size == 0
    strategy.entry("short", strategy.short, amount)
    strategy.exit("exit_short", "short", amount, loss=loss, trail_points=trailPoints, trail_offset=trailOffset)

재검토 테스트

재검토 테스트 시간 범위는 2022년 1월부터 2022년 10월까지 선택되며, K 라인 주기는 15분이며, 종료 가격 모델 재검토를 사용한다. 시장은 Binance의 ETH_USDT 상속 계약을 선택한다. 파라미터 설정은 출출 비디오에서 말하는 빠른 라인 50 주기, 느린 라인 200 주기, 다른 파라미터들은 기본적으로 변하지 않는다. 중지 손실, 추적 중지 요점 수는 내가 주관적으로 한 지점을 설정하면 30 지점이다.

img

img

리테스트 결과 마마호루 호루, 여러 번 리테스트를 통해 이러한 매개 변수들이 리테스트 결과에 영향을 미쳤다고 보입니다. 이 측면에서도 디자인을 최적화해야 할 필요가 있다고 생각합니다. 그러나 전략 신호가 트레이드 후 승률을 유발하는 것은 여전히 가능합니다.

우리는 BTC_USDT 상환 계약을 시도해 보겠습니다.

img

이 글은 유한민주당 소속으로 된 유한민주당 소속으로 올라와 있습니다.

img

img

그라운드:https://www.fmz.com/strategy/385745

이 거래 방법은 트렌드를 잡기 위해 비교적 신뢰할 수 있는 것으로 보입니다. 이 아이디어에 따라 디자인을 계속 최적화 할 수 있습니다. 이 기사에서는 양평선 전략의 아이디어를 이해하는 것뿐만 아니라 오일 파이프 (youtube) 에 대한 대 신 (大神) 전략을 처리하고 배우는 방법을 이해했습니다.


관련

더 많은

환상상이 전략은 변수에도 적용될 수 있을까요?

hyc1743마노다, 왜 아이콘에 신호가 표시되고 실제 디스크는 열리지 않는가? /upload/asset/23cc031609caa7a896da3.jpg /upload/asset/23cae1c5d5b26ec763ea6.jpg /upload/asset/23d49ff4aec3475793e5e.jpg

가벼운 구름마노다, 석유관에서 대표적인 두 세 가지, 더 큰 난이도, 함수, 매개 변수, 연산 방식이 더 많은 전략을 다시 작성하는 것을 제안합니다. 예를 들어,?? line.delete?? 와 유사한 몇 가지 문자 버전의 튜토리얼을하십시오. 나는 이제 이 쌍평선 전략으로, 아주 복잡한 조합 전략을 변경하는 것을 배웠고, 12개의 조합 전략을 변경했습니다. 그 중 한 두 가지가 실제로 21 년 22 년 데이터 리모델링 결과입니다. 그것은 매우 좋았습니다. 또한 실제 디스크에서 테스트를 실행했습니다. 그러나 복잡한 함수 파라미터 연산에 직면했습니다. 예를 들어, 팁:line: 62 Could not find function or function reference 'line.delete', 그런데 FMZ PINE Script 문서에서는 line.delete 관련 설명을 찾지 못했습니다. 이 모든 것이 제 삶을 변화시켰습니다.

하이고시간 선택 21 4-10 BTC가 더 나빠

영준이 문서를 보시면, 이 지폐가 무엇을 의미하는지 이해할 수 없습니다. 이 지폐가 무엇을 의미하는지 설명해 주시겠습니까? 예를 들어, 기본값이 30이면 BTC가 30개 떨어졌다는 것을 의미합니까?

가벼운 구름마노다, PINE에서 좀 더 복잡한 항독법을 쓸 수 있나요? 예를 들어 계층적인 항독법 같은 방법? 감사합니다. 만약 PINE가 JS와 혼용될 수 있다면, 예를 들어, PINE로 지표를 작성하고, JS에서 거래 부분을 작성하는 것이 더 편리하다.

영준실제 디스크는 2022년에 오류가 발생할 수 있습니다.

fmzero저장 전략은 이 장난감을 제안합니다. REST: sql: no rows in result set 결과 세트에서 줄이 없습니다

fmzero꿈은 거칠다

작은 꿈하하, 트렌드 전략 자체는 ", 미래 시장이 트렌드를 가지고 있지, 그렇지 않으면 충격 전략"입니다.

작은 꿈이 모든 것은 매우 무례합니다.

hyc1743감사합니다.

작은 꿈안녕하세요, 이것은 그래프에 표시된 BUY 표시가 기사에 표시된 지표의 신호이기 때문입니다. `` //Plot 구매 및 판매 라벨 plotshape ((longCondition, title = "Buy Signal", text ="BUY", textcolor = color.white, style=shape.labelup, size = size.normal, location=location.belowbar, color = color.new(color.green, 0)) plotshape ((shortCondition, title = "Sell Signal", text ="SELL", textcolor = color.white, style=shape.labeldown, size = size.normal, location=location.abovebar, color = color.new(color.red, 0)) `` plotshape ((longCondition, title = "Buy Signal", text ="BUY 그림이 표시되는 경우, 오직 longCondition 조건만이 충족된다. 이 부분의 본문은 https://www.facebook.com/facebook.com/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook/facebook `` if buy상황 및 전략.position_size == 0 strategy.entry (("long", strategy.long, amount) "전략.장, 금액") strategy.exit (("exit_long", "long", amount, loss=loss, trail_points=trailPoints, trail_offset=trailOffset) 이 있습니다. 그리고 이 방법은 다른 방법도 있습니다. if sell조건 및 전략.position_size == 0 strategy.entry (("short", strategy.short, amount) "단기, 전략.단기, 금액") strategy.exit (("exit_short", "short", amount, loss=loss, trail_points=trailPoints, trail_offset=trailOffset) 이 있습니다. 이 사이트의 주요 사이트는 이 사이트의 주요 사이트입니다. ``

가벼운 구름놀랍습니다. 이해합니다. 감사합니다.

작은 꿈line 이 객체는 FMZ에서 일시적으로 지원되지 않으므로 일부 줄무늬가 변경되지 않을 수 있습니다. 일부 정책에서는 이 객체를 사용하여 계산에 참여합니다.

작은 꿈이 경우, 데이터의 양이 너무 많을 수도 있습니다.

작은 꿈파인 언어 튜토리얼에는 섹션과 설명이 있습니다. http://www.fmz.com/bbs-topic/9390#%E5%B8%A6%E8%B7%F%E8%B8%AA%E6%AD%A2%E6%8D%9F%E6%AD%A2%E7%9B%88%E7%9A%84%E8%B6%85%E7%BA%A7%E8%B6%8B%E5%8A%BF%E7%AD%96%E7%95%A5

가벼운 구름음, 저는 1년 또는 10개월을 설정하고, 기본적으로 완료하고, 1년 후에는 이 팁이나 다른 많은 것들이 있을 것입니다.

작은 꿈이 오류 보고는 제한이 없습니다. 이 오류 보고는 검색 시간 범위가 너무 커야 합니다.

가벼운 구름좋아요, 감사합니다, 그리고, PINE 리코딩 시간에는 제한이 있나요? 2021년 1월 1일부터 2022년 10월 11일까지를 선택했습니다. RuntimeError: abort(undefined) at js Error at StackTrace (eval at self.onmessage (https://www.fmz.com/scripts/worker_detours.393054f7.js:1:147), :1:2096171) at stackTrace (eval at self.onmessage (https://www.fmz.com/scripts/worker_detours.393054f7.js:1:147), :1:2096345) at abort (eval at self.onmessage (https://www.fmz.com/scripts/worker_detours.393054f7.js:147), :192xxx:1478) at stackTrace (eval at self.onmessage (https://www.fmz.com/scripts/worker_detours.onmessage (https://www.fmz.com/scripts/functionanonymous_detours.f7.js:147:147), :2096 그러나 시간대를 변경하지 않으면 정상적으로 재검토됩니다........

작은 꿈파인은 JS 코드에 임베디드된 좀 더 복잡한 차단기를 설계할 수 있어야 한다.

작은 꿈이 글은 이 글의 본문에서 보여드렸습니다.

작은 꿈오, 죄송합니다, 정책 주소가 잘못 붙여졌습니다. 수정되었습니다.