Indicator · Pine Script v4 · Own pane

Ami_Trade_alert() with multiple symbols

by amico1234· code credited to amico5

This script defines a custom alert setup for trade signals across multiple symbols.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code899
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago2 Mar 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

899 lines of Pine Script v4 from 080422/onlyalert().pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

onlyalert().pine
// # ========================================================================= #
// https://www.tradingview.com/pine-script-docs/en/v5/concepts/Alerts.html#alert-function-events

// https://www.tradingview.com/pine-script-reference/v5/#fun_request{dot}security

// https://www.tradingview.com/blog/en/our-new-alerts-allow-for-dynamic-messages-22588/

// # ========================================================================= #
// *   > 1.  simple RSI - over
// *   > 2.  simple RSI - ">"
// *   > 3.  multi any - over
// *   > 4.  multi every - over
// *   > 5.  multi any - ">"
// *   > 6.  multi every - ">"
// *   > 7.  RSI center line 50
// *   > 8.  sar , ucslrs
// *   > 9.  daily 
// # ========================================================================= #

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


// # ========================================================================= #
// # script overview
// # ========================================================================= #

// # ========================================================================= #
// 1. simple test case for alerts(), NOT alertcondition().
// 2. bull and bear
// # ========================================================================= #


// # ========================================================================= #
// # script structure
// # ========================================================================= #

// # ========================================================================= #
// 1. overview
// 2. structure
// 3. main script version number (should b ver' 4. after tested, will b moved to ver' 5)
// 4. main script's: study / inducator (must have only one for all the script)
// 5. sub indicators numbers
// 6. sub indicators title
// 7. input variables
// 8. CALCULATIONS
// 9. plots Entry
// 10. trade definition (for the specific indicator)
// 11. compounding trade definitions (for the indicators, so far)
// 12. alerts (for the specific indicator)
// 13. compounding alerts (for the comulative, so far)
// # ========================================================================= #


// # ========================================================================= #
// https://www.tradingview.com/pine-script-docs/en/v5/concepts/Alerts.html#alert-function-events

// https://www.tradingview.com/pine-script-reference/v5/#fun_request{dot}security

// https://www.tradingview.com/blog/en/our-new-alerts-allow-for-dynamic-messages-22588/

// # ========================================================================= #
// *   > 1.  simple RSI - over
// *   > 2.  simple RSI - ">"
// *   > 3.  multi any - over
// *   > 4.  multi every - over
// *   > 5.  multi any - ">"
// *   > 6.  multi every - ">"
// *   > 7.  RSI center line 50
// *   > 8.  sar , ucslrs
// *   > 9.  daily 





// # ========================================================================= #
// # main script version number
// # ========================================================================= #

//@version=4

// # ========================================================================= #
// # main script's: study / inducator (must have only one for all the script)
// # ========================================================================= #



// alert must be deleted and than new alert with securities 


study("Ami_Trade_alert() with multiple symbols" , shorttitle='Ami_Trade_alert() with multiple symbols', overlay=false)
f_triggerRsi(_ticker)=>
    _r = rsi(close, 7)
   // _x = crossover(_r,70)
    _x = crossover(_r,50) or crossover(_r,70) or crossover(_r,30)
    // _x = (_r > 70)
    // _x = (_r > 50)
    _y = crossunder(_r,28.88) or crossunder(_r,30) or crossunder(_r,28) or crossunder(_r,50)
    // _y = (_r < 30)


// # ========================================================================= #
// # trying comulative
// # ========================================================================= #


    // mom_m  = mom(close, 14)
    // mom_co = mom_m > 0
    // mom_cu = mom_m < 0

    _q = mom(close, 14)
    _w = _q > 0
    _o = _q < 0

///

// Period = input(20, minval=1)
// hline(0, color=purple, linestyle=line)
// xStdDev = stdev(close, Period)
// xMA = sma(close, Period)
// nRes = (close - xMA) / xStdDev
// plot(nRes, color=blue, title="Z-Score")

    _p = 20
    _t = stdev(close, _p) // xStdDev
    _l = sma(close, _p) // xMA
    _n = (close - _l) / _t    // nRes //zscore
    _zc = _n > 0
    _zcs = _n < 0
/////////////////



    _rt = barstate.isrealtime
    //
    
    
    // [_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _rt])
   
   // with momentum
   
    [_rsi, _co, _cu, _mom, _mom_co, _mon_cu, _z_per, _z_std, _z_sma, _z_nres_zscore, _z_zscore, _z_zscore_bear, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _q, _w, _o, _p, _t, _l, _n, _zc, _zcs, _rt])
   
   //
   
    _msg = _ticker + ", " + timeframe.period + ": "
   
 
    if _co and _mom_co and _z_zscore and _rt_bar
        _msg := _msg + "RSI_comulative (" + tostring(_rsi) + tostring(_mom) + tostring(_z_nres_zscore) + ") crossing up 50 level and comulative"
        //alert(_msg,  alert.freq_once_per_bar_close) // *** like this
        alert(_msg,  alert.freq_once_per_bar_close) // *** like this 
            
    else if _cu and _mon_cu and  _z_zscore_bear and _rt_bar
        _msg := _msg + "RSI_comulative (" + tostring(_rsi) + tostring(_mom) + tostring(_z_nres_zscore) + ")  crossing down 50 level and comulative"
        //alert(_msg,  alert.freq_once_per_bar_close)  // *** like this 
       // alert(_msg,  alert.freq_once_per_bar_close)  // *** like this 
        alert(_msg,  alert.freq_once_per_bar)

//
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)

// MKT bull
// MKT bear
// f_triggerRsi("AMEX:UVIX")

// // gold phy
// f_triggerRsi("AMEX:AAAU")
// // gold options
// f_triggerRsi("LSE:3GOL")
// // gold miners
// f_triggerRsi("AMEX:NUGT")
// // gold div
// f_triggerRsi("NASDAQ:GLDI")
// // gold short
// f_triggerRsi("AMEX:DUST")
// f_triggerRsi("LSE:3GOS")

// // silver phy
// // silver options
// f_triggerRsi("LSE:3SIL")
// // silver miners
// // silver div
// f_triggerRsi("NASDAQ:SLVO")
// // silver short
// f_triggerRsi("LSE:3SIS")

// // oil phy
// // oil options
// f_triggerRsi("LSE:3OIL")
// // oil miners
// // oil div
// // oil short
// f_triggerRsi("LSE:3OIS")
// f_triggerRsi("AMEX:SCO")
// // nlg phy
// // nlg options
// f_triggerRsi("LSE:3NGL")
// // nlg miners
// // nlg div
// // nlg short
// f_triggerRsi("LSE:3NGS")

// // URANIUM phy
// // URANIUM options
// // URANIUM miners
// // URANIUM div
// // URANIUM short


// // MOLYBDENUM

// // lumber

// // MAGNESIUM

// // TITANIUM

// // RHODIUM

// // pal phy
// f_triggerRsi("LSE:PHPD")
// // pal options
// f_triggerRsi("LSE:2PAL") 
// // pal miners
// // pal div
// // pal short
// f_triggerRsi("LSE:1PAS")

// // pla phy
// // pla options
// f_triggerRsi("LSE:LPLA")
// // pla miners
// // pla div
// // pla short

// // copper phy
// f_triggerRsi("LSE:TCOP")
// // copper options
// f_triggerRsi("LSE:3HCL") 
// // copper miners
// // copper div
// // copper short
// f_triggerRsi("LSE:3HCS") 

// // leed phy
// // leed options
// // leed miners
// // leed div
// // leed short

// // iron ore phy
// // iron ore options
// // iron ore miners
// // iron ore div
// // iron ore short

// // zinc phy
// // zinc options
// // zinc miners
// // zinc div
// // zinc short

// // ALUMINIUM phy
// // ALUMINIUM options
// f_triggerRsi("LSE:LALU")
// // ALUMINIUM miners
// // ALUMINIUM div
// // ALUMINIUM short

// // nickel phy
// f_triggerRsi("LSE:TNIK")

// // f_triggerRsi("LSE:NICK")

// // nickel options
// f_triggerRsi("LSE:LNIK")
// // nickel miners
// f_triggerRsi("ASX:NIC")
// // nickel div
// // nickel short
// f_triggerRsi("LSE:SNIK")



// // soy phy
// // soy options
// // soy miners
// f_triggerRsi("AMEX:SOYB")
// // soy div
// // soy short

// // corn phy
// // corn options
// // corn miners
// f_triggerRsi("AMEX:CORN")
// // corn div
// // corn short

// // cotton phy
// // cotton options
// // cotton miners
// f_triggerRsi("LSE:COTN")
// // cotton div
// // cotton short

// // wheat phy
// // wheat options
// f_triggerRsi("LSE:3WHL")
// // wheat miners
// // wheat div
// // wheat short

// // sugar phy
// // sugar options
// f_triggerRsi("LSE:3SUL")
// // sugar miners
// // sugar div
// // sugar short

// // coffee phy
// // coffee options
// f_triggerRsi("LSE:LCFE")
// // coffee miners
// // coffee div
// // coffee short

// // coc phy
// // coc options
// f_triggerRsi("LSE:LCOC")
// // coc miners
// // coc div
// // coc short


// //bit
// //bit short

// // f_triggerRsi("NASDAQ:SQQQ")

// f_triggerRsi("TASE:BONS")
// f_triggerRsi("TASE:LUMI")
// f_triggerRsi("TASE:MGRT")
// f_triggerRsi("TASE:MNRT")

// // f_triggerRsi("LSE:3NFE")
// // f_triggerRsi("LSE:NVD3")

f_triggerRsi("NASDAQ:NVDA")


////////



// // indicator('one_indicator_UCS_Stochastic Momentum Index', shorttitle='oneindicator_UCS_SMI', overlay=false)

// study ('Ami_Trade_Test_Indicator_scriptone', shorttitle='Ami_Trade_Test_Indicator_scriptone', overlay= true)


// // ---- //
// //      //
// //      //
// // -  - //
// //      //
// //      //
// // ---- //


// // # ========================================================================= #
// // # sub indicators numbers
// // # ========================================================================= #

// // --first indicator-- //

// // # ========================================================================= #
// // input variables, function
// // # ========================================================================= #

// f_triggerRsi(_ticker)=> // function
//     _r = rsi(close, 7)
//     _x = crossover(_r,70)
//     _y = crossunder(_r,30)
//     _rt = barstate.isrealtime


// // # ========================================================================= #
// // Calculation
// // # ========================================================================= #

// [_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _rt])
// _msg = _ticker + ", " + timeframe.period + ": "




// // # ========================================================================= #
// // alerts Conditions, trade definitions (for the specific indicator)
// // # ========================================================================= #

// if _co and _rt_bar
//     _msg := _msg + "RSI (" + tostring(_rsi) + ") crossing up 70 level"
//     alert(_msg,  alert.freq_once_per_bar_close) // *** like this 
// else if _cu and _rt_bar
//     _msg := _msg + "RSI (" + tostring(_rsi) + ")  crossing down 30 level"
//     alert(_msg,  alert.freq_once_per_bar_close)  // *** like this 


// // # ========================================================================= #
// // All PLOTS
// // # ========================================================================= #

// 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")

// // # ========================================================================= #
// // compound alerts
// // # ========================================================================= #

// // # ========================================================================= #
// // tsecurities alerts trigerring
// // # ========================================================================= #

// f_triggerRsi(syminfo.tickerid)
// f_triggerRsi("NASDAQ:MSFT")
// f_triggerRsi("FX:EURUSD")
// f_triggerRsi("NASDAQ:TSLA")
// f_triggerRsi("NASDAQ:PYPL")
// f_triggerRsi("LSE:3HCS")
// f_triggerRsi("LSE:2PAL")

// //f_triggerRsi("TASE:BONS")


// ///////////////////







//





















//////////////////////////////////////////////////////////////////////////////////////
//@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) // *** like this 
    else if _cu and _rt_bar
        _msg := _msg + "RSI (" + tostring(_rsi) + ")  crossing down 30 level"
        alert(_msg,  alert.freq_once_per_bar_close)  // *** like this 

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")


// # ========================================================================= #

f_triggerRsi(_ticker)=>
    rsi_r = rsi(close, 7)
    rsi_x = crossover(rsi_r,50)
    rsi_y = crossunder(rsi_r,50)
    rsi_rt = barstate.isrealtime
    
    [rsi_rsi, rsi_co, rsi_cu, rsi_rt_bar] = security(rsi_ticker, timeframe.period, [rsi_r, rsi_x, rsi_y, rsi_rt])
    
    rsi_msg = rsi_ticker + ", " + timeframe.period + ": "
    
    if rsi_co and rsi_rt_bar
        rsi_msg := rsi_msg + "RSI (" + tostring(rsi_rsi) + ") crossing up 70 level"
        alert(rsi_msg,  alert.freq_once_per_bar_close) // *** like this 
    else if _cu and _rt_bar
        rsi_msg := rsi_msg + "RSI (" + tostring(rsi_rsi) + ")  crossing down 30 level"
        alert(rsi_msg,  alert.freq_once_per_bar_close)  // *** like this 

// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

        
// Period = input(20, minval=1)
// hline(0, color=purple, linestyle=line)
// xStdDev = stdev(close, Period)
// xMA = sma(close, Period)
// nRes = (close - xMA) / xStdDev
// plot(nRes, color=blue, title="Z-Score")

// # ========================================================================= #













f_triggerSma(_ticker)=>
    _s  = sma(close, 14)
    // sma_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_triggerSma(_ticker)=>
    sma_r = sma(close, 14)
    sma_x = crossover(close, sma_r)
    sma_y = crossunder(close, sma_r)
    sma_rt = barstate.isrealtime
    
    [sma_sma, sma_co, sma_cu, sma_rt_bar] = security(rsi_ticker, timeframe.period, [sma_r, sma_x, sma_y, sma_rt])
    
    rsi_msg = rsi_ticker + ", " + timeframe.period + ": "
    
    if rsi_co and rsi_rt_bar
        rsi_msg := rsi_msg + "RSI (" + tostring(rsi_rsi) + ") crossing up 70 level"
        alert(rsi_msg,  alert.freq_once_per_bar_close) // *** like this 
    else if _cu and _rt_bar
        rsi_msg := rsi_msg + "RSI (" + tostring(rsi_rsi) + ")  crossing down 30 level"
        alert(rsi_msg,  alert.freq_once_per_bar_close)  // *** like this 

// ---- //
//      //
//      //
// -  - //
//      //
//      //
// ---- //


// # ========================================================================= #
f_triggerComulative(_ticker)=>
    // # ========================================================================= #
    sma_s  = sma(close, 14)
    //sma_co = crossover(close, sma_s)
    sma_co = close > sma_s
    sma_cu = close < sma_s 
    // # ========================================================================= #
    comrsi_r  = rsi(close, 7)
    comrsi_co = comrsi_r > 50
    comrsi_cu = comrsi_r < 50    
    // # ========================================================================= #
    mom_m  = mom(close, 14)
    mom_co = mom_m > 0
    mom_cu = mom_m < 0

// # ========================================================================= #

    com_rt = barstate.isrealtime

    // # ========================================================================= #
    
    // [_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, com_rt])
    // _msg = _ticker + ", " + timeframe.period + ": "


    if sma_co and comrsi_co and mom_co and mom_ com_rt
            alert("commulative_bull (" + tostring(mom_m) + tostring(comrsi_r) + tostring(sma_s) + ")  crossing up TBD level", alert.freq_once_per_bar_close)
    else if sma_cu and comrsi_cu and mom_cu and com_rt
            alert("commulative_bear (" + tostring(mom_m) + tostring(comrsi_r) + tostring(sma_s) + ")  crossing down TBD level", alert.freq_once_per_bar_close)



plot(sma(close, 14), "SMA")
f_triggerComulative(_ticker)=>


f_triggerRsi(syminfo.tickerid)

f_triggerComulative(_ticker)=>
f_triggerComulative(syminfo.tickerid)

// MKT bull
// MKT bear
f_triggerComulative("AMEX:UVIX")

// gold phy
f_triggerComulative("AMEX:AAAU")
// gold options
f_triggerComulative("LSE:3GOL")
// gold miners
f_triggerComulative("AMEX:NUGT")
// gold div
f_triggerComulative("NASDAQ:GLDI")
// gold short
f_triggerComulative("AMEX:DUST")
f_triggerComulative("LSE:3GOS")

// silver phy
// silver options
f_triggerComulative("LSE:3SIL")
// silver miners
// silver div
f_triggerComulative("NASDAQ:SLVO")
// silver short
f_triggerComulative("LSE:3SIS")

// oil phy
// oil options
f_triggerComulative("LSE:3OIL")
// oil miners
// oil div
// oil short
f_triggerComulative("LSE:3OIS")

// nlg phy
// nlg options
f_triggerComulative("LSE:3NGL")
// nlg miners
// nlg div
// nlg short
f_triggerComulative("LSE:3NGS")

// URANIUM phy
// URANIUM options
// URANIUM miners
// URANIUM div
// URANIUM short


// MOLYBDENUM

// lumber

// MAGNESIUM

// TITANIUM

// RHODIUM

// pal phy
f_triggerComulative("LSE:PHPD")
// pal options
f_triggerComulative("LSE:2PAL") 
// pal miners
// pal div
// pal short
f_triggerComulative("LSE:1PAS")

// pla phy
// pla options
f_triggerComulative("LSE:LPLA")
// pla miners
// pla div
// pla short

// copper phy
f_triggerComulative("LSE:TCOP")
// copper options
f_triggerComulative("LSE:3HCL") 
// copper miners
// copper div
// copper short
f_triggerComulative("LSE:3HCS") 

// leed phy
// leed options
// leed miners
// leed div
// leed short

// iron ore phy
// iron ore options
// iron ore miners
// iron ore div
// iron ore short

// zinc phy
// zinc options
// zinc miners
// zinc div
// zinc short

// ALUMINIUM phy
// ALUMINIUM options
f_triggerComulative("LSE:LALU")
// ALUMINIUM miners
// ALUMINIUM div
// ALUMINIUM short

// nickel phy
f_triggerComulative("LSE:TNIK")
f_triggerComulative("LSE:NICK")
// nickel options
f_triggerComulative("LSE:LNIK")
// nickel miners
f_triggerComulative("ASX:NIC")
// nickel div
// nickel short
f_triggerComulative("LSE:SNIK")



// soy phy
// soy options
// soy miners
f_triggerComulative("AMEX:SOYB")
// soy div
// soy short

// corn phy
// corn options
// corn miners
f_triggerComulative("AMEX:CORN")
// corn div
// corn short

// cotton phy
// cotton options
// cotton miners
f_triggerComulative("LSE:COTN")
// cotton div
// cotton short

// wheat phy
// wheat options
f_triggerComulative("LSE:3WHL")
// wheat miners
// wheat div
// wheat short

// sugar phy
// sugar options
f_triggerComulative("LSE:3SUL")
// sugar miners
// sugar div
// sugar short

// coffee phy
// coffee options
f_triggerComulative("LSE:LCFE")
// coffee miners
// coffee div
// coffee short

// coc phy
// coc options
f_triggerComulative("LSE:LCOC")
// coc miners
// coc div
// coc short


//bit
//bit short

// f_triggerComulative("NASDAQ:SQQQ")

f_triggerComulative("TASE:BONS")
f_triggerComulative("TASE:LUMI")
f_triggerComulative("TASE:MGRT")
f_triggerComulative("TASE:MNRT")

f_triggerComulative("LSE:3NFE")




// f_triggerSma()
// f_triggerRsi()
// f_triggerMom()

// commulative. all.

// # ========================================================================= #
















//@version=4
study("alert() with multiple indicators", overlay=true)

// var:
// add sar, zscore, ucs, other signals
// only bull

f_triggerSma()=>
    _s  = sma(close, 14)
    // sma_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)
    // rsi_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)

// change var name for each func
// if all alerts // 
// all like orig

// _rt = barstate.isrealtime
//     [_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _rt])
// if _co and _rt_bar
//         _msg := _msg + "RSI (" + tostring(_rsi) + ") crossing up 70 level"
//         alert(_msg,  alert.freq_once_per_bar_close) // *** like this 

plot(sma(close, 14), "SMA")
f_triggerSma()
f_triggerRsi()
f_triggerMom()


// # ========================================================================= #


// Avoiding repainting with alerts

// The most common instances of repainting traders want to avoid with alerts are ones where they must prevent an alert from triggering at some point during the realtime bar when it would not have triggered at its close. This can happen when these conditions are met:

//     The calculations used in the condition triggering the alert can vary during the realtime bar. This will be the case with any calculation using high, low or close, for example, which includes almost all built-in indicators. It will also be the case with the result of any request.security() call using a higher timeframe than the chart’s, when the higher timeframe’s current bar has not closed yet.
//     The alert can trigger before the close of the realtime bar, so with any frequency other than “Once Per Bar Close”.

// The simplest way to avoid this type of repainting is to configure the triggering frequency of alerts so they only trigger on the close of the realtime bar. There is no panacea; avoiding this type of repainting always entails waiting for confirmed information, which means the trader must sacrifice immediacy to achieve reliability.

// Note that other types of repainting such as those documented in our Repainting section may not be preventable by simply triggering alerts on the close of realtime bars.

Overview

Ami_Trade_alert() with multiple symbols supports conditions such as RSI overbought signals, custom crossover rules, center line crosses at 50, SAR alerts, and daily checks. The script uses the alert function combined with security calls to create dynamic messages for bull and bear signals. Alerts are configured to fire on specific conditions without built-in plotting on the price chart. It draws its output in a separate pane for easy monitoring. No main settings are defined in the code, and the script relies on user-defined alert conditions for execution.

Details

Published by

amico1234 on GitHub

Code credit

amico5, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Asymmetrical RSI

by everget
948 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 10 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

Indicator v6 Oscillators & momentumDivergence Repaints
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Indicator

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop
261 stars

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI

KD指標

by TaichiS
219 stars

This script calculates and plots a Stochastic Oscillator (KD indicator) in a separate chart pane. It determines the fast stochastic value over a 9-period lookback, then applies a 3-period Simple Moving Average (SMA) to create the %K line, and a second 3-period

Indicator v4 Oscillators & momentum
Updated 5 years ago · None stated GitHub repository of KD指標

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers