Attachments forums

List of attachments posted on this forum.


All files on forums: 136046

Re: MT4 Indicator requests and ideas

Chickenspicy, Fri Jul 07, 2023 1:05 pm

Does not repaint!

Code: Select all

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

//@version=5
indicator("Faytterro Estimator", overlay=true, max_lines_count=500)

src=input(hlc3,title="source")
len=input.int(10,title="lenght", maxval=499)
c1 = input.color(#35cf02 , "positive momentum color")
c2 = input.color(#cf0202, "negative momentum color")
t1 = input.color(color.white, "text color")
cr(x, y) =>
    z = 0.0
    weight = 0.0
    for i = 0 to y-1
        z:=z + x[i]*((y-1)/2+1-math.abs(i-(y-1)/2))
    z/(((y+1)/2)*(y+1)/2)
cr= cr(src,2*len-1) 
width=input.int(3, title="linewidth", minval=1)
plot(cr, color=(cr>=cr[1])? c1 : c2 , linewidth=width,offset=-len+1)

dizi = array.new_float(1000)
var line=array.new_line()
if barstate.islast
    for i=0 to len*2
        array.set(dizi,i,(i*(i-1)*(cr-2*cr[1]+cr[2])/2+i*(cr[1]-cr[2])+cr[2]))
    for i=0 to (len/2+5)
//        array.push(line, line.new(bar_index[len]+i*2-1, array.get(dizi,i*2), bar_index[len]+i*2,array.get(dizi,i*2+1), 
//         color=array.get(dizi,i*2+1)>=array.get(dizi,i*2)?  #35cf02 : #cf0202, width=width))
        array.push(line, line.new(na, na, na, na))
        line.set_xy1(array.get(line,i), bar_index[len]+i*2-1, array.get(dizi,i*2))
        line.set_xy2(array.get(line,i), bar_index[len]+i*2, array.get(dizi,i*2+1))
        line.set_color(array.get(line,i),array.get(dizi,i*2+1)>=array.get(dizi,i*2)?  c1 : c2)
        line.set_width(array.get(line,i),width)

    
dizii = array.new_float(1000)
for i=0 to len*2
    array.set(dizii,i,(i*(i-1)*(cr-2*cr[1]+cr[2])/2+i*(cr[1]-cr[2])+cr[2]))
r=ta.stdev(close,len*10)
mid=cr(src,10*len-1)
bot=cr(src,5*len-1)-r
top=cr(src,5*len-1)+r
buy=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0
sell=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0
ttk=buy? 1 : sell?-1 : 0
sbuy=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0 and ta.highest(ttk,len)[1]!=1 and ta.lowest(ttk,math.round(len/2))[1]!=-1 and close<bot
ssell=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0 and ta.lowest(ttk,len)[1]!=-1 and ta.highest(ttk,math.round(len/2))[1]!=1 and close>top
plotshape(sbuy, title = "buy", text = "strong buy", style = shape.labelup, location = location.belowbar, color = c1, textcolor = t1, size = size.small)
plotshape(ssell, title = "sell", text ="strong sell", style = shape.labeldown, location = location.abovebar, color = c2, textcolor = t1, size = size.small)

buy:=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0 and ta.highest(ttk,len)[1]!=1 and ta.lowest(ttk,math.round(len/2))[1]!=-1 and close>bot and close<top
sell:=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0 and ta.lowest(ttk,len)[1]!=-1 and ta.highest(ttk,math.round(len/2))[1]!=1 and close<top and close>bot
plotshape(buy, title = "buy", text = "buy", style = shape.labelup, location = location.belowbar, color = c1, textcolor = t1, size = size.small)
plotshape(sell, title = "sell", text ="sell", style = shape.labeldown, location = location.abovebar, color = c2, textcolor = t1, size = size.small)

alertbuy=array.get(dizii,len)>array.get(dizii,len-1) and ta.change(cr)<0 and ta.highest(ttk,len)[1]!=1 and ta.lowest(ttk,math.round(len/2))[1]!=-1 and close<top
alertsell=array.get(dizii,len)<array.get(dizii,len-1) and ta.change(cr)>0 and ta.lowest(ttk,len)[1]!=-1 and ta.highest(ttk,math.round(len/2))[1]!=1 and close>bot
alertcondition(alertbuy or alertsell)

int botsignal= (buy or sbuy)? 1 : (ssell or sell)? -1  : na
plot(botsignal, display=display.none)
All files in topic