Indicator · Pine Script v4 · On the chart

AG DETECTOR

by Anderson-ALGO· code credited to Anderson_Guilcapi

AG Detector is an overlay indicator that calculates multi-timeframe pivot levels and projects them onto the price chart.

View on GitHub

Repaints

GitHub stars9on the repository
Pine versionv4older, still runs
Lines of code162
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update5 years ago30 Nov 2020

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

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

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

//@version=4
study(title="|AG| DETECTOR", shorttitle="|AG| DETECTOR", overlay=true)

tim                 = input(    "W",            title="TIME FOR DETECTOR")
type_sw             = input(    "Camarilla",    title="  Pivots Calculation",             options=["Traditional", "Camarilla", "Standard D." ,"Fibonacci"])
_i                  = input(     1,             title="  Index Back", minval  =  0)
type_color          = input(    "BLACK",        title="  Color",                          options=["AQUA", "BLACK", "BLUE", "FUCHSIA", "GRAY", "GREEN", "PURPLE", "ORANGE", "RED"])
tra1                = input(     0,             title="  Transparency")
type_sw1            = input(    "PLOT All",     title="  PLOT SETTINGS",                  options=["LOCKBACK", "PLOT All"])
daily_adr           = input(                    title="  Number of Days Back",            type=input.integer, defval=7, minval=0)
andy                = input(                    title="Change Candle Colour?",          defval = true)
showlabels          = input(    true,           title="Labels")
//SECURITY FOR TIME
High3  = security(syminfo.tickerid,         tim,            high    [_i],       barmerge.gaps_off,       barmerge.lookahead_on)
Low3   = security(syminfo.tickerid,         tim,            low     [_i],       barmerge.gaps_off,       barmerge.lookahead_on)
Close3 = security(syminfo.tickerid,         tim,            close   [_i],       barmerge.gaps_off,       barmerge.lookahead_on)
//CALCULATIONS

r=High3-Low3
pivot =     (High3 + Low3 + Close3 ) / 3.0
//Std
hvar = pow(High3     - pivot, 2)
lvar = pow(Low3      - pivot, 2)
cvar = pow(Close3    - pivot, 2)
dev = sqrt((hvar + lvar + cvar) / 3)
//
h51a=       (High3/Low3)*Close3
R5 =        (Close3 + (High3-Low3)*(1.1/2)) + 1.168 * ((Close3 + (High3-Low3)*(1.1/2)) - (Close3 + (High3-Low3)*(1.1/4)))
S5 =        (Close3 - (High3-Low3)*(1.1/2)) - 1.168 * ((Close3 - (High3-Low3)*(1.1/4)) - (Close3 - (High3-Low3)*(1.1/2))) 
dtime_r1ab = type_sw == "Traditional" ? pivot + (pivot - Low3)     :na
dtime_s1ab = type_sw == "Traditional" ? pivot - (High3 - pivot)    :na
dtime_r2ab = type_sw == "Traditional" ? pivot + (High3 - Low3)     :na
dtime_s2ab = type_sw == "Traditional" ? pivot - (High3 - Low3)     :na
dtime_r3ab = type_sw == "Traditional" ? (pivot * 2 + (High3 - 2 * Low3))        : type_sw == "Camarilla" ? (Close3 + r*(1.1/4))          :  type_sw == "Fibonacci" ? (pivot + ((pivot - Low3)*1.000))   : type_sw    ==      "Standard D."   ? (pivot   + 2 * dev) :na
dtime_s3ab = type_sw == "Traditional" ? (pivot * 2 - (2 * High3 - Low3))        : type_sw == "Camarilla" ? (Close3 - r*(1.1/4))          :  type_sw == "Fibonacci" ? (pivot - ((High3 - pivot)*1.000))  : type_sw    ==      "Standard D."   ? (pivot   - 2 * dev) :na
dtime_r4ab = type_sw == "Traditional" ? (pivot * 3 + (High3 - 3 * Low3))        : type_sw == "Camarilla" ? (Close3 + r*(1.1/2))          :  type_sw == "Fibonacci" ? (pivot + ((High3 - pivot)*1.272))  : type_sw    ==      "Standard D."   ? (pivot   + 3 * dev) :na
dtime_s4ab = type_sw == "Traditional" ? (pivot * 3 - (3 * High3 - Low3))        : type_sw == "Camarilla" ? (Close3 - r*(1.1/2))          :  type_sw == "Fibonacci" ? (pivot - ((High3 - pivot)*1.272))  : type_sw    ==      "Standard D."   ? (pivot   - 3 * dev) :na
dtime_r5ab = type_sw == "Traditional" ? (pivot * 4 + (High3 - 4 * Low3))        : type_sw == "Camarilla" ?  R5                           :  type_sw == "Fibonacci" ? (pivot + ((High3 - pivot)*1.618))  : type_sw    ==      "Standard D."   ? (pivot   + 4 * dev) :na
dtime_s5ab = type_sw == "Traditional" ? (pivot * 4 - (4 * High3 - Low3))        : type_sw == "Camarilla" ?  S5                           :  type_sw == "Fibonacci" ? (pivot - ((High3 - pivot)*1.618))  : type_sw    ==      "Standard D."   ? (pivot   - 4 * dev) :na
dtime_r6ab = h51a
dtime_s6ab = Close3 - (h51a-Close3)
//COLOR VARIABLES

colorag = type_color == "AQUA" ? color.aqua: type_color == "BLACK" ? color.black: type_color == "BLUE" ? color.blue : type_color == "FUCHSIA" ? color.fuchsia : type_color == "GRAY" ? color.gray : type_color == "GREEN" ? color.green :  type_color == "PURPLE" ? color.purple :  type_color == "ORANGE" ? color.orange :  type_color == "RED" ? color.red :  na 
//LOCKBACK DAYS
new_bar(res) =>
    change(time(res)) != 0
    
new_period(condition, src) =>
    result = 0.0
    result := condition ? src : result[1]
    result
    
one_day = 1000 * 60 * 60 * 24
new_day = daily_adr > 0 and timenow - time < one_day * daily_adr and new_bar("D")
High1 = new_period(new_day, High3)
ij2 = type_sw1 == "LOCKBACK" ? (timeframe.isintraday or timeframe.isdaily ? High1 : na) : type_sw1 == "PLOT All" ? true : na
diff   = iff(type_sw=="Camarilla" or type_sw=="Fibonacci" or type_sw=="Standard D.", true, false )
//RESISTANCE
HTFo    =                iff((close<= dtime_r6ab)  and (close>=dtime_r5ab)         and not (close<dtime_r5ab)                                  , dtime_r6ab, na)
HTFo1   =                iff((close<= dtime_r6ab)  and (close>=dtime_r5ab)         and not (close<dtime_r5ab)                                  , dtime_r5ab, na)
HTFo2   =                iff((close<= dtime_r5ab)  and (close>=dtime_r4ab)         and not (close<dtime_r4ab)       and not (close>dtime_r5ab) , dtime_r5ab, na)
HTFo3   =                iff((close<= dtime_r5ab)  and (close>=dtime_r4ab)         and not (close<dtime_r4ab)       and not (close>dtime_r5ab) , dtime_r4ab, na)
HTFo4   =                iff((close<= dtime_r4ab)  and (close>=dtime_r3ab)         and not (close<dtime_r3ab)       and not (close>dtime_r4ab) , dtime_r4ab, na)
HTFo5   =                iff((close<= dtime_r4ab)  and (close>=dtime_r3ab)         and not (close<dtime_r3ab)       and not (close>dtime_r4ab) , dtime_r3ab, na)
HTFo6   = iff(diff     , iff((close<= dtime_r3ab)  and (close>=dtime_s3ab)         and not (close<dtime_s3ab)       and not (close>dtime_r3ab) , dtime_r3ab, na), iff((close<= dtime_r3ab)  and (close>=dtime_r2ab)  and not (close<dtime_r2ab)       and not (close>dtime_r3ab) , dtime_r3ab, na))

/////////////////////////////////////////////////////////FOR Traditional S&R ////////////////////////////////////////////////////////////////////
//
HTFo6a  =  iff(diff, na, iff((close<= dtime_r3ab)  and (close>=dtime_r2ab)         and not (close<dtime_r2ab)       and not (close>dtime_r3ab) , dtime_r2ab, na))
HTFo7a  =  iff(diff, na, iff((close<= dtime_r2ab)  and (close>=dtime_r1ab)         and not (close<dtime_r1ab)       and not (close>dtime_r2ab) , dtime_r2ab, na))

HTFo8a  =  iff(diff, na, iff((close<= dtime_r2ab)  and (close>=dtime_r1ab)         and not (close<dtime_r1ab)       and not (close>dtime_r2ab) , dtime_r1ab, na))
HTFo9a  =  iff(diff, na, iff((close<= dtime_r1ab)  and (close>=pivot     )         and not (close<pivot     )       and not (close>dtime_r1ab) , dtime_r1ab, na))

HTFo6a1 =  iff(diff, na, iff((close>= dtime_s1ab)  and (close<=pivot     )         and not (close>pivot     )       and not (close<dtime_s1ab) , dtime_s1ab, na))
HTFo7a1 =  iff(diff, na, iff((close>= dtime_s2ab)  and (close<=dtime_s1ab)         and not (close>dtime_s1ab)       and not (close<dtime_s2ab) , dtime_s1ab, na))

HTFo8a1 =  iff(diff, na, iff((close>= dtime_s2ab)  and (close<=dtime_s1ab)         and not (close>dtime_s1ab)       and not (close<dtime_s2ab) , dtime_s2ab, na))
HTFo9a1 =  iff(diff, na, iff((close>= dtime_s3ab)  and (close<=dtime_s2ab)         and not (close>dtime_s2ab)       and not (close<dtime_s3ab) , dtime_s2ab, na))
//PIVOT
HTFo10a =  iff(diff, na, pivot )
//Supports
HTFo7   = iff(diff     , iff((close>= dtime_s3ab)  and (close<=dtime_r3ab)         and not (close>dtime_r3ab)       and not (close<dtime_s3ab) , dtime_s3ab, na), iff((close>= dtime_s3ab)  and (close<=dtime_s2ab)  and not (close>dtime_s2ab)       and not (close<dtime_s3ab) , dtime_s3ab, na))
HTFo8   =                iff((close>= dtime_s4ab)  and (close<=dtime_s3ab)         and not (close>dtime_s3ab)       and not (close<dtime_s4ab) , dtime_s3ab, na)
HTFo9   =                iff((close>= dtime_s4ab)  and (close<=dtime_s3ab)         and not (close>dtime_s3ab)       and not (close<dtime_s4ab) , dtime_s4ab, na)
HTFo10  =                iff((close>= dtime_s5ab)  and (close<=dtime_s4ab)         and not (close>dtime_s4ab)       and not (close<dtime_s5ab) , dtime_s4ab, na)
HTFo11  =                iff((close>= dtime_s5ab)  and (close<=dtime_s4ab)         and not (close>dtime_s4ab)       and not (close<dtime_s5ab) , dtime_s5ab, na)
HTFo12  =                iff((close>= dtime_s6ab)  and (close<=dtime_s5ab)         and not (close>dtime_s5ab)                                  , dtime_s5ab, na)
HTFo13  =                iff((close>= dtime_s6ab)  and (close<=dtime_s5ab)         and not (close>dtime_s5ab)                                  , dtime_s6ab, na)
//PLOT CHAR
plotchar(ij2 and HTFo     ? HTFo    :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo1    ? HTFo1   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo2    ? HTFo2   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo3    ? HTFo3   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo4    ? HTFo4   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo5    ? HTFo5   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo6    ? HTFo6   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo7    ? HTFo7   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo8    ? HTFo8   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo9    ? HTFo9   :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo10   ? HTFo10  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo11   ? HTFo11  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo12   ? HTFo12  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo13   ? HTFo13  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo6a   ? HTFo6a  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo7a   ? HTFo7a  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo8a   ? HTFo8a  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo9a   ? HTFo9a  :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo10a  ? HTFo10a :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo6a1  ? HTFo6a1 :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo7a1  ? HTFo7a1 :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo8a1  ? HTFo8a1 :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
plotchar(ij2 and HTFo9a1  ? HTFo9a1 :na    ,char="□",     location=location.absolute,     size=size.tiny,     color=colorag,      transp=tra1)
//BAR COLOR CHANGE DEFVAL 720 (12 HOURS)
High1a  = security(syminfo.tickerid,        "720",      high[1],        barmerge.gaps_off,      barmerge.lookahead_on)
Low1a   = security(syminfo.tickerid,        "720",      low[1],         barmerge.gaps_off,      barmerge.lookahead_on)
Close1a = security(syminfo.tickerid,        "720",      close[1],       barmerge.gaps_off,      barmerge.lookahead_on)
king = (High1a + Low1a + Close1a ) / 3.0
barcolor(iff(andy, close>king ? colorag : color.black, na)) 

//LABELS
tim1          = iff(tim=="D", "DAILY", iff(tim=="W", "WEEKLY", iff(tim=="M", "MONTHLY", iff(tim=="3M", "QUATERLY", iff(tim=="12M", "YEARLY", iff(tim=="6M", "HALF-YEAR", na))))))
calculation   = iff(type_sw=="Fibonacci","Fibonacci", iff(type_sw=="Camarilla", "Camarilla", iff(type_sw=="Traditional", "Traditional", iff(type_sw=="Standard D.", "Standard D.", na))))
// Label for S/R
chper = time - time[1]
chper := change(chper) > 0 ? chper[1] : chper

_COLOR = type_color == "BLACK" ? color.white : color.black
// Labels
if showlabels
    var label s1blabel = na, var label s1alabel = na, var label s2blabel = na, var label s2alabel = na, var label s3blabel = na, var label s3alabel = na, var label s4blabel = na, var label s4alabel = na, var label s5blabel = na, var label s5alabel = na, var label s6alabel = na, var label pvilabel = na
    var label r1blabel = na, var label r1alabel = na, var label r2blabel = na, var label r2alabel = na, var label r3blabel = na, var label r3alabel = na, var label r4blabel = na, var label r4alabel = na, var label r5blabel = na, var label r5alabel = na, var label r6alabel = na
    
    label.delete(s1blabel), label.delete(s1alabel), label.delete(s2blabel), label.delete(s2alabel), label.delete(s3blabel), label.delete(s3alabel), label.delete(s4blabel), label.delete(s4alabel), label.delete(s5blabel), label.delete(s5alabel), label.delete(s6alabel), label.delete(pvilabel)
    label.delete(r1blabel), label.delete(r1alabel), label.delete(r2blabel), label.delete(r2alabel), label.delete(r3blabel), label.delete(r3alabel), label.delete(r4blabel), label.delete(r4alabel), label.delete(r5blabel), label.delete(r5alabel), label.delete(r6alabel)
    r6alabel := label.new(x = time + chper * 20, y = HTFo   , text = "R6= " + tostring(dtime_r6ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r5alabel := label.new(x = time + chper * 20, y = HTFo1  , text = iff(type_sw=="Standard D.", "R4= ","R5= ") + tostring(dtime_r5ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r5blabel := label.new(x = time + chper * 20, y = HTFo2  , text = iff(type_sw=="Standard D.", "R4= ","R5= ") + tostring(dtime_r5ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r4alabel := label.new(x = time + chper * 20, y = HTFo3  , text = iff(type_sw=="Standard D.", "R3= ","R4= ") + tostring(dtime_r4ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r4blabel := label.new(x = time + chper * 20, y = HTFo4  , text = iff(type_sw=="Standard D.", "R3= ","R4= ") + tostring(dtime_r4ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r3alabel := label.new(x = time + chper * 20, y = HTFo5  , text = iff(type_sw=="Standard D.", "R2= ","R3= ") + tostring(dtime_r3ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r3blabel := label.new(x = time + chper * 20, y = HTFo6  , text = iff(type_sw=="Standard D.", "R2= ","R3= ") + tostring(dtime_r3ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r2alabel := label.new(x = time + chper * 20, y = HTFo6a , text = "R2= " + tostring(dtime_r2ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r2blabel := label.new(x = time + chper * 20, y = HTFo7a , text = "R2= " + tostring(dtime_r2ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r1alabel := label.new(x = time + chper * 20, y = HTFo8a , text = "R1= " + tostring(dtime_r1ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    r1blabel := label.new(x = time + chper * 20, y = HTFo9a , text = "R1= " + tostring(dtime_r1ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    pvilabel := label.new(x = time + chper * 20, y = HTFo10a, text = "P = " + tostring(pivot     , "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s1blabel := label.new(x = time + chper * 20, y = HTFo6a1, text = "S1= " + tostring(dtime_s1ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s1alabel := label.new(x = time + chper * 20, y = HTFo7a1, text = "S1= " + tostring(dtime_s1ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s2blabel := label.new(x = time + chper * 20, y = HTFo8a1, text = "S2= " + tostring(dtime_s2ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s2alabel := label.new(x = time + chper * 20, y = HTFo9a1, text = "S2= " + tostring(dtime_s2ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s3blabel := label.new(x = time + chper * 20, y = HTFo7  , text = iff(type_sw=="Standard D.", "S2= ", "S3= ") + tostring(dtime_s3ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s3alabel := label.new(x = time + chper * 20, y = HTFo8  , text = iff(type_sw=="Standard D.", "S2= ", "S3= ") + tostring(dtime_s3ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s4blabel := label.new(x = time + chper * 20, y = HTFo9  , text = iff(type_sw=="Standard D.", "S3= ", "S4= ") + tostring(dtime_s4ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s4alabel := label.new(x = time + chper * 20, y = HTFo10 , text = iff(type_sw=="Standard D.", "S3= ", "S4= ") + tostring(dtime_s4ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s5blabel := label.new(x = time + chper * 20, y = HTFo11 , text = iff(type_sw=="Standard D.", "S4= ", "S5= ") + tostring(dtime_s5ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s5alabel := label.new(x = time + chper * 20, y = HTFo12 , text = iff(type_sw=="Standard D.", "S4= ", "S5= ") + tostring(dtime_s5ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)
    s6alabel := label.new(x = time + chper * 20, y = HTFo13 , text = "S6= " + tostring(dtime_s6ab, "#.####") + "\n" + tim1 + "\n" + calculation, color = colorag, textcolor=_COLOR, style=label.style_label_left, xloc = xloc.bar_time, yloc=yloc.price)

Overview

AG DETECTOR supports multiple pivot calculation formulas including Traditional, Camarilla, Fibonacci, and Standard Deviation based on user-selected higher timeframes. Settings allow customization of the evaluation resolution, historical index lookback, candle recoloring, and display labels. Note that the indicator uses higher timeframe data with lookahead enabled.

Details

Published by

Anderson-ALGO on GitHub

Code credit

Anderson_Guilcapi, as written in the script's header

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
TIME FOR DETECTORstringWtim
  Pivots CalculationstringCamarillatype_sw
  Index Backint1_i
  ColorstringBLACKtype_color
  Transparencyint0tra1
  PLOT SETTINGSstringPLOT Alltype_sw1
  Number of Days Backint7daily_adr
Change Candle Colour?booltrueandy
Labelsbooltrueshowlabels
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

948 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 10 days ago · GPL-3.0 GitHub repository of Moving Average Channel

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

BZ-tracker

by Allen1212
303 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 2 years ago · None stated GitHub repository of BZ-tracker

Function - Linear Regression

by ricardosantos79
261 stars

This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up

Indicator v5 TrendSupport & resistance
Updated 4 years ago · None stated GitHub repository of Function - Linear Regression

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