Dont share
user_6299896
plain_text
a year ago
60 kB
19
Indexable
Never
//@version=5 indicator("3 Phase", 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(false) and rightsymbol lookback2 = input(2000) intval = input(0) af_len = input(0) 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) boch_ok = input(false) or enableall length = input(5) rsidiv_ok = input(false) or enableall len2 = input(3) 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_r_w = 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 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 barsSincePattern6 = 0 shouldPlot6 := bounce_detected_w and (barsSincePattern6 >= intval or na(barsSincePattern6)) barsSincePattern6 := shouldPlot6 ? 0 : barsSincePattern6 + 1 var int barsSincePattern7 = 0 shouldPlot7 := bounce_detected_r_w and (barsSincePattern7 >= intval 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 >= intval or na(barsSincePattern8)) barsSincePattern8 := shouldPlot8 ? 0 : barsSincePattern8 + 1 var int barsSincePattern9 = 0 shouldPlot9 := bounce_det2 and (barsSincePattern9 >= intval 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 and bar_index>last_bar_index-lookback2 left_highest = ta.highest(vol[len+1], len) right_highest = ta.highest(vol, len) volhi = vol[len] > left_highest and vol[len] > right_highest left_highest_m1 = ta.highest(vol[len], len) right_highest_m1 = ta.highest(vol, len-1) volhi_m1 = vol[len-1] > left_highest_m1 and vol[len-1] > right_highest_m1 left_highest_m2 = ta.highest(vol[len-1], len) volhi_m2 = vol[len-2] > left_highest_m2 hi = high[len] == ta.pivothigh(len,len) lo = low[len] == ta.pivotlow(len,len) barr=900000 cond_b2 = lo and (volhi or volhi[1] or volhi_m1 or volhi_m2) cond_r2 = hi and (volhi or volhi[1] or volhi_m1 or volhi_m2) var int density2 = na if (last_bar_index-bar_index)>300 density2:=90 if (last_bar_index-bar_index)>200 and (last_bar_index-bar_index)<300 density2:=70 if (last_bar_index-bar_index)>100 and (last_bar_index-bar_index)<200 density2:=50 if (last_bar_index-bar_index)<100 density2:=30 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 array.push(boxes, bob) array.push(bbobsize_values, bbobsize_value) array.push(bobsize_values, bobsize_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) array.set(boxes, i, na) array.set(bbobsize_values, i, na) array.set(bobsize_values, i, na) if cond_r2 array.push(boxes_r, rob) array.push(robsize_values, robsize_value) array.push(rrobsize_values, rrobsize_value) 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) 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 >= intval or na(barsSincePattern10)) barsSincePattern10 := shouldPlot10 ? 0 : barsSincePattern10 + 1 var int barsSincePattern11 = 0 shouldPlot11 := bounce_det4 and (barsSincePattern11 >= intval or na(barsSincePattern11)) barsSincePattern11 := shouldPlot11 ? 0 : barsSincePattern11 + 1 shouldPlot63 = shouldPlot6 and vol>3000*dcur and c1-l1>0.0012*pipm shouldPlot62 = shouldPlot6 and vol>1500*dcur and c1-l1>0.0008*pipm and not shouldPlot63 shouldPlot61 = shouldPlot6 and (not shouldPlot63 and not shouldPlot62) shouldPlot73 = shouldPlot7 and vol>3000*dcur and h1-c1>0.0012*pipm shouldPlot72 = shouldPlot7 and vol>1500*dcur and h1-c1>0.0008*pipm and not shouldPlot73 shouldPlot71 = shouldPlot7 and (not shouldPlot73 and not shouldPlot72) 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 //Volume Differences var bool vob1s = na var bool vor1s = na var bool vob1m = na var bool vor1m = na var bool vob1w = na var bool vor1w = na if voldif_ok and bar_index>last_bar_index-lookback2 vo1b = c1>o1 ? vol : 0 vo1r = o1>c1 ? vol : 0 vo2b = c2>o2 ? vol[1] : 0 vo2r = o2>c2 ? vol[1] : 0 vo3b = c3>o3 ? vol[2] : 0 vo3r = o3>c3 ? vol[2] : 0 vo4b = c4>o4 ? vol[3] : 0 vo4r = o4>c4 ? vol[3] : 0 vo5b = c5>o5 ? vol[4] : 0 vo5r = o5>c5 ? vol[4] : 0 vo6b = c6>o6 ? vol[5] : 0 vo6r = o6>c6 ? vol[5] : 0 vo7b = close[6]>open[6] ? vol[6] : 0 vo7r = open[6]>close[6] ? vol[6] : 0 vo8b = close[7]>open[7] ? vol[7] : 0 vo8r = open[7]>close[7] ? vol[7] : 0 vo9b = close[8]>open[8] ? vol[8] : 0 vo9r = open[8]>close[8] ? vol[8] : 0 vo10b = close[9]>open[9] ? vol[9] : 0 vo10r = open[9]>close[9] ? vol[9] : 0 vo11b = close[10]>open[10] ? vol[10] : 0 vo11r = open[10]>close[10] ? vol[10] : 0 vo12b = close[11]>open[11] ? vol[11] : 0 vo12r = open[11]>close[11] ? vol[11] : 0 vo13b = close[12]>open[12] ? vol[12] : 0 vo13r = open[12]>close[12] ? vol[12] : 0 vo14b = close[13]>open[13] ? vol[13] : 0 vo14r = open[13]>close[13] ? vol[13] : 0 vobb = vo1b+vo2b+vo3b+vo4b+vo5b+vo6b+vo7b+vo8b+vo9b+vo10b+vo11b+vo12b+vo13b+vo14b vorr = vo1r+vo2r+vo3r+vo4r+vo5r+vo6r+vo7r+vo8r+vo9r+vo10r+vo11r+vo12r+vo13r+vo14r difb = (vorr-vobb) vob = vorr>vobb and voldif_ok and belowLine_b and ((difb+difb[1])*multp<(difb[2]+difb[3])) var int barsSincePattern2 = 0 vob1 = vob and (barsSincePattern2 >= 5 or na(barsSincePattern2)) barsSincePattern2 := vob1 ? 0 : barsSincePattern2 + 1 difr = (vobb-vorr) vor = vobb>vorr and voldif_ok and belowLine_r and ((difr+difr[1])*multp<(difr[2]+difr[3])) var int barsSincePattern3 = 0 vor1 = vor and (barsSincePattern3 >= 5 or na(barsSincePattern3)) barsSincePattern3 := vor1 ? 0 : barsSincePattern3 + 1 if vob1 and vol>2400*dcur vob1s:=true else vob1s:=false if vob1 and vol>900*dcur and vol<2400*dcur vob1m:=true else vob1m:=false if vob1 and vol<900*dcur vob1w:=true else vob1w:=false if vor1 and vol>2400*dcur vor1s:=true else vor1s:=false if vor1 and vol>900*dcur and vol<2400*dcur vor1m:=true else vor1m:=false if vor1 and vol<900*dcur vor1w:=true else vor1w:=false //Color candles var float dif2 = na if color_candles and bar_index>last_bar_index-lookback2 vo1b = c1>o1 ? vol : 0 vo1r = o1>c1 ? vol : 0 vo2b = c2>o2 ? vol[1] : 0 vo2r = o2>c2 ? vol[1] : 0 vo3b = c3>o3 ? vol[2] : 0 vo3r = o3>c3 ? vol[2] : 0 vo4b = c4>o4 ? vol[3] : 0 vo4r = o4>c4 ? vol[3] : 0 vo5b = c5>o5 ? vol[4] : 0 vo5r = o5>c5 ? vol[4] : 0 vo6b = c6>o6 ? vol[5] : 0 vo6r = o6>c6 ? vol[5] : 0 vo7b = close[6]>open[6] ? vol[6] : 0 vo7r = open[6]>close[6] ? vol[6] : 0 vo8b = close[7]>open[7] ? vol[7] : 0 vo8r = open[7]>close[7] ? vol[7] : 0 vo9b = close[8]>open[8] ? vol[8] : 0 vo9r = open[8]>close[8] ? vol[8] : 0 vo10b = close[9]>open[9] ? vol[9] : 0 vo10r = open[9]>close[9] ? vol[9] : 0 vo11b = close[10]>open[10] ? vol[10] : 0 vo11r = open[10]>close[10] ? vol[10] : 0 vo12b = close[11]>open[11] ? vol[11] : 0 vo12r = open[11]>close[11] ? vol[11] : 0 vo13b = close[12]>open[12] ? vol[12] : 0 vo13r = open[12]>close[12] ? vol[12] : 0 vo14b = close[13]>open[13] ? vol[13] : 0 vo14r = open[13]>close[13] ? vol[13] : 0 vobb1 = (vo1b+vo2b+vo3b+vo4b+vo5b+vo6b+vo7b+vo8b+vo9b+vo10b+vo11b+vo12b+vo13b+vo14b)/14 vorr1 = (vo1r+vo2r+vo3r+vo4r+vo5r+vo6r+vo7r+vo8r+vo9r+vo10r+vo11r+vo12r+vo13r+vo14r)/14 dif1 = vobb1-vorr1 dif2 := (dif1+dif1[1]+dif1[2]+dif1[3]+dif1[4]+dif1[5]+dif1[6])/7 //Candle Patterns var bool b61 = na var bool b62 = na var bool b63 = na var bool b64 = na var bool b65 = na var bool b66 = na var bool b51 = na var bool b52 = na var bool b53 = na var bool b54 = na var bool b55 = na var bool b41 = na var bool b42 = na var bool b43 = na var bool b44 = na var bool b31 = na var bool b32 = na var bool b21 = na var bool bhc = na var bool shouldPlot1 = na var bool r61 = na var bool r62 = na var bool r63 = na var bool r64 = na var bool r65 = na var bool r66 = na var bool r51 = na var bool r52 = na var bool r53 = na var bool r54 = na var bool r55 = na var bool r41 = na var bool r42 = na var bool r43 = na var bool r44 = na var bool r31 = na var bool r32 = na var bool r21 = na var bool rhc = na var bool shouldPlot = na if cp_ok and bar_index>last_bar_index-lookback2 tws3 = (c3>o3) and ((c3-o3)>bl*atr) tws2 = (c2>o2) and ((c2-o2)>bl*atr) and (c2>=h3) tws1 = (c1>o1) and ((c1-o1)>bl*atr) and (c1>=h2) tws = tws1 and tws2 and tws3 and tws_ok and volume_ok and belowLine_b var int barsSincePattern1 = 0 shouldPlot1 := tws and (barsSincePattern1 >= 5 or na(barsSincePattern1)) barsSincePattern1 := shouldPlot1 ? 0 : barsSincePattern1 + 1 tbs3 = (o3>c3) and ((o3-c3)>bl*atr) tbs2 = (o2>c2) and ((o2-c2)>bl*atr) and (c2<=l3) tbs1 = (o1>c1) and ((o1-c1)>bl*atr) and (c1<=l2) tbs = tbs1 and tbs2 and tbs3 and tbs_ok and volume_ok and belowLine_r var int barsSincePattern = 0 shouldPlot := tbs and (barsSincePattern >= 5 or na(barsSincePattern)) barsSincePattern := shouldPlot ? 0 : barsSincePattern + 1 bhc1 = ((c1>=o1) and ((h1-o1)<((h1-l1)*0.382))) or ((o1>c1) and ((h1-c1)<((h1-l1)*0.382)) and (((h1-o1)>=(o1-c1)) or ((h1-c1)<(h1-l1)*0.25))) and (h1-l1)>atr bhc := bhc1 and volume_ok and bhc_ok and belowLine_b rhc1 = ((o1>=c1) and ((o1-l1)<((h1-l1)*0.382))) or ((c1>o1) and ((c1-l1)<((h1-l1)*0.382)) and (((o1-l1)>=(c1-o1)) or ((c1-l1)<(h1-l1)*0.25))) and (h1-l1)>atr rhc := rhc1 and volume_ok and rhc_ok and belowLine_r b616 = (o6>c6) b615 = (o5>c5) b614 = ((o6-c6)>(mcs*atr)and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o5-c5)>(mcs*atr)and((o4-c4)>(bl*atr))and((o6-c6)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o5-c5)>(bl*atr))and((o6-c6)>(bl*atr))) b613 = ((c3-o3)>(bl*atr)) b612 = ((c2-o2)>(bl*atr)) b611 = (c1>o6-(o6-c6)*pmval)and(((c1-o1)>(c2-o2))or((c1-o1)>(c3-o3))) b61 := b616 and b615 and b614 and b613 and b612 and b611 and volume_ok and b61_ok and belowLine_b r616 = (c6>o6) r615 = (c5>o5) r614 = ((c6-o6)>(mcs*atr)and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c5-o5)>(mcs*atr)and((c4-o4)>(bl*atr))and((c6-o6)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c5-o5)>(bl*atr))and((c6-o6)>(bl*atr))) r613 = ((o3-c3)>(bl*atr)) r612 = ((o2-c2)>(bl*atr)) r611 = (c1<o6+(c6-o6)*pmval)and(((o1-c1)>(o2-c2))or((o1-c1)>(o3-c3))) r61 := r616 and r615 and r614 and r613 and r612 and r611 and volume_ok and r61_ok and belowLine_r b626 = (o6>c6) b625 = (((o6-c6)>(mcs*atr))and((o5-c5)>(bl*atr))) or (((o5-c5)>(mcs*atr))and((o6-c6)>(bl*atr))) b624 = (((c4-o4)<(bl*atr))and((c4-o4)>(0)))or(((o4-c4)<(bl*atr))and((o4-c4)>(0))) b623 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) b622 = ((c2-o2)>(bl*atr)) b621 = (c1>o6-(o6-c6)*pmval)and(((c1-o1)>(c2-o2))) b62 := b626 and b625 and b624 and b623 and b622 and b621 and volume_ok and b62_ok and belowLine_b r626 = (c6>o6) r625 = (((c6-o6)>(mcs*atr))and((c5-o5)>(bl*atr))) or (((c5-o5)>(mcs*atr))and((c6-o6)>(bl*atr))) r624 = (((c4-o4)<(bl*atr))and((c4-o4)>(0)))or(((o4-c4)<(bl*atr))and((o4-c4)>(0))) r623 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) r622 = ((o2-c2)>(bl*atr)) r621 = (c1<o6+(c6-o6)*pmval)and(((o1-c1)>(o2-c2))) r62 := r626 and r625 and r624 and r623 and r622 and r621 and volume_ok and r62_ok and belowLine_r b636 = (o6>c6) b635 = (o5>c5) b634 = ((o6-c6)>(mcs*atr)and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o5-c5)>(mcs*atr)and((o4-c4)>(bl*atr))and((o6-c6)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o5-c5)>(bl*atr))and((o6-c6)>(bl*atr))) b633 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) b632 = ((c2-o2)>(bl*atr)) b631 = (c1>o6-(o6-c6)*pmval)and(((c1-o1)>(c2-o2))) b63 := b636 and b635 and b634 and b633 and b632 and b631 and volume_ok and b63_ok and belowLine_b r636 = (c6>o6) r635 = (c5>o5) r634 = ((c6-o6)>(mcs*atr)and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c5-o5)>(mcs*atr)and((c4-o4)>(bl*atr))and((c6-o6)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c5-o5)>(bl*atr))and((c6-o6)>(bl*atr))) r633 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) r632 = ((o2-c2)>(bl*atr)) r631 = (c1<o6+(c6-o6)*pmval)and(((o1-c1)>(o2-c2))) r63 := r636 and r635 and r634 and r633 and r632 and r631 and volume_ok and r63_ok and belowLine_r b646 = (o6>c6) b645 = (o5>c5) b644 = (o4>c4) b643 = ((o6-c6)>(mcs*atr)and((o3-c3)>(bl*atr))and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o5-c5)>(mcs*atr)and((o3-c3)>(bl*atr))and((o4-c4)>(bl*atr))and((o6-c6)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o3-c3)>(bl*atr))and((o6-c6)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o3-c3)>(mcs*atr)and((o6-c6)>(bl*atr))and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) b642 = ((c2-o2)>(bl*atr)) b641 = (c1>o6-(o6-c6)*pmval)and(((c1-o1)>(c2-o2))) b64 := b646 and b645 and b644 and b643 and b642 and b641 and volume_ok and b64_ok and belowLine_b r646 = (c6>o6) r645 = (c5>o5) r644 = (c4>o4) r643 = ((c6-o6)>(mcs*atr)and((c3-o3)>(bl*atr))and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c5-o5)>(mcs*atr)and((c3-o3)>(bl*atr))and((c4-o4)>(bl*atr))and((c6-o6)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c3-o3)>(bl*atr))and((c6-o6)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c3-o3)>(mcs*atr)and((c6-o6)>(bl*atr))and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) r642 = ((o2-c2)>(bl*atr)) r641 = (c1<o6+(c6-o6)*pmval)and(((o1-c1)>(o2-c2))) r64 := r646 and r645 and r644 and r643 and r642 and r641 and volume_ok and r64_ok and belowLine_r b656 = (o6>c6) b655 = (o5>c5) b654 = ((o6-c6)>(mcs*atr)and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o5-c5)>(mcs*atr)and((o4-c4)>(bl*atr))and((o6-c6)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o5-c5)>(bl*atr))and((o6-c6)>(bl*atr))) b653 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) b652 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) b651 = (c1>o6-(o6-c6)*pmval) b65 := b656 and b655 and b654 and b653 and b652 and b651 and volume_ok and b65_ok and belowLine_b r656 = (c6>o6) r655 = (c5>o5) r654 = ((c6-o6)>(mcs*atr)and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c5-o5)>(mcs*atr)and((c4-o4)>(bl*atr))and((c6-o6)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c5-o5)>(bl*atr))and((c6-o6)>(bl*atr))) r653 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) r652 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) r651 = (c1<o6+(c6-o6)*pmval) r65 := r656 and r655 and r654 and r653 and r652 and r651 and volume_ok and r65_ok and belowLine_r b666 = (o6>c6) b665 = (o5>c5) b664 = (o4>c4) b663 = ((o6-c6)>(mcs*atr)and((o3-c3)>(bl*atr))and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o5-c5)>(mcs*atr)and((o3-c3)>(bl*atr))and((o4-c4)>(bl*atr))and((o6-c6)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o3-c3)>(bl*atr))and((o6-c6)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o3-c3)>(mcs*atr)and((o6-c6)>(bl*atr))and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) b662 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) b661 = (c1>o6-(o6-c6)*pmval) b66 := b666 and b665 and b664 and b663 and b662 and b661 and volume_ok and b66_ok and belowLine_b r666 = (c6>o6) r665 = (c5>o5) r664 = (c4>o4) r663 = ((c6-o6)>(mcs*atr)and((c3-o3)>(bl*atr))and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c5-o5)>(mcs*atr)and((c3-o3)>(bl*atr))and((c4-o4)>(bl*atr))and((c6-o6)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c3-o3)>(bl*atr))and((c6-o6)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c3-o3)>(mcs*atr)and((c6-o6)>(bl*atr))and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) r662 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) r661 = (c1<o6+(c6-o6)*pmval) r66 := r666 and r665 and r664 and r663 and r662 and r661 and volume_ok and r66_ok and belowLine_r b515 = (o5>c5) b514 = (o4>c4) b513 = ((o5-c5)>(mcs*atr)and((o4-c4)>(bl*atr))and((o3-c3)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o3-c3)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o3-c3)>(mcs*atr)and((o5-c5)>(bl*atr))and((o4-c4)>(bl*atr))) b512 = ((c2-o2)>(bl*atr)) b511 = (c1>o5-(o5-c5)*pmval)and((c1-o1)>(c2-o2)) b51 := b515 and b514 and b513 and b512 and b511 and volume_ok and b51_ok and belowLine_b r515 = (c5>o5) r514 = (c4>o4) r513 = ((c5-o5)>(mcs*atr)and((c4-o4)>(bl*atr))and((c3-o3)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c3-o3)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c3-o3)>(mcs*atr)and((c5-o5)>(bl*atr))and((c4-o4)>(bl*atr))) r512 = ((o2-c2)>(bl*atr)) r511 = (c1<o5+(c5-o5)*pmval)and((o1-c1)>(o2-c2)) r51 := r515 and r514 and r513 and r512 and r511 and volume_ok and r51_ok and belowLine_r b525 = (o5>c5) b524 = (((o5-c5)>(mcs*atr))and((o4-c4)>(bl*atr))) or (((o4-c4)>(mcs*atr))and((o5-c5)>(bl*atr))) b523 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) b522 = ((c2-o2)>(bl*atr)) b521 = (c1>o5-(o5-c5)*pmval)and((c1-o1)>(c2-o2)) b52 := b525 and b524 and b523 and b522 and b521 and volume_ok and b52_ok and belowLine_b r525 = (c5>o5) r524 = (((c4-o4)>(mcs*atr))and((c5-o5)>(bl*atr))) or (((c4-o4)>(mcs*atr))and((c5-o5)>(bl*atr))) r523 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) r522 = ((o2-c2)>(bl*atr)) r521 = (c1<o5+(c5-o5)*pmval)and(((o1-c1)>(o2-c2))) r52 := r525 and r524 and r523 and r522 and r521 and volume_ok and r52_ok and belowLine_r b535 = (o5>c5) b534 = (((o5-c5)>(mcs*atr))and((o4-c4)>(bl*atr))) or (((o4-c4)>(mcs*atr))and((o5-c5)>(bl*atr))) b533 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) b532 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) b531 = (c1>o5-(o5-c5)*pmval) b53 := b535 and b534 and b533 and b532 and b531 and volume_ok and b53_ok and belowLine_b r535 = (c5>o5) r534 = (((c4-o4)>(mcs*atr))and((c5-o5)>(bl*atr))) or (((c5-o5)>(mcs*atr))and((c4-o4)>(bl*atr))) r533 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) r532 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) r531 = (c1<o5+(c5-o5)*pmval) r53 := r535 and r534 and r533 and r532 and r531 and volume_ok and r53_ok and belowLine_r b545 = (o5>c5) b544 = (o4>c4) b543 = ((o5-c5)>(mcs*atr)and((o4-c4)>(bl*atr))and((o3-c3)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o3-c3)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o3-c3)>(mcs*atr)and((o5-c5)>(bl*atr))and((o4-c4)>(bl*atr))) b542 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) b541 = (c1>o5-(o5-c5)*pmval) b54 := b545 and b544 and b543 and b542 and b541 and volume_ok and b54_ok and belowLine_b r545 = (c5>o5) r544 = (c4>o4) r543 = ((c5-o5)>(mcs*atr)and((c4-o4)>(bl*atr))and((c3-o3)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c3-o3)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c3-o3)>(mcs*atr)and((c5-o5)>(bl*atr))and((c4-o4)>(bl*atr))) r542 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) r541 = (c1<o5+(c5-o5)*pmval) r54 := r545 and r544 and r543 and r542 and r541 and volume_ok and r54_ok and belowLine_r b555 = (o5>c5) b554 = (o4>c4) b553 = (o3>c3) b552 = ((o2-c2)>(mcs*atr)and((o3-c3)>(bl*atr))and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o5-c5)>(mcs*atr)and((o3-c3)>(bl*atr))and((o4-c4)>(bl*atr))and((o2-c2)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o3-c3)>(bl*atr))and((o2-c2)>(bl*atr))and((o5-c5)>(bl*atr))) or ((o3-c3)>(mcs*atr)and((o2-c2)>(bl*atr))and((o4-c4)>(bl*atr))and((o5-c5)>(bl*atr))) b551 = (c1>o5-(o5-c5)*pmval) b55 := b555 and b554 and b553 and b552 and b551 and volume_ok and b55_ok and belowLine_b r555 = (c5>o5) r554 = (c4>o4) r553 = (c3>o3) r552 = ((c2-o2)>(mcs*atr)and((c3-o3)>(bl*atr))and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c5-o5)>(mcs*atr)and((c3-o3)>(bl*atr))and((c4-o4)>(bl*atr))and((c2-o2)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c3-o3)>(bl*atr))and((c2-o2)>(bl*atr))and((c5-o5)>(bl*atr))) or ((c3-o3)>(mcs*atr)and((c2-o2)>(bl*atr))and((c4-o4)>(bl*atr))and((c5-o5)>(bl*atr))) r551 = (c1<o5+(c5-o5)*pmval) r55 := r555 and r554 and r553 and r552 and r551 and volume_ok and r55_ok and belowLine_r b414 = (o4>c4) b413 = (((o3-c3)>(mcs*atr))and((o4-c4)>(bl*atr))) or (((o4-c4)>(mcs*atr))and((o3-c3)>(bl*atr))) b412 = ((c2-o2)>(bl*atr)) b411 = (c1>o4-(o4-c4)*pmval)and((c1-o1)>(c2-o2)) b41 := b414 and b413 and b412 and b411 and volume_ok and b41_ok and belowLine_b r414 = (c4>o4) r413 = (((c4-o4)>(mcs*atr))and((c3-o3)>(bl*atr))) or (((c4-o4)>(mcs*atr))and((c3-o3)>(bl*atr))) r412 = ((o2-c2)>(bl*atr)) r411 = (c1<o4+(c4-o4)*pmval)and((o1-c1)>(o2-c2)) r41 := r414 and r413 and r412 and r411 and volume_ok and r41_ok and belowLine_r b424 = ((o4-c4)>(mcs*atr)) b423 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) b422 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) b421 = (c1>o4-(o4-c4)*pmval) b42 := b424 and b423 and b422 and b421 and volume_ok and b42_ok and belowLine_b r424 = ((c4-o4)>(mcs*atr)) r423 = (((c3-o3)<(bl*atr))and((c3-o3)>(0)))or(((o3-c3)<(bl*atr))and((o3-c3)>(0))) r422 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) r421 = (c1<o4+(c4-o4)*pmval) r42 := r424 and r423 and r422 and r421 and volume_ok and r42_ok and belowLine_r b434 = (o4>c4) b433 = (((o3-c3)>(mcs*atr))and((o4-c4)>(bl*atr))) or (((o4-c4)>(mcs*atr))and((o3-c3)>(bl*atr))) b432 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) b431 = (c1>o4-(o4-c4)*pmval) b43 := b434 and b433 and b432 and b431 and volume_ok and b43_ok and belowLine_b r434 = (c4>o4) r433 = (((c4-o4)>(mcs*atr))and((c3-o3)>(bl*atr))) or (((c4-o4)>(mcs*atr))and((c3-o3)>(bl*atr))) r432 = (((c2-o2)<(bl*atr))and((c2-o2)>(0)))or(((o2-c2)<(bl*atr))and((o2-c2)>(0))) r431 = (c1<o4+(c4-o4)*pmval) r43 := r434 and r433 and r432 and r431 and volume_ok and r43_ok and belowLine_r b444 = (o4>c4) b443 = (o3>c3) b442 = ((o2-c2)>(mcs*atr)and((o4-c4)>(bl*atr))and((o3-c3)>(bl*atr))) or ((o3-c3)>(mcs*atr)and((o4-c4)>(bl*atr))and((o2-c2)>(bl*atr))) or ((o4-c4)>(mcs*atr)and((o3-c3)>(bl*atr))and((o2-c2)>(bl*atr))) b441 = (c1>o4-(o4-c4)*pmval) b44 := b444 and b443 and b442 and b441 and volume_ok and b44_ok and belowLine_b r444 = (c4>o4) r443 = (c3>o3) r442 = ((c2-o2)>(mcs*atr)and((c4-o4)>(bl*atr))and((c3-o3)>(bl*atr))) or ((c3-o3)>(mcs*atr)and((c4-o4)>(bl*atr))and((c2-o2)>(bl*atr))) or ((c4-o4)>(mcs*atr)and((c3-o3)>(bl*atr))and((c2-o2)>(bl*atr))) r441 = (c1<o4+(c4-o4)*pmval) r44 := r444 and r443 and r442 and r441 and volume_ok and r44_ok and belowLine_r b313 = (o3>c3) b312 = (((o3-c3)>(mcs*atr))and((o2-c2)>(bl*atr))) or (((o2-c2)>(mcs*atr))and((o3-c3)>(bl*atr))) b311 = (c1>o3-(o3-c3)*pmval) b31 := b313 and b312 and b311 and volume_ok and b31_ok and belowLine_b r313 = (c3>o3) r312 = (((c3-o3)>(mcs*atr))and((c2-o2)>(bl*atr))) or (((c2-o2)>(mcs*atr))and((c3-o3)>(bl*atr))) r311 = (c1<o3+(c3-o3)*pmval) r31 := r313 and r312 and r311 and volume_ok and r31_ok and belowLine_r b323 = ((o3-c3)>(mcs*atr)) b322 = ((o2>c2)and((o2-c2)<(bl*atr))) or ((c2>o2)and((c2-o2)<(bl*atr))) b321 = (c1>o3-(o3-c3)*pmval) b32 := b323 and b322 and b321 and volume_ok and b32_ok and belowLine_b r323 = ((c3-o3)>(mcs*atr)) r322 = ((c2>o2)and((c2-o2)<(bl*atr))) or ((c2<o2)and((o2-c2)<(bl*atr))) r321 = (c1<o3+(c3-o3)*pmval) r32 := r323 and r322 and r321 and volume_ok and r32_ok and belowLine_r b212 = ((o2-c2)>atr) and (((h2-o2)<((o2-c2)/2))or((h2-o2)<((c2-l2)/2))) b211 = (c1>o2-(o2-c2)*pmval) and (((h1-c1)<((c1-o1)/2))or((h1-c1)<((o1-l1)/2))) b21 := b212 and b211 and volume_ok and b21_ok and belowLine_b r212 = ((c2-o2)>atr) and (((o2-l2)<((c2-o2)/2))or((o2-l2)<((h2-c2)/2))) r211 = (c1<o2+(c2-o2)*pmval) and (((c1-l1)<((o1-c1)/2))or((c1-l1)<((h1-o1)/2))) r21 := r212 and r211 and volume_ok and r21_ok and belowLine_r //BOS and CHOCH var bool plott_b = false var bool plott_r = false var bool plott_bb = false var bool plott_rr = false //Endings plott_b := false plott_r := false plott_bb := false plott_rr := false //Types type fractal float value int loc bool iscrossed //Fractal Detection if boch_ok and bar_index>last_bar_index-lookback2 var p = int(length/2) n = bar_index dh = math.sum(math.sign(high - high[1]), p) dl = math.sum(math.sign(low - low[1]), p) bullf = dh == -p and dh[p] == p and high[p] == ta.highest(length) bearf = dl == p and dl[p] == -p and low[p] == ta.lowest(length) bullf_count = ta.cum(bullf ? 1 : 0) bearf_count = ta.cum(bearf ? 1 : 0) //Bullish market structure var upper = fractal.new() var line lower_lvl = na var label ms_lbl = na var bull_ms_count = 0 var broken_sup = false var os = 0 if bullf upper.value := high[p] upper.loc := n-p upper.iscrossed := false if ta.crossover(close, upper.value) and not upper.iscrossed and belowLine_b if os == 1 plott_b := true else plott_bb := true //Set support k = 2 min = low[1] for i = 2 to (n - upper.loc)-1 min := math.min(low[i], min) k := low[i] == min ? i : k upper.iscrossed := true bull_ms_count += 1 os := 1 //Bearish market structure var lower = fractal.new() var line upper_lvl = na var broken_res = false var bear_ms_count = 0 if bearf lower.value := low[p] lower.loc := n-p lower.iscrossed := false if ta.crossunder(close, lower.value) and not lower.iscrossed and belowLine_r if os == 1 plott_rr := true else plott_r := true //Set resistance k = 2 max = high[1] for i = 2 to (n - lower.loc)-1 max := math.max(high[i], max) k := high[i] == max ? i : k lower.iscrossed := true bear_ms_count += 1 os := -1 ///RSI Divergence var bool beardiv_hi = na var bool bulldiv_hi = na var bool beardiv_lo = na var bool bulldiv_lo = na if rsidiv_ok and bar_index>last_bar_index-lookback2 rsi = ta.rsi(close, 14) pivothigh = ta.pivothigh(len2,len2) pivotlow = ta.pivotlow(len2,len2) hi = high[len2] == pivothigh lo = low[len2] == pivotlow var int needind_hi = na for i = 1 to 100 if not na(pivothigh[i]) needind_hi := i break rsiphi1 = (rsi[needind_hi+len2] < rsi[needind_hi+len2 + 1]) and (rsi[needind_hi+len2 - 1] < rsi[needind_hi+len2 + 1]) ? rsi[needind_hi+len2 + 1] : ((rsi[needind_hi+len2] < rsi[needind_hi+len2 - 1]) and (rsi[needind_hi+len2 + 1] < rsi[needind_hi+len2 - 1]) ? rsi[needind_hi+len2 - 1] : rsi[needind_hi+len2]) rsiphi2 = (rsi[len2] < rsi[len2 + 1]) and (rsi[len2 - 1] < rsi[len2 + 1]) ? rsi[len2 + 1] : ((rsi[len2] < rsi[len2 - 1]) and (rsi[len2 + 1] < rsi[len2 - 1]) ? rsi[len2 - 1] : rsi[len2]) beardiv_hi := ((high[needind_hi+len2] < high[len2]) and hi) and rsiphi1 > rsiphi2 bulldiv_hi := ((high[needind_hi+len2] > high[len2]) and hi) and rsiphi1 < rsiphi2 var int needind_lo = na for i = 1 to 100 if not na(pivotlow[i]) needind_lo := i break rsilo1 = (rsi[needind_lo+len2] > rsi[needind_lo+len2 + 1]) and (rsi[needind_lo+len2 - 1] > rsi[needind_lo+len2 + 1]) ? rsi[needind_lo+len2 + 1] : ((rsi[needind_lo+len2] > rsi[needind_lo+len2 - 1]) and (rsi[needind_lo+len2 + 1] > rsi[needind_lo+len2 - 1]) ? rsi[needind_lo+len2 - 1] : rsi[needind_lo+len2]) rsilo2 = (rsi[len2] > rsi[len2 + 1]) and (rsi[len2 - 1] > rsi[len2 + 1]) ? rsi[len2 + 1] : ((rsi[len2] > rsi[len2 - 1]) and (rsi[len2 + 1] > rsi[len2 - 1]) ? rsi[len2 - 1] : rsi[len2]) beardiv_lo := ((low[needind_lo+len2] < low[len2]) and lo) and rsilo1 > rsilo2 bulldiv_lo := ((low[needind_lo+len2] > low[len2]) and lo) and rsilo1 < rsilo2 var float wt1 = 0 var float wt2 = 0 var float wt3 = 0 var float wt4 = 0 var float wt51 = 0 var float wt61 = 0 var float wt71 = 0 var float wt81 = 0 var float wt52 = 0 var float wt62 = 0 var float wt72 = 0 var float wt82 = 0 var float wt53 = 0 var float wt63 = 0 var float wt73 = 0 var float wt83 = 0 var float wt9 = 0 var float wt10 = 0 var float wt11 = 0 var float wt12 = 0 var float wt131 = 0 var float wt141 = 0 var float wt132 = 0 var float wt142 = 0 var float wt133 = 0 var float wt143 = 0 var float wt15 = 0 var float wt16 = 0 var float wt17 = 0 var float wt18 = 0 var float wt19 = 0 var float wt20 = 0 var float wt21 = 0 var float wt22 = 0 var float wt231 = 0 var float wt241 = 0 var float wt251 = 0 var float wt261 = 0 var float wt232 = 0 var float wt242 = 0 var float wt252 = 0 var float wt262 = 0 var float wt233 = 0 var float wt243 = 0 var float wt253 = 0 var float wt263 = 0 var float wt271 = 0 var float wt272 = 0 var float wt273 = 0 var float wt281 = 0 var float wt282 = 0 var float wt283 = 0 var float wt291 = 0 var float wt301 = 0 var float wt292 = 0 var float wt302 = 0 var float wt311 = 0 var float wt321 = 0 var float wt312 = 0 var float wt322 = 0 volris_wt = 1.0 volfal_wt = 0.5 intr_wt = 0.6 sudv1_wt = 0.5 sudv2_wt = 0.6 sudv3_wt = 0.7 lacv1_wt = 0.5 lacv2_wt = 0.6 lacv3_wt = 0.7 volpat_wt = 0.7 voldif1_wt = 0.8 voldif2_wt = 0.9 voldif3_wt = 1.0 cancol_wt = 0.5 hc_wt = 0.5 bws_wt = 0.6 cp_wt = 0.7 kld1_wt = 0.5 kld2_wt = 0.6 kld3_wt = 0.7 fvgdet1_wt = 0.6 fvgdet2_wt = 0.7 fvgdet3_wt = 0.8 obdet1_wt = 0.6 obdet2_wt = 0.7 obdet3_wt = 0.8 boch1_wt = 0.6 boch2_wt = 0.7 rsidiv_wt = 1.0 if green[0] or green[1] or green[2] wt1 := volris_wt else wt1 := 0 if red[0] or red[1] or red[2] wt2 := 0-volris_wt else wt2 := 0 if greenr[0] or greenr[1] or greenr[2] wt3 := volfal_wt else wt3 := 0 if redr[0] or redr[1] or redr[2] wt4 := 0-volfal_wt else wt4 := 0 if (lackvol1)[0] or (lackvol1)[1] or (lackvol1)[2] wt51 := lacv1_wt else wt51 := 0 if (lackvol1b)[0] or (lackvol1b)[1] or (lackvol1b)[2] wt61 := 0-lacv1_wt else wt61 := 0 if (sudvol1b)[0] or (sudvol1b)[1] or (sudvol1b)[2] wt71 := sudv1_wt else wt71 := 0 if (sudvol1)[0] or (sudvol1)[1] or (sudvol1)[2] wt81 := 0-sudv1_wt else wt81 := 0 if (lackvol2)[0] or (lackvol2)[1] or (lackvol2)[2] wt52 := lacv2_wt else wt52 := 0 if (lackvol2b)[0] or (lackvol2b)[1] or (lackvol2b)[2] wt62 := 0-lacv2_wt else wt62 := 0 if (sudvol2b)[0] or (sudvol2b)[1] or (sudvol2b)[2] wt72 := sudv2_wt else wt72 := 0 if (sudvol2)[0] or (sudvol2)[1] or (sudvol2)[2] wt82 := 0-sudv2_wt else wt82 := 0 if (lackvol3)[0] or (lackvol3)[1] or (lackvol3)[2] wt53 := lacv3_wt else wt53 := 0 if (lackvol3b)[0] or (lackvol3b)[1] or (lackvol3b)[2] wt63 := 0-lacv3_wt else wt63 := 0 if (sudvol3b)[0] or (sudvol3b)[1] or (sudvol3b)[2] wt73 := sudv3_wt else wt73 := 0 if (sudvol3)[0] or (sudvol3)[1] or (sudvol3)[2] wt83 := 0-sudv3_wt else wt83 := 0 if sig1b[0] or sig1b[1] or sig1b[2] wt9 := intr_wt else wt9 := 0 if sig1r[0] or sig1r[1] or sig1r[2] wt10 := 0-intr_wt else wt10 := 0 if (cpt1b or cpt2b or cpt3b or cpt4b or cpt5b)[0] or (cpt1b or cpt2b or cpt3b or cpt4b or cpt5b)[1] or (cpt1b or cpt2b or cpt3b or cpt4b or cpt5b)[2] wt11 := volpat_wt else wt11 := 0 if (cpt1r or cpt2r or cpt3r or cpt4r or cpt5r)[0] or (cpt1r or cpt2r or cpt3r or cpt4r or cpt5r)[1] or (cpt1r or cpt2r or cpt3r or cpt4r or cpt5r)[2] wt12 := 0-volpat_wt else wt12 := 0 if (vob1s)[0] or (vob1s)[1] or (vob1s)[2] wt131 := voldif3_wt else wt131 := 0 if (vor1s)[0] or (vor1s)[1] or (vor1s)[2] wt141 := 0-voldif3_wt else wt141 := 0 if (vob1m)[0] or (vob1m)[1] or (vob1m)[2] wt132 := voldif2_wt else wt132 := 0 if (vor1m)[0] or (vor1m)[1] or (vor1m)[2] wt142 := 0-voldif2_wt else wt142 := 0 if (vob1w)[0] or (vob1w)[1] or (vob1w)[2] wt133 := voldif1_wt else wt133 := 0 if (vor1w)[0] or (vor1w)[1] or (vor1w)[2] wt143 := 0-voldif1_wt else wt143 := 0 if (dif2>dif2[1] and dif2<0)[0] or (dif2>dif2[1] and dif2<0)[1] or (dif2>dif2[1] and dif2<0)[2] wt15 := cancol_wt else wt15 := 0 if (dif2<dif2[1] and dif2>0)[0] or (dif2<dif2[1] and dif2>0)[1] or (dif2<dif2[1] and dif2>0)[2] wt16 := 0-cancol_wt else wt16 := 0 if (b61 or b62 or b63 or b64 or b65 or b66 or b51 or b52 or b53 or b54 or b55 or b41 or b42 or b43 or b44 or b31 or b32 or b21)[0] or (b61 or b62 or b63 or b64 or b65 or b66 or b51 or b52 or b53 or b54 or b55 or b41 or b42 or b43 or b44 or b31 or b32 or b21)[1] or (b61 or b62 or b63 or b64 or b65 or b66 or b51 or b52 or b53 or b54 or b55 or b41 or b42 or b43 or b44 or b31 or b32 or b21)[2] wt17 := cp_wt else wt17 := 0 if (r61 or r62 or r63 or r64 or r65 or r66 or r51 or r52 or r53 or r54 or r55 or r41 or r42 or r43 or r44 or r31 or r32 or r21)[0] or (r61 or r62 or r63 or r64 or r65 or r66 or r51 or r52 or r53 or r54 or r55 or r41 or r42 or r43 or r44 or r31 or r32 or r21)[1] or (r61 or r62 or r63 or r64 or r65 or r66 or r51 or r52 or r53 or r54 or r55 or r41 or r42 or r43 or r44 or r31 or r32 or r21)[2] wt18 := 0-cp_wt else wt18 := 0 if bhc[0] or bhc[1] or bhc[2] wt19 := hc_wt else wt19 := 0 if rhc[0] or rhc[1] or rhc[2] wt20 := 0-hc_wt else wt20 := 0 if shouldPlot1[0] or shouldPlot1[1] or shouldPlot1[2] wt21 := bws_wt else wt21 := 0 if shouldPlot[0] or shouldPlot[1] or shouldPlot[2] wt22 := 0-bws_wt else wt22 := 0 var bool buhi = na var int barsSincePattern88 = 0 barsSincePattern88 := bulldiv_hi ? 0 : barsSincePattern88 + 1 buhi := barsSincePattern88 <= af_len or na(barsSincePattern88) if buhi wt311 := rsidiv_wt else wt311 := 0 var bool brhi = na var int barsSincePattern77 = 0 barsSincePattern77 := beardiv_hi ? 0 : barsSincePattern77 + 1 brhi := barsSincePattern77 <= af_len or na(barsSincePattern77) if brhi wt312 := 0-rsidiv_wt else wt312 := 0 var bool bulo = na var int barsSincePattern99 = 0 barsSincePattern99 := bulldiv_lo ? 0 : barsSincePattern99 + 1 bulo := barsSincePattern99 <= af_len or na(barsSincePattern99) if bulo wt321 := rsidiv_wt else wt321 := 0 var bool brlo = na var int barsSincePattern66 = 0 barsSincePattern66 := beardiv_lo ? 0 : barsSincePattern66 + 1 brlo := barsSincePattern66 <= af_len or na(barsSincePattern66) if brlo wt322 := 0-rsidiv_wt else wt322 := 0 var bool sp61 = na var int barsSincePattern61 = 0 barsSincePattern61 := shouldPlot61 ? 0 : barsSincePattern61 + 1 sp61 := barsSincePattern61 <= af_len or na(barsSincePattern61) if sp61 wt231 := kld1_wt else wt231 := 0 var bool sp71 = na var int barsSincePattern71 = 0 barsSincePattern71 := shouldPlot71 ? 0 : barsSincePattern71 + 1 sp71 := barsSincePattern71 <= af_len or na(barsSincePattern71) if sp71 wt241 := 0-kld1_wt else wt241 := 0 var bool sp62 = na var int barsSincePattern62 = 0 barsSincePattern62 := shouldPlot62 ? 0 : barsSincePattern62 + 1 sp62 := barsSincePattern62 <= af_len or na(barsSincePattern62) if sp62 wt232 := kld2_wt else wt232 := 0 var bool sp72 = na var int barsSincePattern72 = 0 barsSincePattern72 := shouldPlot72 ? 0 : barsSincePattern72 + 1 sp72 := barsSincePattern72 <= af_len or na(barsSincePattern72) if sp72 wt242 := 0-kld2_wt else wt242 := 0 var bool sp63 = na var int barsSincePattern63 = 0 barsSincePattern63 := shouldPlot63 ? 0 : barsSincePattern63 + 1 sp63 := barsSincePattern63 <= af_len or na(barsSincePattern63) if sp63 wt233 := kld3_wt else wt233 := 0 var bool sp73 = na var int barsSincePattern73 = 0 barsSincePattern73 := shouldPlot73 ? 0 : barsSincePattern73 + 1 sp73 := barsSincePattern73 <= af_len or na(barsSincePattern73) if sp73 wt243 := 0-kld3_wt else wt243 := 0 var bool sp81 = na var int barsSincePattern81 = 0 barsSincePattern81 := shouldPlot81 ? 0 : barsSincePattern81 + 1 sp81 := barsSincePattern81 <= af_len or na(barsSincePattern81) if sp81 wt251 := fvgdet1_wt else wt251 := 0 var bool sp91 = na var int barsSincePattern91 = 0 barsSincePattern91 := shouldPlot91 ? 0 : barsSincePattern91 + 1 sp91 := barsSincePattern91 <= af_len or na(barsSincePattern91) if sp91 wt261 := 0-fvgdet1_wt else wt261 := 0 var bool sp82 = na var int barsSincePattern82 = 0 barsSincePattern82 := shouldPlot82 ? 0 : barsSincePattern82 + 1 sp82 := barsSincePattern82 <= af_len or na(barsSincePattern82) if sp82 wt252 := fvgdet2_wt else wt252 := 0 var bool sp92 = na var int barsSincePattern92 = 0 barsSincePattern92 := shouldPlot92 ? 0 : barsSincePattern92 + 1 sp92 := barsSincePattern92 <= af_len or na(barsSincePattern92) if sp92 wt262 := 0-fvgdet2_wt else wt262 := 0 var bool sp83 = na var int barsSincePattern83 = 0 barsSincePattern83 := shouldPlot83 ? 0 : barsSincePattern83 + 1 sp83 := barsSincePattern83 <= af_len or na(barsSincePattern83) if sp83 wt253 := fvgdet3_wt else wt253 := 0 var bool sp93 = na var int barsSincePattern93 = 0 barsSincePattern93 := shouldPlot93 ? 0 : barsSincePattern93 + 1 sp93 := barsSincePattern93 <= af_len or na(barsSincePattern93) if sp93 wt263 := 0-fvgdet3_wt else wt263 := 0 var bool sp101 = na var int barsSincePattern101 = 0 barsSincePattern101 := shouldPlot101 ? 0 : barsSincePattern101 + 1 sp101 := barsSincePattern101 <= af_len or na(barsSincePattern101) if sp101 wt271 := obdet1_wt else wt271 := 0 var bool sp111 = na var int barsSincePattern111 = 0 barsSincePattern111 := shouldPlot111 ? 0 : barsSincePattern111 + 1 sp111 := barsSincePattern111 <= af_len or na(barsSincePattern111) if sp111 wt281 := 0-obdet1_wt else wt281 := 0 var bool sp102 = na var int barsSincePattern102 = 0 barsSincePattern102 := shouldPlot102 ? 0 : barsSincePattern102 + 1 sp102 := barsSincePattern102 <= af_len or na(barsSincePattern102) if sp102 wt272 := obdet2_wt else wt272 := 0 var bool sp112 = na var int barsSincePattern112 = 0 barsSincePattern112 := shouldPlot112 ? 0 : barsSincePattern112 + 1 sp112 := barsSincePattern112 <= af_len or na(barsSincePattern112) if sp112 wt282 := 0-obdet2_wt else wt282 := 0 var bool sp103 = na var int barsSincePattern103 = 0 barsSincePattern103 := shouldPlot103 ? 0 : barsSincePattern103 + 1 sp103 := barsSincePattern103 <= af_len or na(barsSincePattern103) if sp103 wt273 := obdet3_wt else wt273 := 0 var bool sp113 = na var int barsSincePattern113 = 0 barsSincePattern113 := shouldPlot113 ? 0 : barsSincePattern113 + 1 sp113 := barsSincePattern113 <= af_len or na(barsSincePattern113) if sp113 wt283 := 0-obdet3_wt else wt283 := 0 var bool splott_b = na var int barsSincePattern20 = 0 barsSincePattern20 := plott_b ? 0 : barsSincePattern20 + 1 splott_b := barsSincePattern20 <= af_len or na(barsSincePattern20) if splott_b wt291 := boch1_wt else wt291 := 0 var bool splott_r = na var int barsSincePattern21 = 0 barsSincePattern21 := plott_r ? 0 : barsSincePattern21 + 1 splott_r := barsSincePattern21 <= af_len or na(barsSincePattern21) if splott_r wt301 := 0-boch1_wt else wt301 := 0 var bool splott_bb = na var int barsSincePattern22 = 0 barsSincePattern22 := plott_bb ? 0 : barsSincePattern22 + 1 splott_bb := barsSincePattern22 <= af_len or na(barsSincePattern22) if splott_bb wt292 := boch2_wt else wt292 := 0 var bool splott_rr = na var int barsSincePattern23 = 0 barsSincePattern23 := plott_rr ? 0 : barsSincePattern23 + 1 splott_rr := barsSincePattern23 <= af_len or na(barsSincePattern23) if splott_rr wt302 := 0-boch2_wt else wt302 := 0 obwt = wt271+wt272+wt273+wt281+wt282+wt283 if obwt == obdet1_wt+obdet2_wt obwt := obdet2_wt if obwt == obdet2_wt+obdet3_wt or obwt == obdet1_wt+obdet2_wt+obdet3_wt or obwt == obdet1_wt+obdet3_wt obwt := obdet3_wt if obwt == 0 - (obdet1_wt+obdet2_wt) obwt := 0 - obdet2_wt if (obwt == 0 - (obdet2_wt+obdet3_wt)) or (obwt == 0 - (obdet1_wt+obdet2_wt+obdet3_wt)) or (obwt == 0 - (obdet1_wt+obdet3_wt)) obwt := 0 - obdet3_wt fvgwt = wt251+wt261+wt252+wt262+wt253+wt263 if fvgwt == fvgdet1_wt+fvgdet2_wt fvgwt := fvgdet2_wt if fvgwt == fvgdet2_wt+fvgdet3_wt or fvgwt == fvgdet1_wt+fvgdet2_wt+fvgdet3_wt or fvgwt == fvgdet1_wt+fvgdet3_wt fvgwt := fvgdet3_wt if fvgwt == 0 - (fvgdet1_wt+fvgdet2_wt) fvgwt := 0 - fvgdet2_wt if (fvgwt == 0 - (fvgdet2_wt+fvgdet3_wt)) or (fvgwt == 0 - (fvgdet1_wt+fvgdet2_wt+fvgdet3_wt)) or (fvgwt == 0 - (fvgdet1_wt+fvgdet3_wt)) fvgwt := 0 - fvgdet3_wt kldwt = wt231+wt241+wt232+wt242+wt233+wt243 if kldwt == kld1_wt+kld2_wt kldwt := kld2_wt if kldwt == kld2_wt+kld3_wt or kldwt == kld1_wt+kld2_wt+kld3_wt or kldwt == kld1_wt+kld3_wt kldwt := kld3_wt if kldwt == 0 - (kld1_wt+kld2_wt) kldwt := 0 - kld2_wt if (kldwt == 0 - (kld2_wt+kld3_wt)) or (kldwt == 0 - (kld1_wt+kld2_wt+kld3_wt)) or (kldwt == 0 - (kld1_wt+kld3_wt)) kldwt := 0 - kld3_wt wt = wt311+wt312+wt321+wt322+kldwt+fvgwt+obwt+wt292+wt302+wt291+wt301+wt131+wt141+wt132+wt142+wt133+wt143+wt51+wt61+wt71+wt81+wt52+wt62+wt72+wt82+wt53+wt63+wt73+wt83+wt1+wt2+wt3+wt4+wt9+wt10+wt11+wt12+wt15+wt16+wt17+wt18+wt19+wt20+wt21+wt22 plot((wt), color=color.new(#b71c1c, 0)) plot((0), color=color.new(#000000, 0)) plot((3), color=color.new(#000000, 0)) plot((-3), color=color.new(#000000, 0))