Untitled

 avatar
user_0084968
plain_text
a year ago
22 kB
9
Indexable
//@version=5
indicator("3P Beta", overlay = false, max_bars_back = 5000)

//volume_ok for usdcad 700, minimum volume to generate candle pattern 
//avgvol for usdcad is below 800, to be in inSession avgvol needs to be under a certain low volume
//ampl for usdcad is 2, if box height is very small, make ampl higher, if box size is quite big, lower ampl
//minimum for lackvol for usdcad is 3000
//minimum for sduvol for usdcad is 1000
//minimum for news for usdcad is 3000
//minimum for volume patterns (cpt1b - cpt5b) for usdcad is 1000
//usdchf 57M volume, 1y , 4.74M, 1M, 0.96
//usdcad 60M volume, 1y, 4.82M, 1M, 1
//audusd 69M volume, 1y, 5.30M, 1M, 1.12
//eurusd 78M, volume, 1y, 5.69M, 1M, 1.24
//usdjpy 101M volume, 1y, 7.30M, 1M, 1.6
//gbpusd 118M volume, 1y, 7.43M, 1M, 1.7
//usdcad 0.0094 
//eurusd 0.0087 
//gbpusd 0.0119
//audusd 0.0079
//usdjpy 1.2700 
//usdchf 0.0077

currentSymbol = syminfo.tickerid
symbols = array.new_string(6)
array.set(symbols, 0, "FX:USDCAD")
array.set(symbols, 1, "FX:EURUSD")
array.set(symbols, 2, "FX:USDJPY")
array.set(symbols, 3, "FX:USDCHF")
array.set(symbols, 4, "FX:AUDUSD")
array.set(symbols, 5, "FX:GBPUSD")

dcur_vals = array.new_float(6)
array.set(dcur_vals, 0, 1)
array.set(dcur_vals, 1, 1.24)
array.set(dcur_vals, 2, 1.6)
array.set(dcur_vals, 3, 0.96)
array.set(dcur_vals, 4, 1.12)
array.set(dcur_vals, 5, 1.7)

pipm_vals = array.new_float(6)
array.set(pipm_vals, 0, 1)
array.set(pipm_vals, 1, 1)
array.set(pipm_vals, 2, 90)
array.set(pipm_vals, 3, 0.82)
array.set(pipm_vals, 4, 0.84)
array.set(pipm_vals, 5, 1.27)

var float dcur = 1.0
var float pipm = 1.0
var bool rightsymbol = false
for i = 0 to 5
    if currentSymbol == array.get(symbols, i)
        dcur := array.get(dcur_vals, i)
        pipm := array.get(pipm_vals, i)
        rightsymbol := true

// Definitions
bl_ok = input(false)
enableall = input(true) and rightsymbol
lookback2 = input(2000)

volume_ok = volume>(input(700))*dcur
sizze = size.small

box_ok = input(false) or enableall

keylevels_ok = input(false) or enableall
kld_ok = input(false) or enableall
adj = input(0.0001)*pipm
dis = input(40)
day = 86400000

fvg_ok = input(false) or enableall
fvg_det = input(false) or enableall
lookback = input(400)
sens = input(0.0010)

ob_ok = input(false) or enableall
len = input(2)
borline = input(0.0004)
sborline = input(0.0016)

news_ok = input(false) or enableall

risvol_ok = input(false) or enableall
falvol_ok = input(false) or enableall
dist = input(50)
ampl = input(2)

sudIntr_ok = input(false) or enableall

lackvol_ok = input(false) or enableall
sudvol_ok = input(false) or enableall

candlepat_ok = input(false) or enableall
cptper = input(0.85)

voldif_ok = input(false) or enableall
multp=input(5)
color_candles = input(false) or enableall

cp_ok = input(false) or enableall

bl = input(0.26)
mcs = input(0.67)
pmval = input(0.0)

b61_ok        = cp_ok,        b51_ok        = cp_ok,        b41_ok        = cp_ok,        b31_ok        = cp_ok
r61_ok        = cp_ok,        r51_ok        = cp_ok,        r41_ok        = cp_ok,        r31_ok        = cp_ok
b62_ok        = cp_ok,        b52_ok        = cp_ok,        b42_ok        = cp_ok,        b32_ok        = cp_ok
r62_ok        = cp_ok,        r52_ok        = cp_ok,        r42_ok        = cp_ok,        r32_ok        = cp_ok
b63_ok        = cp_ok,        b53_ok        = cp_ok,        b43_ok        = cp_ok,        b21_ok        = cp_ok
r63_ok        = cp_ok,        r53_ok        = cp_ok,        r43_ok        = cp_ok,        r21_ok        = cp_ok
b64_ok        = cp_ok,        b54_ok        = cp_ok,        b44_ok        = cp_ok
r64_ok        = cp_ok,        r54_ok        = cp_ok,        r44_ok        = cp_ok
b65_ok        = cp_ok,        b55_ok        = cp_ok
r65_ok        = cp_ok,        r55_ok        = cp_ok
b66_ok        = cp_ok
r66_ok        = cp_ok
bhc_ok        = cp_ok
rhc_ok        = cp_ok
tws_ok        = cp_ok
tbs_ok        = cp_ok

//2nd Definitions
c1=close,c2=close[1],c3=close[2],o1=open,o2=open[1],o3=open[2],h1=high,h2=high[1],h3=high[2],l1=low,l2=low[1],l3=low[2]
c4=close[3],c5=close[4],c6=close[5],o4=open[3],o5=open[4],o6=open[5],h4=high[3],h5=high[4],h6=high[5],l4=low[3],l5=low[4],l6=low[5]
vol = volume
avgvol = (volume + volume[1]+ volume[2])/3
atr=ta.atr(14)
atr2=ta.atr(7)
atr3=ta.atr(2)
inSession = ((atr<0.0007*pipm or atr2<0.0007*pipm or atr3<0.0007*pipm) and avgvol<800*dcur) and ((time >= timestamp(year, month, dayofmonth, 12, 0)) or (time <= timestamp(year, month, dayofmonth, 3, 00)))

//Boxes
var float low_val = 0.0
var float high_val = 0.0

startTime = 0
startTime := inSession and not inSession[1] ? time : startTime[1]
endTime = 0
endTime := not inSession and inSession[1] ? time : endTime[1]
if inSession and not inSession[1]
    low_val := low
    high_val := high
if inSession and startTime < timestamp(year, month, dayofmonth, 18, 0) and startTime > (timestamp(year, month, dayofmonth, 12, 00)) and time > timestamp(year, 8, 20, 0, 0)
    if low < low_val
        low_val := low
        low_val
    if high > high_val
        high_val := high
        high_val

//checks if below/above middle line of box
var bool belowLine_b = na
var bool belowLine_r = na
if bl_ok
    belowLine_b := (c1<((high_val + low_val) / 2))
    belowLine_r := (c1>((high_val + low_val) / 2)) 
else
    belowLine_b := true
    belowLine_r := true
boxsize = high_val - low_val

//Key Levels
var float prevhih2 = na
var float prevlol2 = na
var float prevtop2 = na
var float prevbot2 = na
var box res21 = na
var box sup21 = na
var color impcolor = na
var bool shouldPlot6 = na
var bool shouldPlot7 = na
var float hih2 = na
var float lol2 = na
var float top2 = na
var float bot2 = na

bounce_conditions_b(_level) =>
    conb = low < _level+adj*2 and low > _level-adj*2 and kld_ok and (c4>_level and c3>_level and c2>_level and c1>_level) and vol>1000*dcur and belowLine_b
bounce_conditions_r(_level) =>
    conr = high > _level-adj*2 and high < _level+adj*2 and kld_ok and (c4<_level and c3<_level and c2<_level and c1<_level) and vol>1000 and belowLine_r

if keylevels_ok and bar_index>last_bar_index-lookback2
    hih2 := ta.pivothigh(high, dis, dis)
    lol2 := ta.pivotlow(low, dis, dis)
    top2 := ta.valuewhen(hih2, high[dis], 0)
    bot2 := ta.valuewhen(lol2, low[dis], 0)
    if bar_index == 0
        prevtop2 := top2
    if bar_index == 0
        prevbot2 := bot2
    prevbot2 := bot2
    prevtop2 := top2

    if kld_ok
        var int max_lookback = 500
        bounce_detected_w = false
        bounce_detected_m = false
        bounce_detected_s = false
        for i = 0 to max_lookback
            if not na(top2[i]) and bounce_conditions_b(top2[i]) 
                bounce_detected_w := true
            if not na(bot2[i]) and bounce_conditions_b(bot2[i])
                bounce_detected_w := true

        var int barsSincePattern6 = 0
        shouldPlot6 := bounce_detected_w and (barsSincePattern6 >= 7 or na(barsSincePattern6))
        barsSincePattern6 := shouldPlot6 ? 0 : barsSincePattern6 + 1

        var int max_lookback_r = 500
        bounce_detected_r_w = false
        bounce_detected_r_m = false
        bounce_detected_r_s = false
        for i = 0 to max_lookback_r
            if not na(top2[i]) and bounce_conditions_r(top2[i])
                bounce_detected_r_w := true
            if not na(bot2[i]) and bounce_conditions_r(bot2[i])
                bounce_detected_r_w := true

        var int barsSincePattern7 = 0
        shouldPlot7 := bounce_detected_r_w and (barsSincePattern7 >= 7 or na(barsSincePattern7))
        barsSincePattern7 := shouldPlot7 ? 0 : barsSincePattern7 + 1

//Volume Divergence rising
var bool risvol = na
var bool risvol1 = na
var bool risvol2 = na
var bool risvol3 = na
var bool risvol4 = na
var bool red = na
var bool green = na
if risvol_ok and bar_index>last_bar_index-lookback2
    risvol1 := vol > ta.highest(vol[1], dist)
    for V = 10 to dist
        for tes = 1 to 10
            risvol4 := (vol[V] > vol[V+tes])
        for am = 1 to (V-1)
            risvol2 := (vol > vol[V-am])
            risvol3 := risvol3 or (vol[V-am] < (0.34 * vol[V]))
    risvol := risvol1 and risvol2 and risvol3 and risvol4 and not risvol[1] and not risvol[2] and not risvol[2] and not risvol[3] and not risvol[4] and not risvol[5] and not risvol[6] and not risvol[7] and not risvol[8] and not risvol[9] and not risvol[10]
    red := risvol and close<open[2] and belowLine_r
    green := risvol and close>open[2] and belowLine_b

//Volume falling
var bool redr = na
var bool greenr = na
if falvol_ok and bar_index>last_bar_index-lookback2
    falvol1 = vol*ampl < ta.highest(vol, 15)
    falvol = falvol1 and falvol_ok and (time == timestamp(year, month, dayofmonth, 0, 30) or time == timestamp(year, month, dayofmonth, 7, 0) or time == timestamp(year, month, dayofmonth, 13, 0))
    redr := falvol and close>(((high_val + low_val)/2)+boxsize*ampl)
    greenr := falvol and close<(((high_val + low_val)/2)-boxsize*ampl)

//fvg
var bool shouldPlot8 = na
var bool shouldPlot9 = na
bounce_conditions_bb(_level) =>
    conbb = low < _level and fvg_det
bounce_conditions_bb2(_level) =>
    conbb = low > _level and fvg_det

bounce_conditions_rr(_level) =>
    conrr = high > _level and fvg_det
bounce_conditions_rr2(_level) =>
    conrr = high < _level and fvg_det

if fvg_ok and bar_index>last_bar_index-lookback
    var bool cond_b = na
    var bool cond_r = na
    if ((c2-o2>sens*pipm) or (o2-c2>sens*pipm))
        if ((h3<l1) or (l3>h1))
            if close[1]>open[1]
                if l1-h3>0.0002*pipm
                    cond_b := true
            if open[1]>close[1]
                if l3-h1>0.0002*pipm
                    cond_r := true
    else
        cond_b := false
        cond_r := false
    
    var int max_lookbackk = lookback
    bounce_det = false
    bounce_det2 = false
    for i = 0 to max_lookbackk
        if not na(low[i])
            if bounce_conditions_bb(low[i])
                if cond_b[i]
                    if not na(high[2+i])
                        if bounce_conditions_bb2(high[2+i])
                            bounce_det := true
        if not na(high[i])
            if bounce_conditions_rr(high[i])
                if cond_r[i]
                    if not na(low[2+i])
                        if bounce_conditions_rr2(low[2+i])
                            bounce_det2 := true

    var int barsSincePattern8 = 0
    shouldPlot8 := bounce_det and (barsSincePattern8 >= 5 or na(barsSincePattern8))
    barsSincePattern8 := shouldPlot8 ? 0 : barsSincePattern8 + 1

    var int barsSincePattern9 = 0
    shouldPlot9 := bounce_det2 and (barsSincePattern9 >= 5 or na(barsSincePattern9))
    barsSincePattern9 := shouldPlot9 ? 0 : barsSincePattern9 + 1

//Order Blocks
bounce_conditions_rr3(_level) =>
    conr = high > _level
bounce_conditions_rr4(_level) =>
    conr = high < _level
bounce_conditions_bb3(_level) =>
    conb = low < _level
bounce_conditions_bb4(_level) =>
    conb = low > _level

var bool shouldPlot10 = na
var bool shouldPlot11 = na

if ob_ok
    left_highest = ta.highest(vol[len+1], len)
    right_highest = ta.highest(vol, len)
    barr=900000
    volhi = vol[len] > ta.highest(vol[len+1], len) and vol[len] > ta.highest(vol, len)
    hi = high[len] == ta.pivothigh(len,len)
    lo = low[len] == ta.pivotlow(len,len)
    var bool cond_b2 = na
    var bool cond_r2 = na
    if volhi
        if lo
            cond_b2 := true
        if hi
            cond_r2 := true
    else
        cond_b2 := false
        cond_r2 := false
    var box[] boxes = array.new_box()
    var float[] bbobsize_values = array.new_float()
    var box[] boxes_r = array.new_box()
    var float[] robsize_values = array.new_float()

    var float[] bobsize_values = array.new_float()
    var float[] rrobsize_values = array.new_float()

    var float bbobsize_value = na
    var float robsize_value = na

    var float bobsize_value = na
    var float rrobsize_value = na

    bobsize_value := close[len]-low[len] < borline ? high[len] : close[len]
    robsize_value := high[len]-close[len] < borline ? low[len] : close[len]
    bbobsize_value := close[len]-low[len] > sborline ? (close[len]+low[len])/2 : low[len]
    rrobsize_value := high[len]-close[len] > sborline ? (high[len]+close[len])/2 : high[len]

    var box bob = na
    var box rob = na

    if cond_b2
        bob := box.new(time-barr*len, bobsize_value, timenow, bbobsize_value, xloc=xloc.bar_time, bgcolor=color.blue, border_color=color.new(color.green, 100))
        array.push(boxes, bob)
        array.push(bbobsize_values, bbobsize_value)
        array.push(bobsize_values, bobsize_value)
    
    if cond_r2
        rob := box.new(time-barr*len, robsize_value, timenow, rrobsize_value, xloc=xloc.bar_time, bgcolor=color.orange, border_color=color.new(color.red, 100))
        array.push(boxes_r, rob)
        array.push(robsize_values, robsize_value)
        array.push(rrobsize_values, rrobsize_value)

    if array.size(boxes) > 0
        for i = 0 to array.size(boxes) - 1
            box_id = array.get(boxes, i)
            bbobsize_value := array.get(bbobsize_values, i)
            bobsize_value := array.get(bobsize_values, i)
            if na(box_id) == false and ta.crossunder(close, bbobsize_value)
                box.delete(box_id)
                array.set(boxes, i, na)
                array.set(bbobsize_values, i, na)
                array.set(bobsize_values, i, na)

    
    if array.size(boxes_r) > 0
        for i = 0 to array.size(boxes_r) - 1
            box_id_r = array.get(boxes_r, i)
            robsize_value := array.get(robsize_values, i)
            rrobsize_value := array.get(rrobsize_values, i)
            if na(box_id_r) == false and ta.crossover(close, robsize_value)
                box.delete(box_id_r)
                array.set(boxes_r, i, na)
                array.set(robsize_values, i, na)
                array.set(rrobsize_values, i, na)

    var int max_lookback2 = lookback2
    bounce_det3 = false
    for i = 0 to max_lookback2
        if not na(bobsize_value[i])
            if bounce_conditions_bb3(bobsize_value[i])
                if cond_b2[i] 
                    if bounce_conditions_bb4(bbobsize_value[i])
                        if not na(bbobsize_value[i])
                            if not (close[i]<bbobsize_value[i])
                                if  (close[5]>close)
                                    bounce_det3 := true

    bounce_det4 = false
    for i = 0 to max_lookback2
        if not na(robsize_value[i])
            if bounce_conditions_rr3(robsize_value[i])
                if cond_r2[i] 
                    if bounce_conditions_rr4(rrobsize_value[i]) 
                        if not na(rrobsize_value[i])
                            if not (close[i]>robsize_value[i])
                                if (close[5]<close)
                                    bounce_det4 := true


    var int barsSincePattern10 = 0
    shouldPlot10 := bounce_det3 and (barsSincePattern10 >= 10 or na(barsSincePattern10))
    barsSincePattern10 := shouldPlot10 ? 0 : barsSincePattern10 + 1
    var int barsSincePattern11 = 0
    shouldPlot11 := bounce_det4 and (barsSincePattern11 >= 10 or na(barsSincePattern11))
    barsSincePattern11 := shouldPlot11 ? 0 : barsSincePattern11 + 1


shouldPlot62 = shouldPlot6 and vol>1500*dcur and c1-l1>0.0008*pipm and vol<3000
shouldPlot63 = shouldPlot6 and vol>3000*dcur and c1-l1>0.0012*pipm
shouldPlot61 = shouldPlot6 and not shouldPlot62 and not shouldPlot63
shouldPlot72 = shouldPlot7 and vol>1500*dcur and h1-c1>0.0008*pipm and vol<3000
shouldPlot73 = shouldPlot7 and vol>3000*dcur and h1-c1>0.0012*pipm
shouldPlot71 = shouldPlot7 and not shouldPlot72 and not shouldPlot73
shouldPlot81 = shouldPlot8 and vol<1500*dcur
shouldPlot83 = shouldPlot8 and vol>1500*dcur and ((o1-l1>(h1-l1)*0.5 and c1>o1) or (c1-l1>(h1-l1)*0.5 and o1>c1))
shouldPlot82 = shouldPlot8 and vol>1500*dcur and not shouldPlot83
shouldPlot91 = shouldPlot9 and vol<1500*dcur
shouldPlot93 = shouldPlot9 and vol>1500*dcur and ((h1-c1>(h1-l1)*0.5 and c1>o1) or (h1-o1>(h1-l1)*0.5 and o1>c1))
shouldPlot92 = shouldPlot9 and vol>1500*dcur and not shouldPlot93
shouldPlot101 = shouldPlot10 and vol<1500*dcur
shouldPlot103 = shouldPlot10 and vol>1500*dcur and ((o1-l1>(h1-l1)*0.5 and c1>o1) or (c1-l1>(h1-l1)*0.5 and o1>c1))
shouldPlot102 = shouldPlot10 and vol>1500*dcur and not shouldPlot103
shouldPlot111 = shouldPlot11 and vol<1500*dcur
shouldPlot113 = shouldPlot11 and vol>1500*dcur and ((h1-c1>(h1-l1)*0.5 and c1>o1) or (h1-o1>(h1-l1)*0.5 and o1>c1))
shouldPlot112 = shouldPlot11 and vol>1500*dcur and not shouldPlot113


//Sudden Lack of Volume
var bool lackvol1b = na
var bool lackvol2b = na
var bool lackvol3b = na
var bool lackvol1 = na
var bool lackvol2 = na
var bool lackvol3 = na

if lackvol_ok and bar_index>last_bar_index-lookback2
    lackvol1b := c1>o1 and ((vol[1]*0.80)>vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>3000*dcur and belowLine_r
    lackvol2b := c1>o1 and ((vol[1]*0.75)>vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>3000*dcur and belowLine_r
    lackvol3b := c1>o1 and ((vol[1]*0.67)>vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>3000*dcur and belowLine_r
    lackvol1 := o1>c1 and ((vol[1]*0.80)>vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>3000*dcur and belowLine_b
    lackvol2 := o1>c1 and ((vol[1]*0.75)>vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>3000*dcur and belowLine_b
    lackvol3 := o1>c1 and ((vol[1]*0.67)>vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>3000*dcur and belowLine_b
//Sudden Volume
var bool sudvol1b = na
var bool sudvol2b = na
var bool sudvol3b = na
var bool sudvol1 = na
var bool sudvol2 = na
var bool sudvol3 = na

if sudvol_ok and bar_index>last_bar_index-lookback2
    sudvol1b := c1>o1 and ((vol[1]*1.4)<vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>1000*dcur and belowLine_b
    sudvol2b := c1>o1 and ((vol[1]*1.7)<vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>1000*dcur and belowLine_b
    sudvol3b := c1>o1 and ((vol[1]*2.0)<vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>1000*dcur and belowLine_b
    sudvol1 := o1>c1 and ((vol[1]*1.4)<vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>1000*dcur and belowLine_r
    sudvol2 := o1>c1 and ((vol[1]*1.7)<vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>1000*dcur and belowLine_r
    sudvol3 := o1>c1 and ((vol[1]*2.0)<vol) and not ((time >= timestamp(year, month, dayofmonth, 12, 0))) and vol[1]>1000*dcur and belowLine_r
si_lo_ab = location.abovebar
si_lo_bb = location.belowbar


//Sudden interest
var bool sig1b = na
var bool sig1r = na
if sudIntr_ok and bar_index>last_bar_index-lookback2
    sig1b := (c1-o1)>atr*1.5 and belowLine_b 
    sig1r := (o1-c1)>atr*1.5 and belowLine_r

//News
var bool news = na
if news_ok and bar_index>last_bar_index-lookback2
    news := (vol>3000*dcur) and (h1-l1>0.0025*pipm) and (vol[1]<vol*0.5) and news_ok


//Volume Patterns
var bool cpt1b = na
var bool cpt2b = na
var bool cpt3b = na
var bool cpt4b = na
var bool cpt5b = na
var bool cpt1r = na
var bool cpt2r = na
var bool cpt3r = na
var bool cpt4r = na
var bool cpt5r = na

if candlepat_ok and bar_index>last_bar_index-lookback2
    cpt1b1 = vol[2]>1000*dcur and c3>o3
    cpt1b2 = vol[1]<vol[2]*cptper and c2<o2
    cpt1b3 = vol>vol[2] and c1>o1
    cpt1b := cpt1b1 and cpt1b2 and cpt1b3 and belowLine_b
    cpt1r1 = vol[2]>1000*dcur and c3<o3
    cpt1r2 = vol[1]<vol[2]*cptper and c2>o2
    cpt1r3 = vol>vol[2] and c1<o1
    cpt1r := cpt1r1 and cpt1r2 and cpt1r3 and belowLine_r
    cpt2b1 = vol[3]>1000*dcur and c4>o4
    cpt2b2 = vol[2]<vol[3]*cptper and c3<o3
    cpt2b3 = vol[1]<vol[3]*cptper and c2<o2
    cpt2b4 = vol>vol[3] and c1>o1
    cpt2b := cpt2b1 and cpt2b2 and cpt2b3 and cpt2b4 and belowLine_b
    cpt2r1 = vol[3]>1000*dcur and c4<o4
    cpt2r2 = vol[2]<vol[3]*cptper and c3>o3
    cpt2r3 = vol[1]<vol[3]*cptper and c2>o2
    cpt2r4 = vol>vol[3] and c1<o1
    cpt2r := cpt2r1 and cpt2r2 and cpt2r3 and cpt2r4 and belowLine_r
    cpt3b1 = vol[4]>1000*dcur and c5>o5
    cpt3b2 = vol[3]<vol[4]*cptper and c4<o4
    cpt3b3 = vol[2]<vol[4]*cptper and c3<o3
    cpt3b4 = vol[1]<vol[4]*cptper and c2<o2
    cpt3b5 = vol>vol[4] and c1>o1
    cpt3b := cpt3b1 and cpt3b2 and cpt3b3 and cpt3b4 and cpt3b5 and belowLine_b
    cpt3r1 = vol[4]>1000*dcur and c5<o5
    cpt3r2 = vol[3]<vol[4]*cptper and c4>o4
    cpt3r3 = vol[2]<vol[4]*cptper and c3>o3
    cpt3r4 = vol[1]<vol[4]*cptper and c2>o2
    cpt3r5 = vol>vol[4] and c1<o1
    cpt3r := cpt3r1 and cpt3r2 and cpt3r3 and cpt3r4 and cpt3r5 and belowLine_r
    cpt4b0 = vol[2]>vol[3]
    cpt4b1 = c3<o3 
    cpt4b2 = vol[1]>vol[2] and c2<o2
    cpt4b3 = vol>vol[1] and c1>o1
    cpt4b4 = (time >= timestamp(year, month, dayofmonth, 0, 30) and time <= timestamp(year, month, dayofmonth, 3, 15)) or (time >= timestamp(year, month, dayofmonth, 6, 0) and time <= timestamp(year, month, dayofmonth, 10, 15))
    cpt4b := cpt4b1 and cpt4b2 and cpt4b3 and cpt4b4 and cpt4b0 and belowLine_b
    cpt4r0 = vol[2]>vol[3]
    cpt4r1 = c3>o3 
    cpt4r2 = vol[1]>vol[2] and c2>o2
    cpt4r3 = vol>vol[1] and c1<o1
    cpt4r4 = (time >= timestamp(year, month, dayofmonth, 0, 30) and time <= timestamp(year, month, dayofmonth, 3, 15)) or (time >= timestamp(year, month, dayofmonth, 6, 0) and time <= timestamp(year, month, dayofmonth, 10, 15))
    cpt4r := cpt4r1 and cpt4r2 and cpt4r3 and cpt4r4 and cpt4r0 and belowLine_r
    cpt5b1 = c4<o4
    cpt5b2 = (vol[2]>vol[3]*1.34 or vol[2]>vol[1]*1.34)and c3>o3
    cpt5b3 = c2<o2
    cpt5b4 = (vol>vol[3]*1.34 or vol>vol[1]*1.34) and vol>vol[2] and c1>o1 and vol>1000*dcur and (vol[1]+vol[3]<vol+vol[2])
    cpt5b := cpt5b1 and cpt5b2 and cpt5b3 and cpt5b4 and belowLine_b
    cpt5r1 = c4>o4
    cpt5r2 = (vol[2]>vol[3]*1.34 or vol[2]>vol[1]*1.34) and c3<o3
    cpt5r3 = c2>o2
    cpt5r4 = (vol>vol[3]*1.34 or vol>vol[1]*1.34) and vol>vol[2] and c1<o1 and vol>1000*dcur and (vol[1]+vol[3]<vol+vol[2])
    cpt5r := cpt5r1 and cpt5r2 and cpt5r3 and cpt5r4 and belowLine_r
Editor is loading...