 3 indicators in another time frame 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aryaniroo

//@version=5
indicator(" 3 indicators in another time frame " , overlay= true ,max_boxes_count=20,max_bars_back=500 )
timferm=input.string("15",title=" tim pivot " )
timfermici=input.string("15",title=" tim ichimoku " )
BARINDEX= bar_index
TIMBOLINGER= input.string("15", title="tim bollinger  ")

[open1D, high1D, low1D, close1D,volume1D,ohlc41D,hlc31D,hl21D] = request.security(syminfo.tickerid,timferm, [open, high, low, close,volume,ohlc4,hlc3,hl2])
// plotcandle( open1D, high1D, low1D, close1D,title='kandel', color = close1D > open1D ? color.green : color.red,
//  wickcolor=color.rgb(83, 78, 83) , display= display.all)


/////////// اوردر بلوک ///////


sens = input.int(28, minval=1, title='Pivot precision adjustment', group='Order Block')
sens /= 100

//OB Colors
col_bullish = input.color(#a7b3b0, title="Bullish OB Border", inline="a", group="Order Block")
col_bullish_ob = input.color(color.new(#a9c2bc, 85), title="Background", inline="a", group="Order Block")

col_bearish = input.color(#9c6c6c, title="Bearish OB Border", inline="b", group="Order Block")
col_bearish_ob = input.color(color.new(#8d7070, 85), title="Background", inline="b", group="Order Block")


// Alerts
buy_alert = input.bool(title='Buy Signal', defval=true, group='Alerts', tooltip='An alert will be sent when price goes below the top of a bullish order block.')
sell_alert = input.bool(title='Sell Signal', defval=true, group='Alerts', tooltip='An alert will be sent when price goes above the bottom of a bearish order block.')
ONICHIMOCO=input.bool(title='ایچیموکو ', defval=true)
BOXOIVOT()=>
    
    bool ob_created = false
    bool ob_created_bull = false
    var int cross_index = na

   
    var box drawlongBox = na
    var longBoxes = array.new_box()
    var box drawShortBox = na
    var shortBoxes = array.new_box()


   
    pc = (open1D - open1D[3]) / open1D[3] * 100

   
    if ta.crossunder(pc, -sens)
        ob_created := true
        cross_index := BARINDEX
        cross_index

   
    if ta.crossover(pc, sens)
        ob_created_bull := true
        cross_index := BARINDEX
        cross_index


    
    if ob_created and cross_index - cross_index[1] > 5
        float last_green = 0
        float highest = 0
       
        for i = 4 to 15 by 1
            if close1D[i] > open1D[i]
                last_green := i
                break
      
        drawShortBox := box.new(left=BARINDEX[last_green], top=high1D[last_green], bottom=low1D[last_green], right=BARINDEX[last_green], bgcolor=col_bearish_ob, border_color=col_bearish, extend=extend.right)
        array.push(shortBoxes, drawShortBox)

   
    
    if ob_created_bull and cross_index - cross_index[1] > 5
        float last_red = 0
        float highest = 0
       
        for i = 4 to 15 by 1
            if close1D[i] < open1D[i]
                last_red := i
                break
       
        drawlongBox := box.new(left=BARINDEX[last_red], top=high1D[last_red], bottom=low1D[last_red], right=BARINDEX[last_red], bgcolor=col_bullish_ob, border_color=col_bullish, extend=extend.right)
        array.push(longBoxes, drawlongBox)

    [shortBoxes,longBoxes]
[shortBoxes,longBoxes]=BOXOIVOT()
// ----------------- Bearish Order Block -------------------
// Clean up OB boxes and place alerts
if array.size(shortBoxes) > 0
    for i = array.size(shortBoxes) - 1 to 0 by 1
        sbox = array.get(shortBoxes, i)
        top = box.get_top(sbox)
        bot = box.get_bottom(sbox)
        // If the two last closes are above the high of the bearish OB - Remove the OB
        if close1D[1] > top and close1D[2] > top
            array.remove(shortBoxes, i)
            box.delete(sbox)
        // Alerts
        if high1D > bot and sell_alert
            alert('قیمت در حمایت ', alert.freq_once_per_bar)

// ----------------- Bullish Clean Up -------------------
// Clean up OB boxes and place alerts
if array.size(longBoxes) > 0
    for i = array.size(longBoxes) - 1 to 0 by 1
        sbox = array.get(longBoxes, i)
        bot = box.get_bottom(sbox)
        top = box.get_top(sbox)
        // If the two last closes are below the low of the bullish OB - Remove the OB
        if close1D[1] < bot and close1D[2] < bot
            array.remove(longBoxes, i)
            box.delete(sbox)
        // Alerts
        if low1D < top and buy_alert
            alert('قیمت در مقاومت', alert.freq_once_per_bar)
////////////////قسمت دوم قیمت کندل ایچیموکو //////////////


conversionPeriodsICH = input.int(9, minval=1, title="Conversion Line Length")
basePeriodsICH = input.int(26, minval=1, title="Base Line Length")
laggingSpan2PeriodsICH = input.int(52, minval=1, title="Leading Span B Length")
displacementICH = input.int(26, minval=1, title="Displacement")


[openICH, highICH, lowICH, closeICH,volumeICH,ohlc4ICH,hlc3ICH,hl2ICH] = request.security(syminfo.tickerid,timferm, [open, high, low, close,volume,ohlc4,hlc3,hl2])


Ichi ()=>
    conversionLine = math.avg(ta.lowest(conversionPeriodsICH), ta.highest(conversionPeriodsICH))
    baseLine = math.avg(ta.lowest(basePeriodsICH), ta.highest(basePeriodsICH))
    leadLine1 = math.avg(conversionLine, baseLine)
    leadLine2 = math.avg(ta.lowest(laggingSpan2PeriodsICH), ta.highest(laggingSpan2PeriodsICH))
   
    [conversionLine,baseLine,leadLine1,leadLine2]

[conversionLineICH,baseLineICH,leadLine1ICH,leadLine2ICH]=request.security("",timfermici,Ichi () )

baseLlineICH = math.avg(ta.lowest(conversionPeriodsICH), ta.highest(conversionPeriodsICH))

p1ichi = plot(leadLine1ICH, offset = displacementICH - 1,color=#0aec11)
  
p2ichi = plot(leadLine2ICH, offset = displacementICH - 1, color=#700606)
     
fill(p1ichi, p2ichi, color = leadLine1ICH > leadLine2ICH ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))
////////////////////باند بولینگر تایم جدا گانه ///////////////

length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")

BOLINGERTIM()=>
    basis = ta.sma(src, length)
    dev = mult * ta.stdev(src, length)
    upper = basis + dev
    lower = basis - dev
    [basis,upper,lower]
[basis,upper,lower]=request.security("",TIMBOLINGER,BOLINGERTIM() )
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1bb = plot(upper, "Upper", color=#b68c64, offset = offset)
p2bb = plot(lower, "Lower", color=#b68c64, offset = offset)
// fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))