//@version=6 indicator("Tam giác mở rộng - MegaPhone Broadening" , "Tam giác mở rộng" , overlay = true , max_bars_back = 5000 , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500) //Input PP = input.int(13 , "Lọc nhiễu Pivot", minval = 2, group = 'Logic') Pattern_Filter = input.string('Rất chủ động', 'Lọc nhiễu mẫu hình giá', ['Rất chủ động' , 'Chủ động' , 'Bị động' , 'Rất Bị động'], group = 'Logic') Candle_Confirmation = input.bool(false, 'Confirm khi đóng nến?', group = 'Logic') Alert = 'on' AlertName = 'Expansion Triangle' Frequncy = 'Once Per Bar' UTC = 'UTC' MessageBull = 'Long Signal Position Based on Expansion Triangle' MessageBear ='Short Signal Position Based on Expansion Triangle' //Calculation ATR =ta.atr(21) Open = open High = high Low = low Close = close Bar_Index = bar_index var ArrayType = array.new_string() var ArrayValue = array.new_float() var ArrayIndex = array.new_int() var Line = array.new_line() HighPivot = ta.pivothigh(PP,PP) LowPivot = ta.pivotlow(PP,PP) HighValue = ta.valuewhen(bool(HighPivot) ,high[PP], 0) LowValue = ta.valuewhen(bool(LowPivot) ,low[PP], 0) HighIndex = ta.valuewhen(bool(HighPivot) ,bar_index[PP], 0) LowIndex = ta.valuewhen(bool(LowPivot) ,bar_index[PP], 0) Correct_HighPivot = 0.0 Correct_LowPivot = 0.0 PASS = 0 if bool(HighPivot) and bool(LowPivot) if ArrayType.size() == 0 PASS := 1 else if ArrayType.size() >= 1 if ((ArrayType.get(ArrayType.size() - 1)) == "L" or (ArrayType.get(ArrayType.size() - 1)) == "LL") if LowPivot < ArrayValue.get(ArrayType.size() - 1) array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H" ) ///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if (ArrayType.get(ArrayType.size() - 1)) == "H" or (ArrayType.get(ArrayType.size() - 1)) == "HH" if HighPivot > ArrayValue.get(ArrayType.size() - 1) array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else if (ArrayType.get(ArrayType.size() - 1)) == "LH" if HighPivot < ArrayValue.get(ArrayType.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else if HighPivot > ArrayValue.get(ArrayType.size() - 1) if close < ArrayValue.get(ArrayType.size() - 1) array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if close > ArrayValue.get(ArrayType.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else if (ArrayType.get(ArrayType.size() - 1)) == "HL" if LowPivot > ArrayValue.get(ArrayType.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H" ) ///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if LowPivot < ArrayValue.get(ArrayType.size() - 1) if close > ArrayValue.get(ArrayType.size() - 1) array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else if close < ArrayValue.get(ArrayType.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if bool(HighPivot) if ArrayType.size() == 0 array.insert(ArrayType, 0, "H") array.insert(ArrayValue, 0, HighValue) array.insert(ArrayIndex, 0, HighIndex) Correct_HighPivot := HighValue else if ArrayType.size() >= 1 if ((ArrayType.get(ArrayType.size() - 1)) == "L" or (ArrayType.get(ArrayType.size() - 1)) == "HL" or (ArrayType.get(ArrayType.size() - 1)) == "LL") if HighPivot > ArrayValue.get(ArrayType.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H" ) ///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if HighPivot < ArrayValue.get(ArrayType.size() - 1) array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else if (ArrayType.get(ArrayType.size() - 1)) == "H" or (ArrayType.get(ArrayType.size() - 1)) == "HH" or (ArrayType.get(ArrayType.size() - 1)) == "LH" if (ArrayValue.get(ArrayValue.size() - 1)) < HighValue array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if bool(LowPivot) if ArrayType.size() == 0 array.insert(ArrayType, 0, "L") array.insert(ArrayValue, 0, LowValue) array.insert(ArrayIndex, 0, LowIndex) Correct_LowPivot := LowValue else if ArrayType.size() >= 1 if (ArrayType.get(ArrayType.size() - 1)) == "H" or (ArrayType.get(ArrayType.size() - 1)) == "HH" or (ArrayType.get(ArrayType.size() - 1)) == "LH" if LowPivot < ArrayValue.get(ArrayType.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue else if LowPivot > ArrayValue.get(ArrayType.size() - 1) array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < HighValue ? "HH" : "LH" : "H")///////////////////////////////Here array.push(ArrayValue, HighValue) array.push(ArrayIndex, HighIndex) Correct_HighPivot := HighValue else if (ArrayType.get(ArrayType.size() - 1)) == "L" or (ArrayType.get(ArrayType.size() - 1)) == "HL" or (ArrayType.get(ArrayType.size() - 1)) == "LL" if (ArrayValue.get(ArrayValue.size() - 1)) > LowValue array.remove(ArrayType,ArrayType.size() - 1) array.remove(ArrayValue,ArrayValue.size() - 1) array.remove(ArrayIndex,ArrayIndex.size() - 1) array.push(ArrayType,ArrayType.size()>2? ArrayValue.get(ArrayType.size() - 2) < LowValue ? "HL" : "LL" : "L")///////////////////////////////Here array.push(ArrayValue, LowValue) array.push(ArrayIndex, LowIndex) Correct_LowPivot := LowValue Fibo(X0, X1) => Y_236 = X0 + ((X1 - X0) * 0.236) Y_382 = X0 + ((X1 - X0) * 0.382) Y_500 = X0 + ((X1 - X0) * 0.500) Y_618 = X0 + ((X1 - X0) * 0.618) Y_786 = X0 + ((X1 - X0) * 0.786) Y_100 = X0 + ((X1 - X0) * 1.000) Y_120 = X0 + ((X1 - X0) * 1.020) Y_150 = X0 + ((X1 - X0) * 1.500) Y_161 = X0 + ((X1 - X0) * 1.618) Y_200 = X0 + ((X1 - X0) * 2.000) [Y_236,Y_382,Y_500,Y_618,Y_786,Y_100,Y_120,Y_150,Y_161,Y_200] //Candle Confirmation candle_range = high - low candle_body = (close - open) cod_pos_candle = candle_body > 0 cod_neg_candle = candle_body < 0 cod_full_body = math.abs((candle_body/candle_range)) > 0.6 cod_full_bodyIB = math.abs((candle_body/candle_range)) //Dark Cloud codDC1 = open >= close[1]//Weak condition codDC2 = open >= high[1]//Strong condition codDC3 = high > high[1] //Piercing Line codPL1 = open <= close[1]//Weak condition codPL2 = open <= low[1]//Strong condition codPL3 = low < low[1] //Dark Cloud first_checkDC = cod_pos_candle[1] and cod_neg_candle //Piercing Line first_checkPL = cod_pos_candle and cod_neg_candle[1] //Dark Cloud cod_semi_cloud = (close < close[1]) and (close > ((low[1] + ((high[1] - low[1])*0.5)))) cod_full_cloud = (close <= (low[1] + ((high[1] - low[1])*0.5))) //Piercing Line cod_semi_cloudPL = close > close[1] and close > (low[1] + (high[1] - low[1])*0.5) cod_full_cloudPL = close >= (low[1] + (high[1] - low[1])*0.5) //Dark Cloud cod_WDC1 = (codDC1 and codDC3 and cod_full_body and cod_full_body[1] and cod_semi_cloud) cod_WDC2 = (codDC2 and codDC3 and cod_full_body and cod_full_body[1] and cod_semi_cloud) cod_WDC3 = (codDC1 and codDC3 and cod_full_body and cod_full_body[1] and cod_full_cloud) cod_SDC = (codDC2 and codDC3 and cod_full_body and cod_full_body[1] and cod_full_cloud) //Piercing Line cod_WPL1 = (codPL1 and codPL3 and cod_full_body and cod_full_body[1] and cod_semi_cloudPL) cod_WPL2 = (codPL2 and codPL3 and cod_full_body and cod_full_body[1] and cod_semi_cloudPL) cod_WPL3 = (codPL1 and codPL3 and cod_full_body and cod_full_body[1] and cod_full_cloudPL) cod_SPL = (codPL2 and codPL3 and cod_full_body and cod_full_body[1] and cod_full_cloudPL) //Dark Cloud Weak_DarkCloud = if first_checkDC cod_WDC1 or cod_WDC2 or cod_WDC3 Strong_Darkcloud = if first_checkDC cod_SDC if Strong_Darkcloud == true Weak_DarkCloud:= false //Piercing Line Weak_PiercingLine = if first_checkPL cod_WPL1 or cod_WPL2 or cod_WPL3 Strong_PiercingLine = if first_checkPL cod_SPL if Strong_PiercingLine == true Weak_PiercingLine:= false // Bullish 3 Inside bar inside_bar_Bull_W = cod_neg_candle[2] and cod_pos_candle and cod_full_bodyIB >= 0.6 and cod_full_bodyIB <= 0.8 and close > high[1] and close > ((low[2] + high[2]) / 2) and high[1] < high[2] and low[2] > low[1] inside_bar_Bull_S = cod_neg_candle[2] and cod_pos_candle and cod_full_bodyIB > 0.8 and close > high[1] and close > ((low[2] + high[2]) / 2) and high[1] < high[2] and low[2] > low[1] // Bearish 3 Inside bar inside_bar_Bear_W = cod_neg_candle and cod_pos_candle[2] and cod_full_bodyIB >= 0.6 and cod_full_bodyIB <= 0.8 and close < low[1] and close < ((low[2] + high[2]) / 2) and high[1] > high[2] and low[2] < low[1] inside_bar_Bear_S = cod_neg_candle and cod_pos_candle[2] and cod_full_bodyIB > 0.8 and close < low[1] and close < ((low[2] + high[2]) / 2) and high[1] > high[2] and low[2] < low[1] //Engulfing trend = high[3] - low[1] power_trend = math.abs(trend / ATR) check_trendBu = high[3] - low[1] > 0 and power_trend > 2 check_trendBe = high[1] - low[3] < 0 and power_trend > 2 engulfungWBu = high >= high[1] and close > open[1] and check_trendBu and candle_body[1] < 0 and candle_range > 1.2 *ATR and cod_full_bodyIB > 0.6 and cod_full_bodyIB <= 0.75 engulfungSBu = close > high[1] and check_trendBu and candle_body[1] < 0 and candle_range > 1.2 *ATR and cod_full_bodyIB > 0.75 engulfungWBe = low <= low[1] and close < open[1] and check_trendBe and candle_body[1] > 0 and candle_range > 1.2 *ATR and cod_full_bodyIB > 0.6 and cod_full_bodyIB <= 0.75 engulfungSBe = close < low[1] and check_trendBe and candle_body[1] > 0 and candle_range > 1.2 *ATR and cod_full_bodyIB > 0.75 //Pin Bar | Hammer | Shooting Star //Bullish PinBar Pass = 1 BullPinBar1 = if candle_body > 0 if high != close or high != open (open - low) / candle_body >= 2 and (open - low ) / (high - close) >= 3 else (open - low) / candle_body >= 2 else if candle_body < 0 if high != close or high != open (close - low) / math.abs(candle_body) >= 2 and (close - low) / (high - open) >= 3 else (close - low) / math.abs(candle_body) >= 2 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BullPinBar2 = if candle_body > 0 if high != close or high != open (open - low) / candle_body >= 2 and (open - low ) / (high - close) >= 3 else (open - low) / candle_body >= 2 else if candle_body < 0 if high != close or high != open (close - low) / math.abs(candle_body) >= 2 and (close - low) / (high - open) >= 3 else (close - low) / math.abs(candle_body) >= 2 //Bearish PinBar BearPinBar1 = if candle_body > 0 if low != close or low != open (high - close) / candle_body >= 2 and (high - close ) / (open - low) >= 3 else (high - close) / candle_body >= 2 else if candle_body < 0 if low != close or low != open (high - open) / math.abs(candle_body) >= 2 and (high - open) / (close - low) >= 3 else (high - open) / math.abs(candle_body) >= 2 BearPinBar2 = if candle_body > 0 if low != close or low != open (high - close) / candle_body >= 2 and (high - close ) / (open - low) >= 3 else (high - close) / candle_body >= 2 else if candle_body < 0 if low != close or low != open (high - open) / math.abs(candle_body) >= 2 and (high - open) / (close - low) >= 3 else (high - open) / math.abs(candle_body) >= 2 Bear_Candle = Weak_DarkCloud or Strong_Darkcloud or (inside_bar_Bear_S or inside_bar_Bear_W) or (engulfungSBe or engulfungWBe) or (BearPinBar1 or BearPinBar2) Bull_candle = Weak_PiercingLine or Strong_PiercingLine or (inside_bar_Bull_S or inside_bar_Bull_W) or (engulfungSBu or engulfungWBu) or (BullPinBar1 or BullPinBar2 ) var string TypePoint0 = '', var float PricePoint0 = 0.0, var int IndexPoint0 = 0 var string TypePoint1 = '', var float PricePoint1 = 0.0, var int IndexPoint1 = 0 var string TypePoint2 = '', var float PricePoint2 = 0.0, var int IndexPoint2 = 0 var string TypePoint3 = '', var float PricePoint3 = 0.0, var int IndexPoint3 = 0 var string TypePoint4 = '', var float PricePoint4 = 0.0, var int IndexPoint4 = 0 var string TypePoint5 = '', var float PricePoint5 = 0.0, var int IndexPoint5 = 0 var string TypePoint6 = '', var float PricePoint6 = 0.0, var int IndexPoint6 = 0 var string TypePoint7 = '', var float PricePoint7 = 0.0, var int IndexPoint7 = 0 var line Bull_LineA = na, var line Bear_LineA = na var line Bull_LineB = na, var line Bear_LineB = na var line Bull_LineC = na, var line Bear_LineC = na var line Bull_LineD = na, var line Bear_LineD = na var line Bull_LineE = na, var line Bear_LineE = na var line Bull_LineF = na, var line Bear_LineF = na var line Bull_High = na, var line Bear_High = na var line Bull_Low = na, var line Bear_Low = na var bool BearSetup = false var bool BullSetup = false if ArrayType.size() > 8 TypePoint0 := ArrayType.get(ArrayType.size() - 1), PricePoint0 := ArrayValue.get(ArrayType.size() - 1), IndexPoint0 := ArrayIndex.get(ArrayType.size() - 1) TypePoint1 := ArrayType.get(ArrayType.size() - 2), PricePoint1 := ArrayValue.get(ArrayType.size() - 2), IndexPoint1 := ArrayIndex.get(ArrayType.size() - 2) TypePoint2 := ArrayType.get(ArrayType.size() - 3), PricePoint2 := ArrayValue.get(ArrayType.size() - 3), IndexPoint2 := ArrayIndex.get(ArrayType.size() - 3) TypePoint3 := ArrayType.get(ArrayType.size() - 4), PricePoint3 := ArrayValue.get(ArrayType.size() - 4), IndexPoint3 := ArrayIndex.get(ArrayType.size() - 4) TypePoint4 := ArrayType.get(ArrayType.size() - 5), PricePoint4 := ArrayValue.get(ArrayType.size() - 5), IndexPoint4 := ArrayIndex.get(ArrayType.size() - 5) TypePoint5 := ArrayType.get(ArrayType.size() - 6), PricePoint5 := ArrayValue.get(ArrayType.size() - 6), IndexPoint5 := ArrayIndex.get(ArrayType.size() - 6) TypePoint6 := ArrayType.get(ArrayType.size() - 7), PricePoint6 := ArrayValue.get(ArrayType.size() - 7), IndexPoint6 := ArrayIndex.get(ArrayType.size() - 7) TypePoint7 := ArrayType.get(ArrayType.size() - 8), PricePoint7 := ArrayValue.get(ArrayType.size() - 8), IndexPoint7 := ArrayIndex.get(ArrayType.size() - 8) //Fibo Call Function [Y_236_43 ,Y_382_43 ,Y_500_43 ,Y_618_43 ,Y_786_43 ,Y_100_43 ,Y_120_43 ,Y_150_43 ,Y_161_43 ,Y_200_43] = Fibo(PricePoint3, PricePoint4) [Y_236_32 ,Y_382_32 ,Y_500_32 ,Y_618_32 ,Y_786_32 ,Y_100_32 ,Y_120_32 ,Y_150_32 ,Y_161_32 ,Y_200_32] = Fibo(PricePoint2, PricePoint3) [Y_236_21 ,Y_382_21 ,Y_500_21 ,Y_618_21 ,Y_786_21 ,Y_100_21 ,Y_120_21 ,Y_150_21 ,Y_161_21 ,Y_200_21] = Fibo(PricePoint1, PricePoint2) [Y_236_10 ,Y_382_10 ,Y_500_10 ,Y_618_10 ,Y_786_10 ,Y_100_10 ,Y_120_10 ,Y_150_10 ,Y_161_10 ,Y_200_10] = Fibo(PricePoint0, PricePoint1) //Filter Bear_Filter_Step_1 = (Y_200_43 < PricePoint2) and (Y_200_32 > PricePoint1) and (Y_200_21 < PricePoint0) and (Y_200_10 > high) Bear_Filter_Step_2 = (Y_120_43 > PricePoint2) and (Y_120_32 < PricePoint1) and (Y_120_21 > PricePoint0) Bear_Filter_Step_3 = high >= Bear_High.get_price(bar_index) Bull_Filter_Step_1 = (Y_200_43 > PricePoint2) and (Y_200_32 < PricePoint1) and (Y_200_21 > PricePoint0) and (Y_200_10 < low) Bull_Filter_Step_2 = (Y_120_43 < PricePoint2) and (Y_120_32 > PricePoint1) and (Y_120_21 < PricePoint0) Bull_Filter_Step_3 = low <= Bull_Low.get_price(bar_index) PF_Bull = switch Pattern_Filter 'Rất chủ động' => true 'Chủ động' => Bull_Filter_Step_1 'Bị động' => Bull_Filter_Step_1 and Bull_Filter_Step_2 'Rất Bị động' => Bull_Filter_Step_1 and Bull_Filter_Step_2 PF_Bear = switch Pattern_Filter 'Rất chủ động' => true 'Chủ động' => Bear_Filter_Step_1 'Bị động' => Bear_Filter_Step_1 and Bear_Filter_Step_2 'Rất Bị động' => Bear_Filter_Step_1 and Bear_Filter_Step_2 ///////////////////////////////// //Bearish SetUp var int BeI = 0 var float BeP = 0.0 var bool Be_Permit = true //Bullish SetUp var int BuI = 0 var float BuP = 0.0 var bool Bu_Permit = true //Bearish Logic if TypePoint0 == 'LL' and TypePoint1 == 'HH' and TypePoint2 == 'LL' and (TypePoint3 == 'LH' or TypePoint3 == 'HH') and (TypePoint4 == 'HL' or TypePoint4 == 'LL' ) and high > PricePoint1 and PF_Bear and (Candle_Confirmation ? (Pattern_Filter != 'Rất Bị động' ? Bear_Candle : true) : true) BearSetup := true BeI := IndexPoint0 BeP := PricePoint0 if BeI == IndexPoint2 BearSetup := false Be_Permit := true if not BearSetup[1] and BearSetup Bear_LineA := line.new(IndexPoint0, PricePoint0, IndexPoint1, PricePoint1, color = color.red, width = 2) Bear_LineB := line.new(IndexPoint1, PricePoint1, IndexPoint2, PricePoint2, color = color.red, width = 2) Bear_LineC := line.new(IndexPoint2, PricePoint2, IndexPoint3, PricePoint3, color = color.red, width = 2) Bear_LineD := line.new(IndexPoint3, PricePoint3, IndexPoint4, PricePoint4, color = color.red, width = 2) Bear_High := line.new(IndexPoint3, PricePoint3, IndexPoint1, PricePoint1, color = color.rgb(93, 95, 99), style = line.style_dashed) Bear_Low := line.new(IndexPoint4, PricePoint4, IndexPoint2, PricePoint2, color = color.rgb(93, 95, 99), style = line.style_dashed) if Pattern_Filter != 'Rất Bị động' Bear_LineE := line.new(IndexPoint0, PricePoint0, bar_index , high , color = color.red, width = 2, style = line.style_dotted) Be_Permit := false if Pattern_Filter == 'Rất Bị động' and BearSetup and Bear_Filter_Step_3 and Be_Permit and (Candle_Confirmation ? Bear_Candle : true) Bear_LineE := line.new(BeI , BeP, bar_index, high, color = color.red, width = 2, style = line.style_dotted) Be_Permit := false if BearSetup[1] and BearSetup Bear_High.set_xy2(bar_index, Bear_High.get_price(bar_index)) Bear_Low.set_xy2(bar_index, Bear_Low.get_price(bar_index)) //Bullish Logic if TypePoint0 == 'HH' and TypePoint1 == 'LL' and TypePoint2 == 'HH' and (TypePoint3 == 'HL' or TypePoint3 == 'LL') and (TypePoint4 == 'LH' or TypePoint4 == 'HH') and low < PricePoint1 and PF_Bull and (Candle_Confirmation ? (Pattern_Filter != 'Rất Bị động' ? Bull_candle : true) : true) BullSetup := true BuI := IndexPoint0 BuP := PricePoint0 if BuI == IndexPoint2 BullSetup := false Bu_Permit := true if not BullSetup[1] and BullSetup Bull_LineA := line.new(IndexPoint0, PricePoint0, IndexPoint1, PricePoint1, color = color.green, width = 2) Bull_LineB := line.new(IndexPoint1, PricePoint1, IndexPoint2, PricePoint2, color = color.green, width = 2) Bull_LineC := line.new(IndexPoint2, PricePoint2, IndexPoint3, PricePoint3, color = color.green, width = 2) Bull_LineD := line.new(IndexPoint3, PricePoint3, IndexPoint4, PricePoint4, color = color.green, width = 2) Bull_High := line.new(IndexPoint4, PricePoint4, IndexPoint2, PricePoint2, color = color.rgb(93, 95, 99), style = line.style_dashed) Bull_Low := line.new(IndexPoint3, PricePoint3, IndexPoint1, PricePoint1, color = color.rgb(93, 95, 99), style = line.style_dashed) if Pattern_Filter != 'Rất Bị động' Bull_LineE := line.new(IndexPoint0, PricePoint0, bar_index , low , color = color.green, width = 2, style = line.style_dotted) Bu_Permit := false if Pattern_Filter == 'Rất Bị động' and BullSetup and Bull_Filter_Step_3 and Bu_Permit and (Candle_Confirmation ? Bull_candle : true) Bull_LineE := line.new(BuI , BuP, bar_index, low, color = color.green, width = 2, style = line.style_dotted) Bu_Permit := false if BullSetup[1] and BullSetup Bull_High.set_xy2(bar_index, Bull_High.get_price(bar_index)) Bull_Low.set_xy2(bar_index, Bull_Low.get_price(bar_index)) Bull_Alert = Bu_Permit[1] and not Bu_Permit Bear_Alert = Be_Permit[1] and not Be_Permit plotchar(Bear_Alert, char = "⬇", size = size.small , color = color.red , location = location.abovebar) plotchar(Bull_Alert, char = "⬆", size = size.small , color = color.green, location = location.belowbar)