새 스크립트 얼러트는 스트래티지 및 스터디 모두에서 돌아가는 `alert()` 펑크션을 쓰고 있으며, 얼러트가 트리거되었을 때 풀 다이내믹 메시지를 만들 수 있습니다.
새 얼러트는 최신 스트래티지 얼러트와 비슷한 모델을 써서 돌아가므로 차트 유저 인터페이스에서 만들어진 단 한개의 얼러트만이 스크립트안의 여러 `alert()` 콜에 의해 만들어진 모든 트리거를 합칠수 있습니다. 이는 하나의 스트래티지 얼러트가 모든 브로커 이벤트 트리거를 합칠 수 있는 것과 같은 것입니다.
새 얼러트를 만들려면:
- 여러분의 스크립트안에 넣고 싶은 만큼 `alert()` 콜을 넣고 각각을 트리거링 컨디션을 정한 `if` 블럭안에 넣으십시오.
- 차트의 “얼러트 만들기” 다이얼로그 박스를 써서 스크립트용 얼러트를 하나 만들고 “alert() function call” 이 들어 있는 얼러트 타입을고르십시오.
스트래티지에 쓸때는 유저는 `alert()` 이벤트에서만, 오더 필 이벤트에서만, 또는 둘다에서 트리거하는 얼러트를 골라 만들 수 있습니다. 그리고 다이내믹 얼러트 메시지에 쓰는 베어리어블 갯수에는 제한이 없으며 플레이스홀더는 더이상 필요없습니다. 스크립트에서 쓰는 모든 베어리어블은 새 `alert()` 펑크션에서도 스트링 포맷이기만 하면 쓸 수 있기 때문입니다.
아래에 세 가지 `alert()` 펑크션 보기가 있습니다:
1) 각 바에서 스크립트 얼러트가 트리거되며 메시지에는 바 클로징 프라이스가 들어 있습니다:
//@version=4 study("Simple alert() example") plot(close) alert("Close = " + tostring(close), alert.freq_once_per_bar_close)
2) 세 가지 인디케이터 밸류가 체크되고 있습니다: RSI, SMA 그리고 Momentum. 이들 인디케이터가운데 어느 것이라도 지정 레벨 (또는 프라이스) 를 크로스하면 스크립트 얼러트가 트리거되며, 메시지에는 해당 인디케이터 네임 및 커런트 밸류가 들어갑니다.
//@version=4 study("alert() with multiple indicators", overlay=true) f_triggerSma()=> _s = sma(close, 14) _co = crossover(close, _s) _cu = crossunder(close, _s) if _co alert("Price (" + tostring(close) + ") crossing up SMA (" + tostring(_s) + ")", alert.freq_once_per_bar) else if _cu alert("Price (" + tostring(close) + ") crossing down SMA (" + tostring(_s) + ")", alert.freq_once_per_bar) f_triggerRsi()=> _r = rsi(close, 7) _co = crossover(_r, 70) _cu = crossunder(_r, 30) if _co alert("RSI (" + tostring(_r) + ") crossing up 70 level", alert.freq_once_per_bar) else if _cu alert("RSI (" + tostring(_r) + ") crossing down 30 level", alert.freq_once_per_bar) f_triggerMom()=> _m = mom(close, 14) _co = crossover(_m, 0) _cu = crossunder(_m, 0) if _co alert("Momentum (" + tostring(_m) + ") crossing up 0 level", alert.freq_once_per_bar) else if _cu alert("Momentum (" + tostring(_m) + ") crossing down 0 level", alert.freq_once_per_bar) plot(sma(close, 14), "SMA") f_triggerSma() f_triggerRsi() f_triggerMom()
3) 이번 보기에서는 RSI 인디케이터 밸류를 체크하지만 다섯 심볼에 대하여 한꺼번에 합니다. RSI 가 그 가운데 아무 심볼이나 지정 레벨을 크로스하면 스크립트 얼러트가 트리거되며, 메시지에는 심볼 및 크로싱할 때 인디케이터 밸류가 들어가게 됩니다.
//@version=4 study("alert() with multiple symbols") f_triggerRsi(_ticker)=> _r = rsi(close, 7) _x = crossover(_r,70) _y = crossunder(_r,30) _rt = barstate.isrealtime [_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _rt]) _msg = _ticker + ", " + timeframe.period + ": " if _co and _rt_bar _msg := _msg + "RSI (" + tostring(_rsi) + ") crossing up 70 level" alert(_msg, alert.freq_once_per_bar_close) else if _cu and _rt_bar _msg := _msg + "RSI (" + tostring(_rsi) + ") crossing down 30 level" alert(_msg, alert.freq_once_per_bar_close) plot(rsi(close, 7), "RSI", color=#8E1599) band1 = hline(70, "Upper Band", color=#C0C0C0) band0 = hline(30, "Lower Band", color=#C0C0C0) fill(band1, band0, color=color.new(#9915FF,90), title="Background") f_triggerRsi(syminfo.tickerid) f_triggerRsi("NASDAQ:MSFT") f_triggerRsi("FX:EURUSD") f_triggerRsi("NASDAQ:TSLA") f_triggerRsi("NASDAQ:PYPL")
스크립트 유저는 헬프 센터에서 얼러트 만들기에 대해 더 배울 수 있습니다. 파인 코더는 새 얼러트에 대해 파인 유저 매뉴얼 과 레퍼런스 매뉴얼을 읽어 보시기 바랍니다.
유저 매뉴얼 릴리즈 노트에 나오는 파인 업데이트를 모두 읽어 보시기 바랍니다.