// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © arqsampaio //@version=5 //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REV 2.6 - VERSÃO 88.0 FUNCIOANNDO //NOTAS: //V.2.5 = VERÇÃO FUNCIONANDO PERFEITAMENTE- ENTRADA NO ROMPIMENTO DAS ZONAS DE SUPORTE E RESISTENCIA TANTO LONG E SHORT E ENTRADA EM ZONAS DE RESISTENCIA E SUPORTE //PLANEJAMENTO PARA VERSÃO 3.0 //1.INCLUIR FILTRO DE VOLUME DA BARRA DE ACORDO COM O ROMPIMENTO //2.INCLUIR FIBONACCI RETRAÇÃO E PROJEÇÃO strategy(title="TA_STR_VOL.SUPORT_RESIST._REV02.6_FUNCIONANDO",shorttitle = 'VOL.SUPORT_RESIST._REV02.6', initial_capital = 1000, default_qty_type = strategy.fixed, default_qty_value = 1, pyramiding = 0, currency = 'USD', commission_type=strategy.commission.cash_per_contract, commission_value =1, overlay=true) // INPUT ============================================================================================================ CloseSession = input.bool(true, title="Close positions at market at the end of each session ?", group="Session") Session = input.session(title="Trading Session", defval="0900-1745", group="Session") ExtendLines = input.bool(title='Extend previous S/R?', defval=true, tooltip='If enabled all previous SR zones will extend to the next SR zone. If disabled, historical SR zones will not be extended but active SR zones will remain extended.', group='*** General Settings ***') ShowLabel = input.bool(title='Show Time Frame Label?', defval=true, group='*** General Settings ***') //// Stoploss and Take Profit Parameters // Enable Long Strategy ativa_estrategia_compra_TF1 = input(true, title="Ativar Estrategida de Compra no S/P TF1?", group="SL/TP For Long Strategy", inline="1") ativa_estrategia_compra_TF2 = input(false, title="Ativar Estrategida de Compra no S/P TF2?", group="SL/TP For Long Strategy", inline="1") ativa_estrategia_compra_TF3 = input(false, title="Ativar Estrategida de Compra no S/P TF3?",group="SL/TP For Long Strategy", inline="1") ativa_estrategia_compra_TF4 = input(false, title="Ativar Estrategida de Compra no S/P TF4?", group="SL/TP For Long Strategy", inline="1") long_stoploss_value = input.float(defval=0.55, title='Stoploss %', minval=0.1, step=0.1, group="SL/TP For Long Strategy",inline="2") long_stoploss_percentage = (close * (long_stoploss_value / 100)) / syminfo.mintick long_takeprofit_value = input.float(defval=1.0, title='Take Profit %', minval=0.1,step=0.1, group="SL/TP For Long Strategy",inline="2") long_takeprofit_percentage = (close * (long_takeprofit_value / 100)) / syminfo.mintick // Enable Short Strategy ativa_estrategia_venda_TF1 = input(true, title="Ativar Estrategida de Venda no S/P TF1?", group="SL/TP For Short Strategy",inline="3") ativa_estrategia_venda_TF2 = input(false, title="Ativar Estrategida de Venda no S/P TF2?", group="SL/TP For Short Strategy",inline="3") ativa_estrategia_venda_TF3 = input(false, title="Ativar Estrategida de Venda no S/P TF3?", group="SL/TP For Short Strategy",inline="3") ativa_estrategia_venda_TF4 = input(false, title="Ativar Estrategida de Venda no S/P TF4?", group="SL/TP For Short Strategy",inline="3") short_stoploss_value = input.float(defval=0.55, title='Stoploss %', minval=0.1, step=0.1, group= "SL/TP For Short Strategy",inline="4") short_stoploss_percentage = (close * (short_stoploss_value / 100)) / syminfo.mintick short_takeprofit_value = input.float(defval=1.0, title='Take Profit %', minval=0.1, step=0.1, group="SL/TP For Short Strategy",inline="4") short_takeprofit_percentage = (close * (short_takeprofit_value / 100)) / syminfo.mintick // Plot Stoploss & Take Profit Levels long_stoploss_price = strategy.position_avg_price * (1 - long_stoploss_value/100) long_takeprofit_price = strategy.position_avg_price * (1 + long_takeprofit_value/100) short_stoploss_price = strategy.position_avg_price * (1 + short_stoploss_value/100) short_takeprofit_price = strategy.position_avg_price * (1 - short_takeprofit_value/100) plot(ativa_estrategia_compra_TF1 or ativa_estrategia_compra_TF2 or ativa_estrategia_compra_TF3 or ativa_estrategia_compra_TF4 and not ativa_estrategia_venda_TF1 or ativa_estrategia_venda_TF2 or ativa_estrategia_venda_TF3 or ativa_estrategia_venda_TF4 ? long_stoploss_price: na, color=#ff0000, style=plot.style_linebr, linewidth=2, title="Long SL Level") plot(ativa_estrategia_compra_TF1 or ativa_estrategia_compra_TF2 or ativa_estrategia_compra_TF3 or ativa_estrategia_compra_TF4 and not ativa_estrategia_venda_TF1 or ativa_estrategia_venda_TF2 or ativa_estrategia_venda_TF3 or ativa_estrategia_venda_TF4 ? long_takeprofit_price: na, color=#008000, style=plot.style_linebr, linewidth=2, title="Long TP Level") plot(ativa_estrategia_venda_TF1 or ativa_estrategia_venda_TF2 or ativa_estrategia_venda_TF3 or ativa_estrategia_venda_TF4 and not ativa_estrategia_compra_TF1 or ativa_estrategia_compra_TF2 or ativa_estrategia_compra_TF3 or ativa_estrategia_compra_TF4 ? short_stoploss_price: na, color=#ff0000, style=plot.style_linebr, linewidth=2, title="Short SL Level") plot(ativa_estrategia_venda_TF1 or ativa_estrategia_venda_TF2 or ativa_estrategia_venda_TF3 or ativa_estrategia_venda_TF4 and not ativa_estrategia_compra_TF1 or ativa_estrategia_compra_TF2 or ativa_estrategia_compra_TF3 or ativa_estrategia_compra_TF4 ? short_takeprofit_price: na, color=#008000, style=plot.style_linebr, linewidth=2, title="Short TP Level") //// Inputs **This is where you enter your indicators for your strategy. For example, I added the RSI indicator.** // INPUTS DA ESTRATEGIA ============================================================================================================ // Time Frame 1 = TF1 // TF1 = SUPORTE -> EQUIVALE A ENTRADA DE COMPRA/LONG - ENTRA NO MOMENTO QUE O PREÇO FECHA NO SUPORTE TF1_Menu = input.string(title='TF1 - A ESTRATEGIA ESCOLHIDA IRÁ DEFINIR O TIPO DE ENTRADA - EX.: SUPORTE=COMPRA E RESITENCIA=VENDA', defval='S/R Zones', options=['S/R Zones', 'Disable'], group='*** Time Frame 1 ***') TF1_input = input.string(title='Time Frame 1', defval='5m', options=['Chart','1m','2m','3m', '5m','10m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', 'D', '3D', 'W', '2W', '1M'], group='*** Time Frame 1 ***') TF1_VolMA1Input = input.int(title='Volume MA - Threshold', defval=7, group='*** Time Frame 1 ***') TF1_ResLinesColor = input.color(color.new(color.white, 100), 'Resistance Lines Color', inline='2', group='*** Time Frame 1 ***') TF1_ResZoneColor = input.color(color.new(color.white, 100), 'Resistance Zone Color', inline='3', group='*** Time Frame 1 ***') TF1_SupLinesColor = input.color(color.new(color.lime, 20), ' ...................... Support Lines Color', inline='2', group='*** Time Frame 1 ***') TF1_SupZoneColor = input.color(color.new(color.lime, 90), ' ...................... Support Zone Color', inline='3', group='*** Time Frame 1 ***') TF1_Alerts = input.string(title='Alerts', defval='None', options=['None', 'Zona de Resistência - Venda Forte', 'Zona de Suporte - Compra Forte','Rompi. da Zona de Resistecia - Compra Forte','Rompi. da Zona de Suporte - Venda Forte', 'Ropi. do Suporte - Venda', 'Ropi. da Resistência - Compra','Nova Resistencia - Venda?','Novo Suporte - Compra?','Rompi. Nova Resistencia - Ideal Compra', 'Rompi. Novo Suporte - Ideal Venda', 'All Alerts On'], tooltip='Select the type of alert you would like, then save settings. On chart, right click on SR indicator and click \'Add Alert\' then save. If you would like to change the alert, delete existing alert, change alert settings on indicator, then create new alert', inline='0', group='*** Time Frame 1 ***') // Time Frame 2 = TF2 // TF2 = RESISTENCIA -> EQUIVALE A ENTRADA DE VENDA/SHORT - ENTRA NO MOMENTO QUE O PREÇO FECHA NA RESISTENCIA--> DEVE HABILITAR A OPÇÃO DE "Ativar Estrategida de Venda na Resistencia_TF1?" TF2_Menu = input.string(title='TF2 - A ESTRATEGIA ESCOLHIDA IRÁ DEFINIR O TIPO DE ENTRADA - EX.: SUPORTE=COMPRA E RESITENCIA=VENDA', defval='S/R Zones', options=['S/R', 'S/R Zones', 'Disable'], group= '*** Time Frame 2 ***') TF2_input = input.string(title='Time Frame 2', defval='5m', options=['Chart','1m','2m','3m', '5m','10m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', 'D', '3D', 'W', '2W', '1M'], group='*** Time Frame 2 ***') TF2_VolMA1Input = input.int(title='Volume MA - Threshold', defval=9, group='*** Time Frame 2 ***') TF2_ResLinesColor = input.color(color.new(color.red, 20), 'Resistance Lines Color', inline='1', group='*** Time Frame 2 ***') TF2_ResZoneColor = input.color(color.new(color.red, 90), 'Resistance Zone Color', inline='2', group='*** Time Frame 2 ***') TF2_SupLinesColor = input.color(color.new(color.white, 100), ' ...................... Support Lines Color', inline='1', group='*** Time Frame 2 ***') TF2_SupZoneColor = input.color(color.new(color.white, 100), ' ...................... Support Zone Color', inline='2', group='*** Time Frame 2 ***') TF2_Alerts = input.string(title='Alerts', defval='None', options=['None', 'Zona de Resistência - Venda Forte', 'Zona de Suporte - Compra Forte','Rompi. da Zona de Resistecia - Compra Forte','Rompi. da Zona de Suporte - Venda Forte', 'Ropi. do Suporte - Venda', 'Ropi. da Resistência - Compra','Nova Resistencia - Venda?','Novo Suporte - Compra?','Rompi. Nova Resistencia - Ideal Compra', 'Rompi. Novo Suporte - Ideal Venda', 'All Alerts On'], tooltip='Select the type of alert you would like, then save settings. On chart, right click on SR indicator and click \'Add Alert\' then save. If you would like to change the alert, delete existing alert, change alert settings on indicator, then create new alert', inline='0', group='*** Time Frame 2 ***') // Time Frame 3 = TF3 // TF3 = ROMPIMENTO DE SUPORTE -> EQUIVALE A ENTRADA DE VENDA/SHORT - ENTRA NO MOMENTO QUE O PREÇO ROMPE O SUPORTE TF3 --> DEVE HABILITAR A OPÇÃO DE "Ativar Estrategida de Rompimento do Suporte_TF3?" TF3_Menu = input.string(title='TF3 - A ESTRATEGIA ESCOLHIDA IRÁ DEFINIR O TIPO DE ENTRADA - EX.: SUPORTE=COMPRA E RESITENCIA=VENDA', defval='Disable', options=['S/R', 'S/R Zones', 'Disable'], group='*** Time Frame 3 ***') TF3_input = input.string(title='Time Frame 3', defval='2m', options=['Chart','1m','2m','3m', '5m','10m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', 'D', '3D', 'W', '2W', '1M'], group='*** Time Frame 3 ***') TF3_VolMA1Input = input.int(title='Volume MA - Threshold', defval=2, group='*** Time Frame 3 ***') TF3_ResLinesColor = input.color(color.new(color.white, 100), 'Resistance Lines Color', inline='1', group='*** Time Frame 3 ***') TF3_ResZoneColor = input.color(color.new(color.white, 100), 'Resistance Zone Color', inline='2', group='*** Time Frame 3 ***') TF3_SupLinesColor = input.color(color.new(color.blue, 20), ' ...................... Support Lines Color', inline='1', group='*** Time Frame 3 ***') TF3_SupZoneColor = input.color(color.new(color.blue, 90), ' ...................... Support Zone Color', inline='2', group='*** Time Frame 3 ***') TF3_Alerts = input.string(title='Alerts', defval='None', options=['None', 'Zona de Resistência - Venda Forte', 'Zona de Suporte - Compra Forte','Rompi. da Zona de Resistecia - Compra Forte','Rompi. da Zona de Suporte - Venda Forte', 'Ropi. do Suporte - Venda', 'Ropi. da Resistência - Compra','Nova Resistencia - Venda?','Novo Suporte - Compra?','Rompi. Nova Resistencia - Ideal Compra', 'Rompi. Novo Suporte - Ideal Venda', 'All Alerts On'], tooltip='Select the type of alert you would like, then save settings. On chart, right click on SR indicator and click \'Add Alert\' then save. If you would like to change the alert, delete existing alert, change alert settings on indicator, then create new alert', inline='0', group='*** Time Frame 3 ***') // Time Frame 4 = TF4 //TF4 = RESITENCIA ROMPIDA -> EQUIVALE A ENTRADA DE COMPRA/LONG - ENTRA NO MOMENTO QUE O PREÇO FECHA A RESISTENCIA--> DEVE HABILITAR A OPÇÃO DE "Ativar Estrategida de Rompimento de Resistencia_TF4?" TF4_Menu = input.string(title='TF4 - A ESTRATEGIA ESCOLHIDA IRÁ DEFINIR O TIPO DE ENTRADA - EX.: SUPORTE= COMPRA E RESITENCIA=VENDA', defval='Disable', options=['S/R', 'S/R Zones', 'Disable'], group='*** Time Frame 4 ***') TF4_input = input.string(title='Time Frame 4', defval='30m', options=['1m','2m','3m', '5m','10m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', 'D', '3D', 'W', '2W', '1M'], group='*** Time Frame 4 ***') TF4_VolMA1Input = input.int(title='Volume MA - Threshold', defval=300, group='*** Time Frame 4 ***') TF4_ResLinesColor = input.color(color.new(color.maroon, 20), 'Resistance Lines Color', inline='1', group='*** Time Frame 4 ***') TF4_ResZoneColor = input.color(color.new(color.maroon, 90), 'Resistance Zone Color', inline='2', group='*** Time Frame 4 ***') TF4_SupLinesColor = input.color(color.new(color.teal, 20), ' ...................... Support Lines Color', inline='1', group='*** Time Frame 4 ***') TF4_SupZoneColor = input.color(color.new(color.teal, 90), ' ...................... Support Zone Color', inline='2', group='*** Time Frame 4 ***') TF4_Alerts = input.string(title='Alerts', defval='None', options=['None', 'Zona de Resistência - Venda Forte', 'Zona de Suporte - Compra Forte','Rompi. da Zona de Resistecia - Compra Forte','Rompi. da Zona de Suporte - Venda Forte', 'Ropi. do Suporte - Venda', 'Ropi. da Resistência - Compra','Nova Resistencia - Venda?','Novo Suporte - Compra?','Rompi. Nova Resistencia - Ideal Compra', 'Rompi. Novo Suporte - Ideal Venda', 'All Alerts On'], tooltip='Select the type of alert you would like, then save settings. On chart, right click on SR indicator and click \'Add Alert\' then save. If you would like to change the alert, delete existing alert, change alert settings on indicator, then create new alert', inline='0', group='*** Time Frame 4 ***') // LOGIC ============================================================================================================ // Session calculations BarInSession(sess) => time(timeframe.period, sess) != 0 in_session = BarInSession(Session) okToTradeInSession = CloseSession ? in_session : true new_session = in_session and not in_session[1] // INPUT ============================================================================================================ // // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // CALCULO DA ESTRATEGIA ============================================================================================================ f_TFx(_TF_input) => if _TF_input == 'Chart' timeframe.period else if _TF_input == '1m' '1' else if _TF_input == '2m' '2' else if _TF_input == '3m' '3' else if _TF_input == '5m' '5' else if _TF_input == '10m' '10' else if _TF_input == '15m' '15' else if _TF_input == '30m' '30' else if _TF_input == '1h' '60' else if _TF_input == '2h' '120' else if _TF_input == '4h' '240' else if _TF_input == '6h' '360' else if _TF_input == '12h' '720' else if _TF_input == 'D' 'D' else if _TF_input == '3D' '3D' else if _TF_input == 'W' 'W' else if _TF_input == '2W' '2W' else if _TF_input == '1M' '1M' TF1 = f_TFx(TF1_input) TF2 = f_TFx(TF2_input) TF3 = f_TFx(TF3_input) TF4 = f_TFx(TF4_input) vol_check = na(volume) var label vol_check_lab = na if barstate.islast and vol_check label.delete(vol_check_lab) vol_check_lab := label.new(bar_index + 60, close, text="There is no volume data for this symbol" + " (" + syminfo.tickerid + ")" + "\n Please use a different symbol with volume data", style=label.style_none, textcolor=color.blue, size=size.normal) stockschart = syminfo.type == 'stock' futureschart = syminfo.type == 'futures' indexchart = syminfo.type == 'index' // // --------- This ensures that no plots from lower time frames will be plotted on higher time frames. // ————— Converts current chart resolution into a float minutes value. f_resInMinutes() => if stockschart or futureschart or indexchart _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 16 : timeframe.isweekly ? 60. * 7 * 5 : timeframe.ismonthly ? 60. * 7 * 21 : na) _resInMinutes else _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) _resInMinutes // ————— Returns the float minutes value of the string _res. f_tfResInMinutes(_res) => // _res: resolution of any TF (in "timeframe.period" string format). // Dependency: f_resInMinutes(). request.security(syminfo.tickerid, _res, f_resInMinutes()) // —————————— Determine if current timeframe is smaller that higher timeframe selected in Inputs. // Get higher timeframe in minutes. TF1InMinutes = f_tfResInMinutes(TF1) TF2InMinutes = f_tfResInMinutes(TF2) TF3InMinutes = f_tfResInMinutes(TF3) TF4InMinutes = f_tfResInMinutes(TF4) // Get current timeframe in minutes. currentTFInMinutes = f_resInMinutes() // Compare current TF to higher TF to make sure it is smaller, otherwise our plots don't make sense. chartOnLowerTF1 = currentTFInMinutes <= TF1InMinutes chartOnLowerTF2 = currentTFInMinutes <= TF2InMinutes chartOnLowerTF3 = currentTFInMinutes <= TF3InMinutes chartOnLowerTF4 = currentTFInMinutes <= TF4InMinutes chartEqualTF2 = currentTFInMinutes == TF2InMinutes and TF2_Menu != 'Disable' chartEqualTF3 = currentTFInMinutes == TF3InMinutes and TF3_Menu != 'Disable' chartEqualTF4 = currentTFInMinutes == TF4InMinutes and TF4_Menu != 'Disable' TF1_inH = str.tostring(TF1InMinutes / 60) TF1_text = if stockschart or futureschart TF1InMinutes >= 60 and TF1InMinutes < 960 ? TF1_inH + 'h' : TF1InMinutes < 60 ? TF1 + 'm' : TF1 else TF1InMinutes >= 60 and TF1InMinutes < 1440 ? TF1_inH + 'h' : TF1InMinutes < 60 ? TF1 + 'm' : TF1 //--- In order to get the left side of SR zone on higher time frames to line up directly on the bar with the fractal high or fractal low, we need to perform //--- a series of calculations to find the pivot high/low. Since the FractalUp or FractalDown condition is found after 2 confirming bars, the SR zone would begin //--- at that point (3 bars after the pivot high/low). For example, if there is a 4hr Fractal confirmed while on the 1hr chart, it would take 3 4hr bars to confirm. //--- That means the high/low point could've occured anywhere between 8-12 1hr bars ago. // // --------- To get the correct bar_index for higher time frame lines placed on lower time frame candles, // // --------- we need to calculate how many lower time frame bars are contained in the higher time frame bar, // // --------- Then find the highest/lowest bar within that range of bars for bar_index on the x1 (left) coordinates of lines. // Calculate number of current TF bars in higher TF bar barsinTF1 = TF1InMinutes / currentTFInMinutes barsinTF2 = TF2InMinutes / currentTFInMinutes barsinTF3 = TF3InMinutes / currentTFInMinutes barsinTF4 = TF4InMinutes / currentTFInMinutes // Multiply the # of current TF bars in higher TF bar by 1 to provide a starting point back to start scanning, and multiply by 3 for the range of bars to scan for highs/lows // Round up to make integer for bar indexing TF1_bar_index = math.ceil(1 * barsinTF1) TF2_bar_index = math.ceil(1 * barsinTF2) TF3_bar_index = math.ceil(1 * barsinTF3) TF4_bar_index = math.ceil(1 * barsinTF4) TF1_bar_index_range = math.ceil(3 * barsinTF1) TF2_bar_index_range = math.ceil(3 * barsinTF2) TF3_bar_index_range = math.ceil(3 * barsinTF3) TF4_bar_index_range = math.ceil(3 * barsinTF4) // Get offset value for the highest high or lowest low found within the specified range , using [] to establish the starting point back to begin scanning past bars for highest high or lowest low. // Moving the starting point back ensures it scans within the range in which the high/low was found by FractalUp/FractalDown condition. // Output by default is negative, make positive with absolute value for bar_index. // nz() forces a return of 1 in case bar_index comes back NaN // Adding the TFx_bar_index back in accounts for the number of bars skipped back in []. // First check if the number of bars back to scan for pivot high/low is going to be over the max bars back, and if so set the bar_index to the max bars back, otherwise get exact bar index value for pivot high/low. var int TF1_High_index = na var int TF1_Low_index = na var int TF2_High_index = na var int TF2_Low_index = na var int TF3_High_index = na var int TF3_Low_index = na var int TF4_High_index = na var int TF4_Low_index = na if TF1_bar_index + TF1_bar_index_range > 4999 TF1_High_index := 4999 TF1_Low_index := 4999 else TF1_High_index := math.abs(ta.highestbars(high, nz(TF1_bar_index_range, 1)))[TF1_bar_index] + TF1_bar_index TF1_Low_index := math.abs(ta.lowestbars(low, nz(TF1_bar_index_range, 1)))[TF1_bar_index] + TF1_bar_index if TF2_bar_index + TF2_bar_index_range > 4999 TF2_High_index := 4999 TF2_Low_index := 4999 else TF2_High_index := math.abs(ta.highestbars(high, nz(TF2_bar_index_range, 1)))[TF2_bar_index] + TF2_bar_index TF2_Low_index := math.abs(ta.lowestbars(low, nz(TF2_bar_index_range, 1)))[TF2_bar_index] + TF2_bar_index if TF3_bar_index + TF3_bar_index_range > 4999 TF3_High_index := 4999 TF3_Low_index := 4999 else TF3_High_index := math.abs(ta.highestbars(high, nz(TF3_bar_index_range, 1)))[TF3_bar_index] + TF3_bar_index TF3_Low_index := math.abs(ta.lowestbars(low, nz(TF3_bar_index_range, 1)))[TF3_bar_index] + TF3_bar_index if TF4_bar_index + TF4_bar_index_range > 4999 TF4_High_index := 4999 TF4_Low_index := 4999 else TF4_High_index := math.abs(ta.highestbars(high, nz(TF4_bar_index_range, 1)))[TF4_bar_index] + TF4_bar_index TF4_Low_index := math.abs(ta.lowestbars(low, nz(TF4_bar_index_range, 1)))[TF4_bar_index] + TF4_bar_index // TFUp and TFDown Calculations f_tfUp(_TF_High, _TF_Vol, _TF_VolMA) => _TF_High[3] > _TF_High[4] and _TF_High[4] > _TF_High[5] and _TF_High[2] < _TF_High[3] and _TF_High[1] < _TF_High[2] and _TF_Vol[3] > _TF_VolMA[3] f_tfDown(_TF_Low, _TF_Vol, _TF_VolMA) => _TF_Low[3] < _TF_Low[4] and _TF_Low[4] < _TF_Low[5] and _TF_Low[2] > _TF_Low[3] and _TF_Low[1] > _TF_Low[2] and _TF_Vol[3] > _TF_VolMA[3] // Provide function for each time frame's various sources used in FractalUp and FractalDown calculations. f_tfSources(_res, _source) => request.security(syminfo.tickerid, _res, _source) // S/R = Time Frame 1 = TF1 TF1_Vol = f_tfSources(TF1, volume) TF1_VolMA = ta.sma(TF1_Vol, TF1_VolMA1Input) TF1_High = f_tfSources(TF1, high) TF1_Low = f_tfSources(TF1, low) TF1_Open = f_tfSources(TF1, open) TF1_Close = f_tfSources(TF1, close) TF1_Up = f_tfUp(TF1_High, TF1_Vol, TF1_VolMA) TF1_Down = f_tfDown(TF1_Low, TF1_Vol, TF1_VolMA) TF1_CalcFractalUp() => TF1_FractalUp = 0.0 TF1_FractalUp := TF1_Up ? TF1_High[3] : TF1_FractalUp[1] TF1_FractalUp TF1_CalcFractalDown() => TF1_FractalDown = 0.0 TF1_FractalDown := TF1_Down ? TF1_Low[3] : TF1_FractalDown[1] TF1_FractalDown TF1_FractalUp = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUp()) TF1_FractalDown = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDown()) // Zones - Current Time Frame = Time Frame 1 = TF1 // Fractal Up Zones TF1_CalcFractalUpZone() => TF1_FractalUpZone = 0.0 TF1_FractalUpZone := TF1_Up and TF1_Close[3] >= TF1_Open[3] ? TF1_Close[3] : TF1_Up and TF1_Close[3] < TF1_Open[3] ? TF1_Open[3] : TF1_FractalUpZone[1] TF1_FractalUpZone TF1_FractalUpZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUpZone()) TF1_ResistanceZone = TF1_FractalUpZone // Fractal Down Zones TF1_CalcFractalDownZone() => TF1_FractalDownZone = 0.0 TF1_FractalDownZone := TF1_Down and TF1_Close[3] >= TF1_Open[3] ? TF1_Open[3] : TF1_Down and TF1_Close[3] < TF1_Open[3] ? TF1_Close[3] : TF1_FractalDownZone[1] TF1_FractalDownZone TF1_FractalDownZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDownZone()) TF1_SupportZone = TF1_FractalDownZone LineStyleHL = line.style_solid LineStyleClose = line.style_solid LineWidthHLInput = 3 LineWidthCloseInput = 3 label_loc = label.style_label_right label_offset = 15 // Time Frame 1 = TF1 Resistance var TF1_UpperResistanceLine_array = array.new_line(30) var TF1_LowerResistanceLine_array = array.new_line(30) var TF1ResLabel_array = array.new_label(1) if (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and TF1_FractalUp != TF1_FractalUp[1] and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF1_UpperResistanceLine = line.new(x1=TF1_input != 'Chart' ? bar_index[TF1_High_index] : bar_index[3], y1=TF1_FractalUp, x2=bar_index, y2=TF1_FractalUp, color=TF1_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF1_UpperResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_UpperResistanceLine_array, 29), x=TF1_input != 'Chart' ? bar_index[TF1_High_index] : bar_index[3]) array.push(TF1_UpperResistanceLine_array, TF1_UpperResistanceLine) line.delete(array.shift(TF1_UpperResistanceLine_array)) TF1_LowerResistanceLine = line.new(x1=TF1_input != 'Chart' ? bar_index[TF1_High_index] : bar_index[3], y1=TF1_ResistanceZone, x2=bar_index, y2=TF1_ResistanceZone, color=TF1_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF1_LowerResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_LowerResistanceLine_array, 29), x=TF1_input != 'Chart' ? bar_index[TF1_High_index] : bar_index[3]) array.push(TF1_LowerResistanceLine_array, TF1_LowerResistanceLine) line.delete(array.shift(TF1_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF1ResLabel = label.new(TF1_input != 'Chart' ? bar_index[TF1_High_index - 2] : bar_index[2], TF1_FractalUp, text=TF1_text + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF1_ResLinesColor) array.push(TF1ResLabel_array, TF1ResLabel) label.delete(array.shift(TF1ResLabel_array)) else if (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and na(TF1_FractalUp != TF1_FractalUp[1]) and chartOnLowerTF1 and na(ta.barssince(TF1_FractalUp != TF1_FractalUp[1])) and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF1_UpperResistanceLine = line.new(x1=bar_index[3], y1=TF1_FractalUp, x2=bar_index, y2=TF1_FractalUp, color=TF1_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF1_UpperResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_UpperResistanceLine_array, 29), x=bar_index[3]) array.push(TF1_UpperResistanceLine_array, TF1_UpperResistanceLine) line.delete(array.shift(TF1_UpperResistanceLine_array)) TF1_LowerResistanceLine = line.new(x1=bar_index[3], y1=TF1_ResistanceZone, x2=bar_index, y2=TF1_ResistanceZone, color=TF1_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF1_LowerResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_LowerResistanceLine_array, 29), x=bar_index[3]) array.push(TF1_LowerResistanceLine_array, TF1_LowerResistanceLine) line.delete(array.shift(TF1_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF1ResLabel = label.new(bar_index[3], TF1_FractalUp, text=TF1_text + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF1_ResLinesColor) array.push(TF1ResLabel_array, TF1ResLabel) label.delete(array.shift(TF1ResLabel_array)) if (TF1_Menu == 'S/R Zones') linefill.new(array.get(TF1_UpperResistanceLine_array, 29), array.get(TF1_LowerResistanceLine_array, 29), TF1_ResZoneColor) if ShowLabel == true and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 and label_loc == 'Right' TF1ResLabel = label.new(bar_index + label_offset, TF1_FractalUp, text=TF1_text + "(R)", size=size.normal, style=label.style_none, textcolor=TF1_ResLinesColor) array.push(TF1ResLabel_array, TF1ResLabel) label.delete(array.shift(TF1ResLabel_array)) // Time Frame 1 = TF1 Support var TF1_UpperSupportLine_array = array.new_line(30) var TF1_LowerSupportLine_array = array.new_line(30) var TF1SupLabel_array = array.new_label(1) if (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and TF1_FractalDown != TF1_FractalDown[1] and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF1_UpperSupportLine = line.new(x1=TF1_input != 'Chart' ? bar_index[TF1_Low_index] : bar_index[3], y1=TF1_SupportZone, x2=bar_index, y2=TF1_SupportZone, color=TF1_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF1_UpperSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_UpperSupportLine_array, 29), x=TF1_input != 'Chart' ? bar_index[TF1_Low_index] : bar_index[3]) array.push(TF1_UpperSupportLine_array, TF1_UpperSupportLine) line.delete(array.shift(TF1_UpperSupportLine_array)) TF1_LowerSupportLine = line.new(x1=TF1_input != 'Chart' ? bar_index[TF1_Low_index] : bar_index[3], y1=TF1_FractalDown, x2=bar_index, y2=TF1_FractalDown, color=TF1_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF1_LowerSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_LowerSupportLine_array, 29), x=TF1_input != 'Chart' ? bar_index[TF1_Low_index] : bar_index[3]) array.push(TF1_LowerSupportLine_array, TF1_LowerSupportLine) line.delete(array.shift(TF1_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF1SupLabel = label.new(TF1_input != 'Chart' ? bar_index[TF1_Low_index - 2] : bar_index[2], TF1_FractalDown, text=TF1_text + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF1_SupLinesColor) array.push(TF1SupLabel_array, TF1SupLabel) label.delete(array.shift(TF1SupLabel_array)) else if (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and na(TF1_FractalDown != TF1_FractalDown[1]) and chartOnLowerTF1 and na(ta.barssince(TF1_FractalDown != TF1_FractalDown[1])) and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF1_UpperSupportLine = line.new(x1=bar_index[3], y1=TF1_SupportZone, x2=bar_index, y2=TF1_SupportZone, color=TF1_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF1_UpperSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_UpperSupportLine_array, 29), x=bar_index[3]) array.push(TF1_UpperSupportLine_array, TF1_UpperSupportLine) line.delete(array.shift(TF1_UpperSupportLine_array)) TF1_LowerSupportLine = line.new(x1=bar_index[3], y1=TF1_FractalDown, x2=bar_index, y2=TF1_FractalDown, color=TF1_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF1_LowerSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF1_LowerSupportLine_array, 29), x=bar_index[3]) array.push(TF1_LowerSupportLine_array, TF1_LowerSupportLine) line.delete(array.shift(TF1_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF1SupLabel = label.new(bar_index[3], TF1_FractalDown, text=TF1_text + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF1_SupLinesColor) array.push(TF1SupLabel_array, TF1SupLabel) label.delete(array.shift(TF1SupLabel_array)) if (TF1_Menu == 'S/R Zones') linefill.new(array.get(TF1_UpperSupportLine_array, 29), array.get(TF1_LowerSupportLine_array, 29), TF1_SupZoneColor) if ShowLabel == true and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 and label_loc == 'Right' TF1SupLabel = label.new(bar_index + label_offset, TF1_FractalDown, text=TF1_text + "(S)", size=size.normal, style=label.style_none, textcolor=TF1_SupLinesColor) array.push(TF1SupLabel_array, TF1SupLabel) label.delete(array.shift(TF1SupLabel_array)) // S/R - Time Frame 2 = TF2 TF2_Vol = f_tfSources(TF2, volume) TF2_VolMA = ta.sma(TF2_Vol, TF2_VolMA1Input) TF2_High = f_tfSources(TF2, high) TF2_Low = f_tfSources(TF2, low) TF2_Open = f_tfSources(TF2, open) TF2_Close = f_tfSources(TF2, close) TF2_Up = f_tfUp(TF2_High, TF2_Vol, TF2_VolMA) TF2_Down = f_tfDown(TF2_Low, TF2_Vol, TF2_VolMA) TF2_CalcFractalUp() => TF2_FractalUp = 0.0 TF2_FractalUp := TF2_Up ? TF2_High[3] : TF2_FractalUp[1] TF2_FractalUp TF2_CalcFractalDown() => TF2_FractalDown = 0.0 TF2_FractalDown := TF2_Down ? TF2_Low[3] : TF2_FractalDown[1] TF2_FractalDown TF2_FractalUp = request.security(syminfo.tickerid, TF2, TF2_CalcFractalUp()) TF2_FractalDown = request.security(syminfo.tickerid, TF2, TF2_CalcFractalDown()) // Zones - Time Frame 2 = TF2 // Fractal Up Zones TF2_CalcFractalUpZone() => TF2_FractalUpZone = 0.0 TF2_FractalUpZone := TF2_Up and TF2_Close[3] >= TF2_Open[3] ? TF2_Close[3] : TF2_Up and TF2_Close[3] < TF2_Open[3] ? TF2_Open[3] : TF2_FractalUpZone[1] TF2_FractalUpZone TF2_FractalUpZone = request.security(syminfo.tickerid, TF2, TF2_CalcFractalUpZone()) TF2_ResistanceZone = TF2_FractalUpZone // Fractal Down Zones TF2_CalcFractalDownZone() => TF2_FractalDownZone = 0.0 TF2_FractalDownZone := TF2_Down and TF2_Close[3] >= TF2_Open[3] ? TF2_Open[3] : TF2_Down and TF2_Close[3] < TF2_Open[3] ? TF2_Close[3] : TF2_FractalDownZone[1] TF2_FractalDownZone TF2_FractalDownZone = request.security(syminfo.tickerid, TF2, TF2_CalcFractalDownZone()) TF2_SupportZone = TF2_FractalDownZone // Time Frame 2 = TF2 Resistance var TF2_UpperResistanceLine_array = array.new_line(30) var TF2_LowerResistanceLine_array = array.new_line(30) var TF2ResLabel_array = array.new_label(1) if (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and TF2_FractalUp != TF2_FractalUp[1] and chartOnLowerTF2 TF2_UpperResistanceLine = line.new(x1=bar_index[TF2_High_index], y1=TF2_FractalUp, x2=bar_index, y2=TF2_FractalUp, color=TF2_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF2_UpperResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_UpperResistanceLine_array, 29), x=bar_index[TF2_High_index]) array.push(TF2_UpperResistanceLine_array, TF2_UpperResistanceLine) line.delete(array.shift(TF2_UpperResistanceLine_array)) TF2_LowerResistanceLine = line.new(x1=bar_index[TF2_High_index], y1=TF2_ResistanceZone, x2=bar_index, y2=TF2_ResistanceZone, color=TF2_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF2_LowerResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_LowerResistanceLine_array, 29), x=bar_index[TF2_High_index]) array.push(TF2_LowerResistanceLine_array, TF2_LowerResistanceLine) line.delete(array.shift(TF2_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF2ResLabel = label.new(bar_index[TF2_High_index - 2], TF2_FractalUp, text=TF2_input + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF2_ResLinesColor) array.push(TF2ResLabel_array, TF2ResLabel) label.delete(array.shift(TF2ResLabel_array)) else if (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and na(TF2_FractalUp != TF2_FractalUp[1]) and chartOnLowerTF2 and na(ta.barssince(TF2_FractalUp != TF2_FractalUp[1])) TF2_UpperResistanceLine = line.new(x1=bar_index[3], y1=TF2_FractalUp, x2=bar_index, y2=TF2_FractalUp, color=TF2_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF2_UpperResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_UpperResistanceLine_array, 29), x=bar_index[3]) array.push(TF2_UpperResistanceLine_array, TF2_UpperResistanceLine) line.delete(array.shift(TF2_UpperResistanceLine_array)) TF2_LowerResistanceLine = line.new(x1=bar_index[3], y1=TF2_ResistanceZone, x2=bar_index, y2=TF2_ResistanceZone, color=TF2_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF2_LowerResistanceLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_LowerResistanceLine_array, 29), x=bar_index[3]) array.push(TF2_LowerResistanceLine_array, TF2_LowerResistanceLine) line.delete(array.shift(TF2_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF2ResLabel = label.new(bar_index[3], TF2_FractalUp, text=TF2_input + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF2_ResLinesColor) array.push(TF2ResLabel_array, TF2ResLabel) label.delete(array.shift(TF2ResLabel_array)) if (TF2_Menu == 'S/R Zones') linefill.new(array.get(TF2_UpperResistanceLine_array, 29), array.get(TF2_LowerResistanceLine_array, 29), TF2_ResZoneColor) if ShowLabel == true and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and label_loc == 'Right' TF2ResLabel = label.new(bar_index + label_offset, TF2_FractalUp, text=TF2_input + "(R)", size=size.normal, style=label.style_none, textcolor=TF2_ResLinesColor) array.push(TF2ResLabel_array, TF2ResLabel) label.delete(array.shift(TF2ResLabel_array)) // Time Frame 2 = TF2 Support var TF2_UpperSupportLine_array = array.new_line(30) var TF2_LowerSupportLine_array = array.new_line(30) var TF2SupLabel_array = array.new_label(1) if (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and TF2_FractalDown != TF2_FractalDown[1] and chartOnLowerTF2 TF2_UpperSupportLine = line.new(x1=bar_index[TF2_Low_index], y1=TF2_SupportZone, x2=bar_index, y2=TF2_SupportZone, color=TF2_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF2_UpperSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_UpperSupportLine_array, 29), x=bar_index[TF2_Low_index]) array.push(TF2_UpperSupportLine_array, TF2_UpperSupportLine) line.delete(array.shift(TF2_UpperSupportLine_array)) TF2_LowerSupportLine = line.new(x1=bar_index[TF2_Low_index], y1=TF2_FractalDown, x2=bar_index, y2=TF2_FractalDown, color=TF2_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF2_LowerSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_LowerSupportLine_array, 29), x=bar_index[TF2_Low_index]) array.push(TF2_LowerSupportLine_array, TF2_LowerSupportLine) line.delete(array.shift(TF2_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF2SupLabel = label.new(bar_index[TF2_Low_index - 2], TF2_FractalDown, text=TF2_input + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF2_SupLinesColor) array.push(TF2SupLabel_array, TF2SupLabel) label.delete(array.shift(TF2SupLabel_array)) else if (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and na(TF2_FractalDown != TF2_FractalDown[1]) and chartOnLowerTF2 and na(ta.barssince(TF2_FractalDown != TF2_FractalDown[1])) TF2_UpperSupportLine = line.new(x1=bar_index[3], y1=TF2_SupportZone, x2=bar_index, y2=TF2_SupportZone, color=TF2_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF2_UpperSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_UpperSupportLine_array, 29), x=bar_index[3]) array.push(TF2_UpperSupportLine_array, TF2_UpperSupportLine) line.delete(array.shift(TF2_UpperSupportLine_array)) TF2_LowerSupportLine = line.new(x1=bar_index[3], y1=TF2_FractalDown, x2=bar_index, y2=TF2_FractalDown, color=TF2_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF2_LowerSupportLine_array, 29), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF2_LowerSupportLine_array, 29), x=bar_index[3]) array.push(TF2_LowerSupportLine_array, TF2_LowerSupportLine) line.delete(array.shift(TF2_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF2SupLabel = label.new(bar_index[3], TF2_FractalDown, text=TF2_input + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF2_SupLinesColor) array.push(TF2SupLabel_array, TF2SupLabel) label.delete(array.shift(TF2SupLabel_array)) if (TF2_Menu == 'S/R Zones') linefill.new(array.get(TF2_UpperSupportLine_array, 29), array.get(TF2_LowerSupportLine_array, 29), TF2_SupZoneColor) if ShowLabel == true and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and label_loc == 'Right' TF2SupLabel = label.new(bar_index + label_offset, TF2_FractalDown, text=TF2_input + "(S)", size=size.normal, style=label.style_none, textcolor=TF2_SupLinesColor) array.push(TF2SupLabel_array, TF2SupLabel) label.delete(array.shift(TF2SupLabel_array)) // S/R - Time Frame 3 = TF3 TF3_Vol = f_tfSources(TF3, volume) TF3_VolMA = ta.sma(TF3_Vol, TF3_VolMA1Input) TF3_High = f_tfSources(TF3, high) TF3_Low = f_tfSources(TF3, low) TF3_Open = f_tfSources(TF3, open) TF3_Close = f_tfSources(TF3, close) TF3_Up = f_tfUp(TF3_High, TF3_Vol, TF3_VolMA) TF3_Down = f_tfDown(TF3_Low, TF3_Vol, TF3_VolMA) TF3_CalcFractalUp() => TF3_FractalUp = 0.0 TF3_FractalUp := TF3_Up ? TF3_High[3] : TF3_FractalUp[1] TF3_FractalUp TF3_CalcFractalDown() => TF3_FractalDown = 0.0 TF3_FractalDown := TF3_Down ? TF3_Low[3] : TF3_FractalDown[1] TF3_FractalDown TF3_FractalUp = request.security(syminfo.tickerid, TF3, TF3_CalcFractalUp()) TF3_FractalDown = request.security(syminfo.tickerid, TF3, TF3_CalcFractalDown()) // Zones - Time Frame 3 = TF3 // Fractal Up Zones TF3_CalcFractalUpZone() => TF3_FractalUpZone = 0.0 TF3_FractalUpZone := TF3_Up and TF3_Close[3] >= TF3_Open[3] ? TF3_Close[3] : TF3_Up and TF3_Close[3] < TF3_Open[3] ? TF3_Open[3] : TF3_FractalUpZone[1] TF3_FractalUpZone TF3_FractalUpZone = request.security(syminfo.tickerid, TF3, TF3_CalcFractalUpZone()) TF3_ResistanceZone = TF3_FractalUpZone // Fractal Down Zones TF3_CalcFractalDownZone() => TF3_FractalDownZone = 0.0 TF3_FractalDownZone := TF3_Down and TF3_Close[3] >= TF3_Open[3] ? TF3_Open[3] : TF3_Down and TF3_Close[3] < TF3_Open[3] ? TF3_Close[3] : TF3_FractalDownZone[1] TF3_FractalDownZone TF3_FractalDownZone = request.security(syminfo.tickerid, TF3, TF3_CalcFractalDownZone()) TF3_SupportZone = TF3_FractalDownZone // Time Frame 3 = TF3 Resistance var TF3_UpperResistanceLine_array = array.new_line(25) var TF3_LowerResistanceLine_array = array.new_line(25) var TF3ResLabel_array = array.new_label(1) if (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and TF3_FractalUp != TF3_FractalUp[1] and chartOnLowerTF3 TF3_UpperResistanceLine = line.new(x1=bar_index[TF3_High_index], y1=TF3_FractalUp, x2=bar_index, y2=TF3_FractalUp, color=TF3_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF3_UpperResistanceLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_UpperResistanceLine_array, 24), x=bar_index[TF3_High_index]) array.push(TF3_UpperResistanceLine_array, TF3_UpperResistanceLine) line.delete(array.shift(TF3_UpperResistanceLine_array)) TF3_LowerResistanceLine = line.new(x1=bar_index[TF3_High_index], y1=TF3_ResistanceZone, x2=bar_index, y2=TF3_ResistanceZone, color=TF3_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF3_LowerResistanceLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_LowerResistanceLine_array, 24), x=bar_index[TF3_High_index]) array.push(TF3_LowerResistanceLine_array, TF3_LowerResistanceLine) line.delete(array.shift(TF3_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF3ResLabel = label.new(bar_index[TF3_High_index - 2], TF3_FractalUp, text=TF3_input + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF3_ResLinesColor) array.push(TF3ResLabel_array, TF3ResLabel) label.delete(array.shift(TF3ResLabel_array)) else if (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and na(TF3_FractalUp != TF3_FractalUp[1]) and chartOnLowerTF3 and na(ta.barssince(TF3_FractalUp != TF3_FractalUp[1])) TF3_UpperResistanceLine = line.new(x1=bar_index[3], y1=TF3_FractalUp, x2=bar_index, y2=TF3_FractalUp, color=TF3_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF3_UpperResistanceLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_UpperResistanceLine_array, 24), x=bar_index[3]) array.push(TF3_UpperResistanceLine_array, TF3_UpperResistanceLine) line.delete(array.shift(TF3_UpperResistanceLine_array)) TF3_LowerResistanceLine = line.new(x1=bar_index[3], y1=TF3_ResistanceZone, x2=bar_index, y2=TF3_ResistanceZone, color=TF3_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF3_LowerResistanceLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_LowerResistanceLine_array, 24), x=bar_index[3]) array.push(TF3_LowerResistanceLine_array, TF3_LowerResistanceLine) line.delete(array.shift(TF3_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF3ResLabel = label.new(bar_index[3], TF3_FractalUp, text=TF3_input + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF3_ResLinesColor) array.push(TF3ResLabel_array, TF3ResLabel) label.delete(array.shift(TF3ResLabel_array)) if (TF3_Menu == 'S/R Zones') linefill.new(array.get(TF3_UpperResistanceLine_array, 24), array.get(TF3_LowerResistanceLine_array, 24), TF3_ResZoneColor) if ShowLabel == true and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and chartOnLowerTF3 and label_loc == 'Right' TF3ResLabel = label.new(bar_index + label_offset, TF3_FractalUp, text=TF3_input + "(R)", size=size.normal, style=label.style_none, textcolor=TF3_ResLinesColor) array.push(TF3ResLabel_array, TF3ResLabel) label.delete(array.shift(TF3ResLabel_array)) // Time Frame 3 = TF3 Support var TF3_UpperSupportLine_array = array.new_line(25) var TF3_LowerSupportLine_array = array.new_line(25) var TF3SupLabel_array = array.new_label(1) if (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and TF3_FractalDown != TF3_FractalDown[1] and chartOnLowerTF3 TF3_UpperSupportLine = line.new(x1=bar_index[TF3_Low_index], y1=TF3_SupportZone, x2=bar_index, y2=TF3_SupportZone, color=TF3_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF3_UpperSupportLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_UpperSupportLine_array, 24), x=bar_index[TF3_Low_index]) array.push(TF3_UpperSupportLine_array, TF3_UpperSupportLine) line.delete(array.shift(TF3_UpperSupportLine_array)) TF3_LowerSupportLine = line.new(x1=bar_index[TF3_Low_index], y1=TF3_FractalDown, x2=bar_index, y2=TF3_FractalDown, color=TF3_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF3_LowerSupportLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_LowerSupportLine_array, 24), x=bar_index[TF3_Low_index]) array.push(TF3_LowerSupportLine_array, TF3_LowerSupportLine) line.delete(array.shift(TF3_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF3SupLabel = label.new(bar_index[TF3_Low_index - 2], TF3_FractalDown, text=TF3_input + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF3_SupLinesColor) array.push(TF3SupLabel_array, TF3SupLabel) label.delete(array.shift(TF3SupLabel_array)) else if (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and na(TF3_FractalDown != TF3_FractalDown[1]) and chartOnLowerTF3 and na(ta.barssince(TF3_FractalDown != TF3_FractalDown[1])) TF3_UpperSupportLine = line.new(x1=bar_index[3], y1=TF3_SupportZone, x2=bar_index, y2=TF3_SupportZone, color=TF3_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF3_UpperSupportLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_UpperSupportLine_array, 24), x=bar_index[3]) array.push(TF3_UpperSupportLine_array, TF3_UpperSupportLine) line.delete(array.shift(TF3_UpperSupportLine_array)) TF3_LowerSupportLine = line.new(x1=bar_index[3], y1=TF3_FractalDown, x2=bar_index, y2=TF3_FractalDown, color=TF3_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF3_LowerSupportLine_array, 24), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF3_LowerSupportLine_array, 24), x=bar_index[3]) array.push(TF3_LowerSupportLine_array, TF3_LowerSupportLine) line.delete(array.shift(TF3_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF3SupLabel = label.new(bar_index[3], TF3_FractalDown, text=TF3_input + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF3_SupLinesColor) array.push(TF3SupLabel_array, TF3SupLabel) label.delete(array.shift(TF3SupLabel_array)) if (TF3_Menu == 'S/R Zones') linefill.new(array.get(TF3_UpperSupportLine_array, 24), array.get(TF3_LowerSupportLine_array, 24), TF3_SupZoneColor) if ShowLabel == true and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and chartOnLowerTF3 and label_loc == 'Right' TF3SupLabel = label.new(bar_index + label_offset, TF3_FractalDown, text=TF3_input + "(S)", size=size.normal, style=label.style_none, textcolor=TF3_SupLinesColor) array.push(TF3SupLabel_array, TF3SupLabel) label.delete(array.shift(TF3SupLabel_array)) // S/R - Time Frame 4 = TF4 TF4_Vol = f_tfSources(TF4, volume) TF4_VolMA = ta.sma(TF4_Vol, TF4_VolMA1Input) TF4_High = f_tfSources(TF4, high) TF4_Low = f_tfSources(TF4, low) TF4_Open = f_tfSources(TF4, open) TF4_Close = f_tfSources(TF4, close) TF4_Up = f_tfUp(TF4_High, TF4_Vol, TF4_VolMA) TF4_Down = f_tfDown(TF4_Low, TF4_Vol, TF4_VolMA) TF4_CalcFractalUp() => TF4_FractalUp = 0.0 TF4_FractalUp := TF4_Up ? TF4_High[3] : TF4_FractalUp[1] TF4_FractalUp TF4_CalcFractalDown() => TF4_FractalDown = 0.0 TF4_FractalDown := TF4_Down ? TF4_Low[3] : TF4_FractalDown[1] TF4_FractalDown TF4_FractalUp = request.security(syminfo.tickerid, TF4, TF4_CalcFractalUp()) TF4_FractalDown = request.security(syminfo.tickerid, TF4, TF4_CalcFractalDown()) // Zones - Time Frame 4 = TF4 // Fractal Up Zones TF4_CalcFractalUpZone() => TF4_FractalUpZone = 0.0 TF4_FractalUpZone := TF4_Up and TF4_Close[3] >= TF4_Open[3] ? TF4_Close[3] : TF4_Up and TF4_Close[3] < TF4_Open[3] ? TF4_Open[3] : TF4_FractalUpZone[1] TF4_FractalUpZone TF4_FractalUpZone = request.security(syminfo.tickerid, TF4, TF4_CalcFractalUpZone()) TF4_ResistanceZone = TF4_FractalUpZone // Fractal Down Zones TF4_CalcFractalDownZone() => TF4_FractalDownZone = 0.0 TF4_FractalDownZone := TF4_Down and TF4_Close[3] >= TF4_Open[3] ? TF4_Open[3] : TF4_Down and TF4_Close[3] < TF4_Open[3] ? TF4_Close[3] : TF4_FractalDownZone[1] TF4_FractalDownZone TF4_FractalDownZone = request.security(syminfo.tickerid, TF4, TF4_CalcFractalDownZone()) TF4_SupportZone = TF4_FractalDownZone // Time Frame 4 = TF4 Resistance var TF4_UpperResistanceLine_array = array.new_line(20) var TF4_LowerResistanceLine_array = array.new_line(20) var TF4ResLabel_array = array.new_label(1) if (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and TF4_FractalUp != TF4_FractalUp[1] and chartOnLowerTF4 TF4_UpperResistanceLine = line.new(x1=bar_index[TF4_High_index], y1=TF4_FractalUp, x2=bar_index, y2=TF4_FractalUp, color=TF4_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF4_UpperResistanceLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_UpperResistanceLine_array, 19), x=bar_index[TF4_High_index]) array.push(TF4_UpperResistanceLine_array, TF4_UpperResistanceLine) line.delete(array.shift(TF4_UpperResistanceLine_array)) TF4_LowerResistanceLine = line.new(x1=bar_index[TF4_High_index], y1=TF4_ResistanceZone, x2=bar_index, y2=TF4_ResistanceZone, color=TF4_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF4_LowerResistanceLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_LowerResistanceLine_array, 19), x=bar_index[TF4_High_index]) array.push(TF4_LowerResistanceLine_array, TF4_LowerResistanceLine) line.delete(array.shift(TF4_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF4ResLabel = label.new(bar_index[TF4_High_index - 2], TF4_FractalUp, text=TF4_input + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF4_ResLinesColor) array.push(TF4ResLabel_array, TF4ResLabel) label.delete(array.shift(TF4ResLabel_array)) else if (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and na(TF4_FractalUp != TF4_FractalUp[1]) and chartOnLowerTF4 and na(ta.barssince(TF4_FractalUp != TF4_FractalUp[1])) TF4_UpperResistanceLine = line.new(x1=bar_index[3], y1=TF4_FractalUp, x2=bar_index, y2=TF4_FractalUp, color=TF4_ResLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF4_UpperResistanceLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_UpperResistanceLine_array, 19), x=bar_index[3]) array.push(TF4_UpperResistanceLine_array, TF4_UpperResistanceLine) line.delete(array.shift(TF4_UpperResistanceLine_array)) TF4_LowerResistanceLine = line.new(x1=bar_index[3], y1=TF4_ResistanceZone, x2=bar_index, y2=TF4_ResistanceZone, color=TF4_ResLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF4_LowerResistanceLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_LowerResistanceLine_array, 19), x=bar_index[3]) array.push(TF4_LowerResistanceLine_array, TF4_LowerResistanceLine) line.delete(array.shift(TF4_LowerResistanceLine_array)) if ShowLabel == true and label_loc == 'Left' TF4ResLabel = label.new(bar_index[3], TF4_FractalUp, text=TF4_input + "(R)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF4_ResLinesColor) array.push(TF4ResLabel_array, TF4ResLabel) label.delete(array.shift(TF4ResLabel_array)) if (TF4_Menu == 'S/R Zones') linefill.new(array.get(TF4_UpperResistanceLine_array, 19), array.get(TF4_LowerResistanceLine_array, 19), TF4_ResZoneColor) if ShowLabel == true and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and chartOnLowerTF4 and label_loc == 'Right' TF4ResLabel = label.new(bar_index + label_offset, TF4_FractalUp, text=TF4_input + "(R)", size=size.normal, style=label.style_none, textcolor=TF4_ResLinesColor) array.push(TF4ResLabel_array, TF4ResLabel) label.delete(array.shift(TF4ResLabel_array)) // Time Frame 4 = TF4 Support var TF4_UpperSupportLine_array = array.new_line(20) var TF4_LowerSupportLine_array = array.new_line(20) var TF4SupLabel_array = array.new_label(1) if (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and TF4_FractalDown != TF4_FractalDown[1] and chartOnLowerTF4 TF4_UpperSupportLine = line.new(x1=bar_index[TF4_Low_index], y1=TF4_SupportZone, x2=bar_index, y2=TF4_SupportZone, color=TF4_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF4_UpperSupportLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_UpperSupportLine_array, 19), x=bar_index[TF4_Low_index]) array.push(TF4_UpperSupportLine_array, TF4_UpperSupportLine) line.delete(array.shift(TF4_UpperSupportLine_array)) TF4_LowerSupportLine = line.new(x1=bar_index[TF4_Low_index], y1=TF4_FractalDown, x2=bar_index, y2=TF4_FractalDown, color=TF4_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF4_LowerSupportLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_LowerSupportLine_array, 19), x=bar_index[TF4_Low_index]) array.push(TF4_LowerSupportLine_array, TF4_LowerSupportLine) line.delete(array.shift(TF4_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF4SupLabel = label.new(bar_index[TF4_Low_index - 2], TF4_FractalDown, text=TF4_input + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF4_SupLinesColor) array.push(TF4SupLabel_array, TF4SupLabel) label.delete(array.shift(TF4SupLabel_array)) else if (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and na(TF4_FractalDown != TF4_FractalDown[1]) and chartOnLowerTF4 and na(ta.barssince(TF4_FractalDown != TF4_FractalDown[1])) TF4_UpperSupportLine = line.new(x1=bar_index[3], y1=TF4_SupportZone, x2=bar_index, y2=TF4_SupportZone, color=TF4_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF4_UpperSupportLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_UpperSupportLine_array, 19), x=bar_index[3]) array.push(TF4_UpperSupportLine_array, TF4_UpperSupportLine) line.delete(array.shift(TF4_UpperSupportLine_array)) TF4_LowerSupportLine = line.new(x1=bar_index[3], y1=TF4_FractalDown, x2=bar_index, y2=TF4_FractalDown, color=TF4_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF4_LowerSupportLine_array, 19), extend=extend.none) if ExtendLines == true line.set_x2(id=array.get(TF4_LowerSupportLine_array, 19), x=bar_index[3]) array.push(TF4_LowerSupportLine_array, TF4_LowerSupportLine) line.delete(array.shift(TF4_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' TF4SupLabel = label.new(bar_index[3], TF4_FractalDown, text=TF4_input + "(S)", color=color.new(color.white, 100), size=size.normal, style=label.style_label_right, textcolor=TF4_SupLinesColor) array.push(TF4SupLabel_array, TF4SupLabel) label.delete(array.shift(TF4SupLabel_array)) if (TF4_Menu == 'S/R Zones') linefill.new(array.get(TF4_UpperSupportLine_array, 19), array.get(TF4_LowerSupportLine_array, 19), TF4_SupZoneColor) if ShowLabel == true and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and chartOnLowerTF4 and label_loc == 'Right' TF4SupLabel = label.new(bar_index + label_offset, TF4_FractalDown, text=TF4_input + "(S)", size=size.normal, style=label.style_none, textcolor=TF4_SupLinesColor) array.push(TF4SupLabel_array, TF4SupLabel) label.delete(array.shift(TF4SupLabel_array)) // ---------- The following lines modify the labels when there is the same S/R zone found on 2 different time frames, to combine both into one label and take the color of the higher time frame. // ---------- This prevents 2 labels from being displayed on top of each other. For left labels, extra lines are required to reset the labels back to their original form once the SR changes for the lower time frame. if label_loc == 'Right' if TF4_FractalUp == TF3_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and chartOnLowerTF3 and not chartEqualTF4 label.set_textcolor(id=array.get(TF3ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF3_input + '/' + TF4_input + "(R)") if TF4_FractalUp == TF2_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF4 label.set_textcolor(id=array.get(TF2ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF2_input + '/' + TF4_input + "(R)") if TF4_FractalUp == TF1_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF4 and not chartEqualTF4 label.set_textcolor(id=array.get(TF1ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF1_text + '/' + TF4_input + "(R)") if TF3_FractalUp == TF2_FractalUp and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF3 label.set_textcolor(id=array.get(TF2ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3ResLabel_array, 0), text=TF2_input + '/' + TF3_input + "(R)") if TF3_FractalUp == TF1_FractalUp and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF3 and not chartEqualTF3 label.set_textcolor(id=array.get(TF1ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3ResLabel_array, 0), text=TF1_text + '/' + TF3_input + "(R)") if TF2_FractalUp == TF1_FractalUp and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF2 and not chartEqualTF2 label.set_textcolor(id=array.get(TF1ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF2ResLabel_array, 0), text=TF1_text + '/' + TF2_input + "(R)") if TF4_FractalDown == TF3_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and chartOnLowerTF3 and not chartEqualTF4 label.set_textcolor(id=array.get(TF3SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF3_input + '/' + TF4_input + "(S)") if TF4_FractalDown == TF2_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF4 label.set_textcolor(id=array.get(TF2SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF2_input + '/' + TF4_input + "(S)") if TF4_FractalDown == TF1_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF4 and not chartEqualTF4 label.set_textcolor(id=array.get(TF1SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF1_text + '/' + TF4_input + "(S)") if TF3_FractalDown == TF2_FractalDown and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF3 label.set_textcolor(id=array.get(TF2SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3SupLabel_array, 0), text=TF2_input + '/' + TF3_input + "(S)") if TF3_FractalDown == TF1_FractalDown and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF3 and not chartEqualTF3 label.set_textcolor(id=array.get(TF1SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3SupLabel_array, 0), text=TF1_text + '/' + TF3_input + "(S)") if TF2_FractalDown == TF1_FractalDown and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF2 and not chartEqualTF2 label.set_textcolor(id=array.get(TF1SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF2SupLabel_array, 0), text=TF1_text + '/' + TF2_input + "(S)") // Left Labels if label_loc == 'Left' if TF4_FractalUp == TF3_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and chartOnLowerTF3 and not chartEqualTF4 label.set_textcolor(id=array.get(TF3ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF3_input + '/' + TF4_input + "(R)") if TF4_FractalUp[1] == TF3_FractalUp[1] and TF4_FractalUp != TF3_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF4_input + "(R)") if TF4_FractalUp == TF2_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF4 label.set_textcolor(id=array.get(TF2ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF2_input + '/' + TF4_input + "(R)") if TF4_FractalUp[1] == TF2_FractalUp[1] and TF4_FractalUp != TF2_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF4_input + "(R)") if TF4_FractalUp == TF1_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF4 and not chartEqualTF4 label.set_textcolor(id=array.get(TF1ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF1_text + '/' + TF4_input + "(R)") if TF4_FractalUp[1] == TF1_FractalUp[1] and TF4_FractalUp != TF1_FractalUp and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') label.set_text(id=array.get(TF4ResLabel_array, 0), text=TF4_input + "(R)") if TF3_FractalUp == TF2_FractalUp and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF3 label.set_textcolor(id=array.get(TF2ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3ResLabel_array, 0), text=TF2_input + '/' + TF3_input + "(R)") if TF3_FractalUp[1] == TF2_FractalUp[1] and TF3_FractalUp != TF2_FractalUp and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') label.set_text(id=array.get(TF3ResLabel_array, 0), text=TF3_input + "(R)") if TF3_FractalUp == TF1_FractalUp and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF3 and not chartEqualTF3 label.set_textcolor(id=array.get(TF1ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3ResLabel_array, 0), text=TF1_text + '/' + TF3_input + "(R)") if TF3_FractalUp[1] == TF1_FractalUp[1] and TF3_FractalUp != TF1_FractalUp and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') label.set_text(id=array.get(TF3ResLabel_array, 0), text=TF3_input + "(R)") if TF2_FractalUp == TF1_FractalUp and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF2 and not chartEqualTF2 label.set_textcolor(id=array.get(TF1ResLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF2ResLabel_array, 0), text=TF1_text + '/' + TF2_input + "(R)") if TF2_FractalUp[1] == TF1_FractalUp[1] and TF2_FractalUp != TF1_FractalUp and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') label.set_text(id=array.get(TF2ResLabel_array, 0), text=TF2_input + "(R)") if TF4_FractalDown == TF3_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and chartOnLowerTF3 and not chartEqualTF4 label.set_textcolor(id=array.get(TF3SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF3_input + '/' + TF4_input + "(S)") if TF4_FractalDown[1] == TF3_FractalDown[1] and TF4_FractalDown != TF3_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF4_input + "(S)") if TF4_FractalDown == TF2_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF4 label.set_textcolor(id=array.get(TF2SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF2_input + '/' + TF4_input + "(S)") if TF4_FractalDown[1] == TF2_FractalDown[1] and TF4_FractalDown != TF2_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF4_input + "(S)") if TF4_FractalDown == TF1_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF4 and not chartEqualTF4 label.set_textcolor(id=array.get(TF1SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF1_text + '/' + TF4_input + "(S)") if TF4_FractalDown[1] == TF1_FractalDown[1] and TF4_FractalDown != TF1_FractalDown and (TF4_Menu == 'S/R Zones' or TF4_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') label.set_text(id=array.get(TF4SupLabel_array, 0), text=TF4_input + "(S)") if TF3_FractalDown == TF2_FractalDown and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and chartOnLowerTF2 and not chartEqualTF3 label.set_textcolor(id=array.get(TF2SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3SupLabel_array, 0), text=TF2_input + '/' + TF3_input + "(S)") if TF3_FractalDown[1] == TF2_FractalDown[1] and TF2_FractalDown != TF3_FractalDown and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') label.set_text(id=array.get(TF3SupLabel_array, 0), text=TF3_input + "(S)") if TF3_FractalDown == TF1_FractalDown and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF3 and not chartEqualTF3 label.set_textcolor(id=array.get(TF1SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF3SupLabel_array, 0), text=TF1_text + '/' + TF3_input + "(S)") if TF3_FractalDown[1] == TF1_FractalDown[1] and TF3_FractalDown != TF1_FractalDown and (TF3_Menu == 'S/R Zones' or TF3_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') label.set_text(id=array.get(TF3SupLabel_array, 0), text=TF3_input + "(S)") if TF2_FractalDown == TF1_FractalDown and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') and chartOnLowerTF1 and chartOnLowerTF2 and not chartEqualTF2 label.set_textcolor(id=array.get(TF1SupLabel_array, 0), textcolor=color.new(color.white, 100)) label.set_text(id=array.get(TF2SupLabel_array, 0), text=TF1_text + '/' + TF2_input + "(S)") if TF2_FractalDown[1] == TF1_FractalDown[1] and TF2_FractalDown != TF1_FractalDown and (TF2_Menu == 'S/R Zones' or TF2_Menu == 'S/R') and (TF1_Menu == 'S/R Zones' or TF1_Menu == 'S/R') label.set_text(id=array.get(TF2SupLabel_array, 0), text=TF2_input + "(S)") // FILTROS DE ENTRADA E SAIDA ============================================================================================================ //filtro_vol_hATRLb = i_hATRLb == true and ta.crossover(range_1, i_weightedATR) ///filtro_vol_i_vSpikeLb = i_vSpikeLb == true and ta.crossover(nzVolume, i_vSMA * i_vSpikeThresh) //filtro_vol_i_vwcb_bull = i_vwcb == true and nzVolume > i_vSMA * i_vwcbHighThresh //filtro_vol_i_vwcb_bear = i_vwcb == true and nzVolume < i_vSMA * i_vwcbLowThresh //filtro_vol_i_vSMA = i_vSMA_bool == true and exhaustVol // ---------------- DIREÇÃO DA BARRA numerodebar_ONOFF = input(true, title="Filtro de direção de barra",inline='5') numerodebar_TF1 = input.int(defval=2, minval=2, title="Filtro de Confirmação de Candles a favor da Tendencia",inline='5') bar_conf_verde_TF1 = ta.highestbars(close, numerodebar_TF1) == true bar_conf_vermelha_TF1 = ta.lowestbars(close, numerodebar_TF1)== true // LOGICA DA ESTRATEGIA ============================================================================================================ // ---------------- Alerts // TF1 PriceEntersTF1ResZone = ta.crossover(close, TF1_ResistanceZone) PriceTestResAsSupportTF1 = ta.crossunder(close, TF1_FractalUp) PriceEntersTF1SupZone = ta.crossunder(close, TF1_SupportZone) PriceTestSupportAsResTF1 = ta.crossover(close, TF1_FractalDown) PriceBreakingTF1Resistance = ta.crossover(close, TF1_FractalUp) PriceBreakingTF1Support = ta.crossunder(close, TF1_FractalDown) NewResFoundTF1 = TF1_FractalUp != TF1_FractalUp[1] NewSupFoundTF1 = TF1_FractalDown != TF1_FractalDown[1] PriceBreakingNewResFoundTF1 = ta.crossover(close, TF1_FractalUp) != TF1_FractalUp[1] PriceBreakingNewSupFoundTF1 = ta.crossunder(close, TF1_FractalDown) != TF1_FractalDown[1] venda_resistencia_TF1= (TF1_Alerts == 'Zona de Resistência - Venda Forte' or TF1_Alerts == 'All Alerts On') and PriceEntersTF1ResZone alert(syminfo.ticker + ' - Price enters ' + TF1_input + ' Resistance Zone', alert.freq_once_per_bar) compra_resistencia_vira_suporte_TF1 =(TF1_Alerts == 'Ropi. da Resistência - Compra' or TF1_Alerts == 'All Alerts On') and PriceTestResAsSupportTF1 alert(syminfo.ticker + ' - Price is testing ' + TF1_input + ' resistance as support', alert.freq_once_per_bar) compra_suporte_TF1=(TF1_Alerts == 'Zona de Suporte - Compra Forte' or TF1_Alerts == 'All Alerts On') and PriceEntersTF1SupZone alert(syminfo.ticker + ' - Price enters ' + TF1_input + ' Support Zone', alert.freq_once_per_bar) venda_suporte_vira_resistencia_TF1= (TF1_Alerts == 'Ropi. do Suporte - Venda' or TF1_Alerts == 'All Alerts On') and PriceTestSupportAsResTF1 alert(syminfo.ticker + ' - Price is testing ' + TF1_input + ' support as resistance', alert.freq_once_per_bar) compra_rompimento_resistencia_TF1= (TF1_Alerts == 'Rompi. da Zona de Resistecia - Compra Forte' or TF1_Alerts == 'All Alerts On') and PriceBreakingTF1Resistance alert(syminfo.ticker + ' - Price is breaking out ' + TF1_input + ' Resistance', alert.freq_once_per_bar) venda_rompimento_suporte_TF1 = (TF1_Alerts == 'Rompi. da Zona de Suporte - Venda Forte' or TF1_Alerts == 'All Alerts On') and PriceBreakingTF1Support alert(syminfo.ticker + ' - Price is breaking down ' + TF1_input + ' Support', alert.freq_once_per_bar) venda_nova_resistencia_TF1 = (TF1_Alerts == 'Nova Resistencia - Venda?' or TF1_Alerts == 'All Alerts On') and NewResFoundTF1 alert(syminfo.ticker + ' - New ' + TF1_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_rompimento_nova_resistencia_TF1 = (TF1_Alerts == 'Rompi. Nova Resistencia - Ideal Compra' or TF1_Alerts == 'All Alerts On') and PriceBreakingNewResFoundTF1 alert(syminfo.ticker + ' - New ' + TF1_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_novo_suporte_TF1 = (TF1_Alerts == 'Novo Suporte - Compra?' or TF1_Alerts == 'All Alerts On') and NewSupFoundTF1 alert(syminfo.ticker + ' - New ' + TF1_input + ' Support Zone Found', alert.freq_once_per_bar) venda_rompimento_novo_suporte_TF1 = (TF1_Alerts == 'Rompi. Novo Suporte - Ideal Venda' or TF1_Alerts == 'All Alerts On') and PriceBreakingNewSupFoundTF1 alert(syminfo.ticker + ' - New ' + TF1_input + ' Resistance Zone Found', alert.freq_once_per_bar) venda_desativa_TF1 = (TF1_Alerts == 'None') and not PriceEntersTF1ResZone and not PriceTestResAsSupportTF1 and not PriceEntersTF1SupZone and not PriceTestSupportAsResTF1 and not PriceBreakingTF1Resistance and not venda_nova_resistencia_TF1 and not compra_novo_suporte_TF1 and not venda_rompimento_novo_suporte_TF1 and not compra_novo_suporte_TF1 and not compra_rompimento_nova_resistencia_TF1 and not venda_nova_resistencia_TF1 // TF2 PriceEntersTF2ResZone = ta.crossover(close, TF2_ResistanceZone) PriceTestResAsSupportTF2 = ta.crossunder(close, TF2_FractalUp) PriceEntersTF2SupZone = ta.crossunder(close, TF2_SupportZone) PriceTestSupportAsResTF2 = ta.crossover(close, TF2_FractalDown) PriceBreakingTF2Resistance = ta.crossover(close, TF2_FractalUp) PriceBreakingTF2Support = ta.crossunder(close, TF2_FractalDown) NewResFoundTF2 = TF2_FractalUp != TF2_FractalUp[1] NewSupFoundTF2 = TF2_FractalDown != TF2_FractalDown[1] PriceBreakingNewResFoundTF2 = ta.crossover(close, TF2_FractalUp) != TF2_FractalUp[1] PriceBreakingNewSupFoundTF2 = ta.crossunder(close, TF2_FractalDown) != TF2_FractalDown[1] venda_resistencia_TF2= (TF2_Alerts == 'Zona de Resistência - Venda Forte' or TF2_Alerts == 'All Alerts On') and PriceEntersTF2ResZone alert(syminfo.ticker + ' - Price enters ' + TF2_input + ' Resistance Zone', alert.freq_once_per_bar) compra_resistencia_vira_suporte_TF2 =(TF2_Alerts == 'Ropi. da Resistência - Compra' or TF2_Alerts == 'All Alerts On') and PriceTestResAsSupportTF2 alert(syminfo.ticker + ' - Price is testing ' + TF2_input + ' resistance as support', alert.freq_once_per_bar) compra_suporte_TF2=(TF2_Alerts == 'Zona de Suporte - Compra Forte' or TF2_Alerts == 'All Alerts On') and PriceEntersTF2SupZone alert(syminfo.ticker + ' - Price enters ' + TF2_input + ' Support Zone', alert.freq_once_per_bar) venda_suporte_vira_resistencia_TF2= (TF2_Alerts == 'Ropi. do Suporte - Venda' or TF2_Alerts == 'All Alerts On') and PriceTestSupportAsResTF2 alert(syminfo.ticker + ' - Price is testing ' + TF2_input + ' support as resistance', alert.freq_once_per_bar) compra_rompimento_resistencia_TF2= (TF2_Alerts == 'Rompi. da Zona de Resistecia - Compra Forte' or TF2_Alerts == 'All Alerts On') and PriceBreakingTF2Resistance alert(syminfo.ticker + ' - Price is breaking out ' + TF2_input + ' Resistance', alert.freq_once_per_bar) venda_rompimento_suporte_TF2 = (TF2_Alerts == 'Rompi. da Zona de Suporte - Venda Forte' or TF2_Alerts == 'All Alerts On') and PriceBreakingTF2Support alert(syminfo.ticker + ' - Price is breaking down ' + TF2_input + ' Support', alert.freq_once_per_bar) venda_nova_resistencia_TF2 = (TF2_Alerts == 'Nova Resistencia - Venda?' or TF2_Alerts == 'All Alerts On') and NewResFoundTF2 alert(syminfo.ticker + ' - New ' + TF2_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_rompimento_nova_resistencia_TF2 = (TF2_Alerts == 'Rompi. Nova Resistencia - Ideal Compra' or TF2_Alerts == 'All Alerts On') and PriceBreakingNewResFoundTF2 alert(syminfo.ticker + ' - New ' + TF2_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_novo_suporte_TF2 = (TF2_Alerts == 'Novo Suporte - Compra?' or TF2_Alerts == 'All Alerts On') and NewSupFoundTF2 alert(syminfo.ticker + ' - New ' + TF2_input + ' Support Zone Found', alert.freq_once_per_bar) venda_rompimento_novo_suporte_TF2 = (TF2_Alerts == 'Rompi. Novo Suporte - Ideal Venda' or TF2_Alerts == 'All Alerts On') and PriceBreakingNewSupFoundTF2 alert(syminfo.ticker + ' - New ' + TF2_input + ' Resistance Zone Found', alert.freq_once_per_bar) venda_desativa_TF2 = (TF2_Alerts == 'None') and not PriceEntersTF2ResZone and not PriceTestResAsSupportTF2 and not PriceEntersTF2SupZone and not PriceTestSupportAsResTF2 and not PriceBreakingTF2Resistance and not venda_nova_resistencia_TF2 and not compra_novo_suporte_TF2 and not venda_rompimento_novo_suporte_TF2 and not compra_novo_suporte_TF2 and not compra_rompimento_nova_resistencia_TF2 and not venda_nova_resistencia_TF2 // TF3 PriceEntersTF3ResZone = ta.crossover(close, TF3_ResistanceZone) PriceTestResAsSupportTF3 = ta.crossunder(close, TF3_FractalUp) PriceEntersTF3SupZone = ta.crossunder(close, TF3_SupportZone) PriceTestSupportAsResTF3 = ta.crossover(close, TF3_FractalDown) PriceBreakingTF3Resistance = ta.crossover(close, TF3_FractalUp) PriceBreakingTF3Support = ta.crossunder(close, TF3_FractalDown) NewResFoundTF3 = TF3_FractalUp != TF3_FractalUp[1] NewSupFoundTF3 = TF3_FractalDown != TF3_FractalDown[1] PriceBreakingNewResFoundTF3 = ta.crossover(close, TF3_FractalUp) != TF3_FractalUp[1] PriceBreakingNewSupFoundTF3 = ta.crossunder(close, TF3_FractalDown) != TF3_FractalDown[1] venda_resistencia_TF3= (TF3_Alerts == 'Zona de Resistência - Venda Forte' or TF3_Alerts == 'All Alerts On') and PriceEntersTF3ResZone alert(syminfo.ticker + ' - Price enters ' + TF3_input + ' Resistance Zone', alert.freq_once_per_bar) compra_resistencia_vira_suporte_TF3 =(TF3_Alerts == 'Ropi. da Resistência - Compra' or TF3_Alerts == 'All Alerts On') and PriceTestResAsSupportTF3 alert(syminfo.ticker + ' - Price is testing ' + TF3_input + ' resistance as support', alert.freq_once_per_bar) compra_suporte_TF3=(TF3_Alerts == 'Zona de Suporte - Compra Forte' or TF3_Alerts == 'All Alerts On') and PriceEntersTF3SupZone alert(syminfo.ticker + ' - Price enters ' + TF3_input + ' Support Zone', alert.freq_once_per_bar) venda_suporte_vira_resistencia_TF3= (TF3_Alerts == 'Ropi. do Suporte - Venda' or TF3_Alerts == 'All Alerts On') and PriceTestSupportAsResTF3 alert(syminfo.ticker + ' - Price is testing ' + TF3_input + ' support as resistance', alert.freq_once_per_bar) compra_rompimento_resistencia_TF3= (TF3_Alerts == 'Rompi. da Zona de Resistecia - Compra Forte' or TF3_Alerts == 'All Alerts On') and PriceBreakingTF3Resistance alert(syminfo.ticker + ' - Price is breaking out ' + TF3_input + ' Resistance', alert.freq_once_per_bar) venda_rompimento_suporte_TF3 = (TF3_Alerts == 'Rompi. da Zona de Suporte - Venda Forte' or TF3_Alerts == 'All Alerts On') and PriceBreakingTF3Support alert(syminfo.ticker + ' - Price is breaking down ' + TF3_input + ' Support', alert.freq_once_per_bar) venda_nova_resistencia_TF3 = (TF3_Alerts == 'Nova Resistencia - Venda?' or TF3_Alerts == 'All Alerts On') and NewResFoundTF3 alert(syminfo.ticker + ' - New ' + TF3_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_rompimento_nova_resistencia_TF3 = (TF3_Alerts == 'Rompi. Nova Resistencia - Ideal Compra' or TF3_Alerts == 'All Alerts On') and PriceBreakingNewResFoundTF3 alert(syminfo.ticker + ' - New ' + TF3_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_novo_suporte_TF3 = (TF3_Alerts == 'Novo Suporte - Compra?' or TF3_Alerts == 'All Alerts On') and NewSupFoundTF3 alert(syminfo.ticker + ' - New ' + TF3_input + ' Support Zone Found', alert.freq_once_per_bar) venda_rompimento_novo_suporte_TF3 = (TF3_Alerts == 'Rompi. Novo Suporte - Ideal Venda' or TF3_Alerts == 'All Alerts On') and PriceBreakingNewSupFoundTF3 alert(syminfo.ticker + ' - New ' + TF3_input + ' Resistance Zone Found', alert.freq_once_per_bar) venda_desativa_TF3 = (TF3_Alerts == 'None') and not PriceEntersTF3ResZone and not PriceTestResAsSupportTF3 and not PriceEntersTF3SupZone and not PriceTestSupportAsResTF3 and not PriceBreakingTF3Resistance and not venda_nova_resistencia_TF3 and not compra_novo_suporte_TF3 and not venda_rompimento_novo_suporte_TF3 and not compra_novo_suporte_TF3 and not compra_rompimento_nova_resistencia_TF3 and not venda_nova_resistencia_TF3 // TF4 PriceEntersTF4ResZone = ta.crossover(close, TF4_ResistanceZone) PriceTestResAsSupportTF4 = ta.crossunder(close, TF4_FractalUp) PriceEntersTF4SupZone = ta.crossunder(close, TF4_SupportZone) PriceTestSupportAsResTF4 = ta.crossover(close, TF4_FractalDown) PriceBreakingTF4Resistance = ta.crossover(close, TF4_FractalUp) PriceBreakingTF4Support = ta.crossunder(close, TF4_FractalDown) NewResFoundTF4 = TF4_FractalUp != TF4_FractalUp[1] NewSupFoundTF4 = TF4_FractalDown != TF4_FractalDown[1] PriceBreakingNewResFoundTF4 = ta.crossover(close, TF4_FractalUp) != TF4_FractalUp[1] PriceBreakingNewSupFoundTF4 = ta.crossunder(close, TF4_FractalDown) != TF4_FractalDown[1] venda_resistencia_TF4= (TF4_Alerts == 'Zona de Resistência - Venda Forte' or TF4_Alerts == 'All Alerts On') and PriceEntersTF4ResZone alert(syminfo.ticker + ' - Price enters ' + TF4_input + ' Resistance Zone', alert.freq_once_per_bar) compra_resistencia_vira_suporte_TF4 =(TF4_Alerts == 'Ropi. da Resistência - Compra' or TF4_Alerts == 'All Alerts On') and PriceTestResAsSupportTF4 alert(syminfo.ticker + ' - Price is testing ' + TF4_input + ' resistance as support', alert.freq_once_per_bar) compra_suporte_TF4=(TF4_Alerts == 'Zona de Suporte - Compra Forte' or TF4_Alerts == 'All Alerts On') and PriceEntersTF4SupZone alert(syminfo.ticker + ' - Price enters ' + TF4_input + ' Support Zone', alert.freq_once_per_bar) venda_suporte_vira_resistencia_TF4= (TF4_Alerts == 'Ropi. do Suporte - Venda' or TF4_Alerts == 'All Alerts On') and PriceTestSupportAsResTF4 alert(syminfo.ticker + ' - Price is testing ' + TF4_input + ' support as resistance', alert.freq_once_per_bar) compra_rompimento_resistencia_TF4= (TF4_Alerts == 'Rompi. da Zona de Resistecia - Compra Forte' or TF4_Alerts == 'All Alerts On') and PriceBreakingTF4Resistance alert(syminfo.ticker + ' - Price is breaking out ' + TF4_input + ' Resistance', alert.freq_once_per_bar) venda_rompimento_suporte_TF4 = (TF4_Alerts == 'Rompi. da Zona de Suporte - Venda Forte' or TF4_Alerts == 'All Alerts On') and PriceBreakingTF4Support alert(syminfo.ticker + ' - Price is breaking down ' + TF4_input + ' Support', alert.freq_once_per_bar) venda_nova_resistencia_TF4 = (TF4_Alerts == 'Nova Resistencia - Venda?' or TF4_Alerts == 'All Alerts On') and NewResFoundTF4 alert(syminfo.ticker + ' - New ' + TF4_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_rompimento_nova_resistencia_TF4 = (TF4_Alerts == 'Rompi. Nova Resistencia - Ideal Compra' or TF4_Alerts == 'All Alerts On') and PriceBreakingNewResFoundTF4 alert(syminfo.ticker + ' - New ' + TF4_input + ' Resistance Zone Found', alert.freq_once_per_bar) compra_novo_suporte_TF4 = (TF4_Alerts == 'Novo Suporte - Compra?' or TF4_Alerts == 'All Alerts On') and NewSupFoundTF4 alert(syminfo.ticker + ' - New ' + TF4_input + ' Support Zone Found', alert.freq_once_per_bar) venda_rompimento_novo_suporte_TF4 = (TF4_Alerts == 'Rompi. Novo Suporte - Ideal Venda' or TF4_Alerts == 'All Alerts On') and PriceBreakingNewSupFoundTF4 alert(syminfo.ticker + ' - New ' + TF4_input + ' Resistance Zone Found', alert.freq_once_per_bar) venda_desativa_TF4 = (TF4_Alerts == 'None') and not PriceEntersTF4ResZone and not PriceTestResAsSupportTF4 and not PriceEntersTF4SupZone and not PriceTestSupportAsResTF4 and not PriceBreakingTF4Resistance and not venda_nova_resistencia_TF4 and not compra_novo_suporte_TF4 and not venda_rompimento_novo_suporte_TF4 and not compra_novo_suporte_TF4 and not compra_rompimento_nova_resistencia_TF4 and not venda_nova_resistencia_TF4 // LOGICA DAS ESTRADAS DE COMPRA/LONG E VENDA/SHORT ============================================================================================================ //ENTRADAS OPCIONAIS DE ACORDO COM O ALERTA ESCOLHIDO operacoes_tf1 = (venda_resistencia_TF1 or compra_resistencia_vira_suporte_TF1 or compra_suporte_TF1 or venda_suporte_vira_resistencia_TF1 or compra_rompimento_resistencia_TF1 or venda_rompimento_suporte_TF1 or compra_novo_suporte_TF1 or venda_nova_resistencia_TF1 or venda_nova_resistencia_TF1 or compra_novo_suporte_TF1 or venda_rompimento_novo_suporte_TF1 or compra_novo_suporte_TF1 or compra_rompimento_nova_resistencia_TF1 or venda_nova_resistencia_TF1) operacoes_tf2 = (venda_resistencia_TF2 or compra_resistencia_vira_suporte_TF2 or compra_suporte_TF2 or venda_suporte_vira_resistencia_TF2 or compra_rompimento_resistencia_TF2 or venda_rompimento_suporte_TF2 or compra_novo_suporte_TF2 or venda_nova_resistencia_TF2 or venda_nova_resistencia_TF2 or compra_novo_suporte_TF2 or venda_rompimento_novo_suporte_TF2 or compra_novo_suporte_TF2 or compra_rompimento_nova_resistencia_TF2 or venda_nova_resistencia_TF2) operacoes_tf3 = (venda_resistencia_TF3 or compra_resistencia_vira_suporte_TF3 or compra_suporte_TF3 or venda_suporte_vira_resistencia_TF3 or compra_rompimento_resistencia_TF3 or venda_rompimento_suporte_TF3 or compra_novo_suporte_TF3 or venda_nova_resistencia_TF3 or venda_nova_resistencia_TF3 or compra_novo_suporte_TF3 or venda_rompimento_novo_suporte_TF3 or compra_novo_suporte_TF3 or compra_rompimento_nova_resistencia_TF3 or venda_nova_resistencia_TF3) operacoes_tf4 = (venda_resistencia_TF4 or compra_resistencia_vira_suporte_TF4 or compra_suporte_TF4 or venda_suporte_vira_resistencia_TF4 or compra_rompimento_resistencia_TF4 or venda_rompimento_suporte_TF4 or compra_novo_suporte_TF4 or venda_nova_resistencia_TF4 or venda_nova_resistencia_TF4 or compra_novo_suporte_TF4 or venda_rompimento_novo_suporte_TF4 or compra_novo_suporte_TF4 or compra_rompimento_nova_resistencia_TF4 or venda_nova_resistencia_TF4) grupo_total_das_operacoes = (operacoes_tf1 or operacoes_tf2 or operacoes_tf3 or operacoes_tf4) operacoes_tf1_compra = (compra_resistencia_vira_suporte_TF1 or compra_suporte_TF1 or compra_rompimento_resistencia_TF1 or compra_novo_suporte_TF1) operacoes_tf1_venda = (venda_resistencia_TF1 or venda_suporte_vira_resistencia_TF1 or venda_rompimento_suporte_TF1 or venda_nova_resistencia_TF1) operacoes_tf2_compra = (compra_resistencia_vira_suporte_TF2 or compra_suporte_TF2 or compra_rompimento_resistencia_TF2 or compra_novo_suporte_TF2) operacoes_tf2_venda = (venda_resistencia_TF2 or venda_suporte_vira_resistencia_TF2 or venda_rompimento_suporte_TF2 or venda_nova_resistencia_TF2) operacoes_tf3_compra = (compra_resistencia_vira_suporte_TF3 or compra_suporte_TF3 or compra_rompimento_resistencia_TF3 or compra_novo_suporte_TF3) operacoes_tf3_venda = ( venda_resistencia_TF3 or venda_suporte_vira_resistencia_TF3 or venda_rompimento_suporte_TF3 or venda_nova_resistencia_TF3) operacoes_tf4_compra = (compra_resistencia_vira_suporte_TF4 or compra_suporte_TF4 or compra_rompimento_resistencia_TF4 or compra_novo_suporte_TF4) operacoes_tf4_venda = ( venda_resistencia_TF4 or venda_suporte_vira_resistencia_TF4 or venda_rompimento_suporte_TF4 or venda_nova_resistencia_TF4) grupo_operacoes_apenas_compra = (operacoes_tf1_compra or operacoes_tf2_compra or operacoes_tf3_compra or operacoes_tf4_compra) grupo_operacoes_apenas_venda = (operacoes_tf1_venda or operacoes_tf2_venda or operacoes_tf3_venda or operacoes_tf4_venda) grupo_total_das_operacoes_compra_TF2_TF3_TF4 = (operacoes_tf2_compra or operacoes_tf3_compra or operacoes_tf4_compra) grupo_total_das_operacoes_compra_TF1_TF3_TF4 = (operacoes_tf1_compra or operacoes_tf3_compra or operacoes_tf4_compra) grupo_total_das_operacoes_compra_TF1_TF2_TF4 = (operacoes_tf1_compra or operacoes_tf2_compra or operacoes_tf4_compra) grupo_total_das_operacoes_compra_TF1_TF2_TF3 = (operacoes_tf1_compra or operacoes_tf2_compra or operacoes_tf3_compra) grupo_total_das_operacoes_venda_TF2_TF3_TF4 = (operacoes_tf2_venda or operacoes_tf3_venda or operacoes_tf4_venda ) grupo_total_das_operacoes_venda_TF1_TF3_TF4 = (operacoes_tf1_venda or operacoes_tf3_venda or operacoes_tf4_venda) grupo_total_das_operacoes_venda_TF1_TF2_TF4 = (operacoes_tf1_venda or operacoes_tf2_venda or operacoes_tf4_venda) grupo_total_das_operacoes_venda_TF1_TF2_TF3 = (operacoes_tf1_venda or operacoes_tf2_venda or operacoes_tf3_venda) grupo_total_das_operacoes_TF2_TF3_TF4 = (operacoes_tf2 or operacoes_tf3 or operacoes_tf4 and not operacoes_tf1) grupo_total_das_operacoes_TF1_TF3_TF4 = (operacoes_tf1 or operacoes_tf3 or operacoes_tf4 and not operacoes_tf2) grupo_total_das_operacoes_TF1_TF2_TF4 = (operacoes_tf1 or operacoes_tf2 or operacoes_tf4 and not operacoes_tf3) grupo_total_das_operacoes_TF1_TF2_TF3 = (operacoes_tf1 or operacoes_tf2 or operacoes_tf3 and not operacoes_tf4) grupo_total_das_operacoes_desativadas_compra = (TF1_Alerts == 'None' or TF2_Alerts == 'None' or TF3_Alerts == 'None' or TF4_Alerts == 'None') and grupo_operacoes_apenas_compra grupo_total_das_operacoes_desativadas_venda = (TF1_Alerts == 'None' or TF2_Alerts == 'None' or TF3_Alerts == 'None' or TF4_Alerts == 'None') and grupo_operacoes_apenas_venda desativacao_geral_das_compras_vendas = (TF1_Alerts == 'None' or TF2_Alerts == 'None' or TF3_Alerts == 'None' or TF4_Alerts == 'None') and grupo_total_das_operacoes //COMPRA: //SUGESTOES DE ENTRADA //ENTRADA 1: SE O PREÇO FECHAR NO SUPORTE = COMPRA //SAIDA 1: FECHA COMPRA SE O PREÇO FECHAR NA ZONA DE RESITENCIA = SAIDA //ENTRADA 2: SE O PREÇO ROMPER A RESINTENCIA PARA CIMA E VOLTA PARA TESTA-LA = COMPRA //SAIDA 2: STOP NA FAIXA INFERIOR DA ZONA DE RESITENCIA = SAIDA //ENTRADA 3: SE O PREÇO ROMPER O SUPORTE DE PERIODOS ANTERIOR PRA CIMA E VOLTA PARA TESTA-LO = COMPRA //SAIDA 3: STOP NA FAIXA INFERIOR DA ZONA DE SUPORTE = SAIDA compra_entrada_TF1 = ativa_estrategia_compra_TF1==true and grupo_total_das_operacoes and grupo_total_das_operacoes_desativadas_compra compra_saida_TF1 = ativa_estrategia_compra_TF1==true and grupo_operacoes_apenas_venda compra_entrada_TF2 = ativa_estrategia_compra_TF2==true and grupo_total_das_operacoes and grupo_total_das_operacoes_desativadas_compra compra_saida_TF2 = ativa_estrategia_compra_TF2==true and grupo_operacoes_apenas_venda compra_entrada_TF3 = ativa_estrategia_compra_TF3==true and grupo_total_das_operacoes and grupo_total_das_operacoes_desativadas_compra compra_saida_TF3 = ativa_estrategia_compra_TF3==true and grupo_operacoes_apenas_venda compra_entrada_TF4 = ativa_estrategia_compra_TF4==true and grupo_total_das_operacoes and grupo_total_das_operacoes_desativadas_compra compra_saida_TF4 = ativa_estrategia_compra_TF4==true and grupo_operacoes_apenas_venda //VENDA: //SUGESTOES DE ENTRADA //ENTRADA 1: SE O PREÇO FECHAR NA RESISTENCIA = VENDA //SAIDA 1: FECHA COMPRA SE O PREÇO FECHAR NA ZONA DE SUPORTE = SAIDA //ENTRADA 2: SE O PREÇO ROMPER O SUPORTE PARA BAIXOE VOLTA PARA TESTA-LO = VENDA //SAIDA 2: STOP NA FAIXA SUPERIOR DA ZONA DE SUPORTE = SAIDA //ENTRADA 3: SE O PREÇO ROMPER A RESISTENCIA DE PERIODOS ANTERIOR PRA BAIXO E VOLTA PARA TESTA-LA = VENDA //SAIDA 3: STOP NA FAIXA SUPEIOR DA ZONA DE RESISTENCIA = SAIDA venda_entrada_TF1 = ativa_estrategia_venda_TF1==true and operacoes_tf1_venda and grupo_total_das_operacoes_desativadas_venda venda_saida_TF1 = ativa_estrategia_venda_TF1==true and grupo_operacoes_apenas_compra venda_entrada_TF2 = ativa_estrategia_venda_TF2==true and operacoes_tf2_venda and grupo_total_das_operacoes_desativadas_venda venda_saida_TF2 = ativa_estrategia_venda_TF2==true and grupo_operacoes_apenas_compra venda_entrada_TF3 = ativa_estrategia_venda_TF3==true and operacoes_tf3_venda and grupo_total_das_operacoes_desativadas_venda venda_saida_TF3 = ativa_estrategia_venda_TF3==true and grupo_operacoes_apenas_compra venda_entrada_TF4 = ativa_estrategia_venda_TF4==true and operacoes_tf4_venda and grupo_total_das_operacoes_desativadas_venda venda_saida_TF4 = ativa_estrategia_venda_TF4==true and grupo_operacoes_apenas_compra // Long Strategy if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not compra_entrada_TF2 and not compra_entrada_TF3 and not compra_entrada_TF4 and not compra_saida_TF4 and not compra_saida_TF3 and not compra_saida_TF2 strategy.entry("Long1", strategy.long, when=compra_entrada_TF1, comment="TF1_COMPRA", alert_message="TF1_COMPRA") strategy.exit("Long SL/TP", from_entry="Long1", loss=long_stoploss_percentage, profit=long_takeprofit_percentage, comment="TF1_LOSS OR GAINS", alert_message="TF1_LOSS OR GAINS") strategy.close("Long1", when=compra_saida_TF1, comment="TF1_SAIDA", alert_message="TF1_SAIDA") if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not compra_entrada_TF1 and not compra_entrada_TF3 and not compra_entrada_TF4 and not compra_saida_TF4 and not compra_saida_TF3 and not compra_saida_TF1 strategy.entry("Long2", strategy.long, when=compra_entrada_TF2, comment="TF2_COMPRA", alert_message="TF2_COMPRA") strategy.exit("Long SL/TP", from_entry="Long2", loss=long_stoploss_percentage, profit=long_takeprofit_percentage, comment="TF2_LOSS OR GAINS", alert_message="TF2_LOSS OR GAINS") strategy.close("Long2", when=compra_saida_TF2, comment="TF2_SAIDA", alert_message="TF2_SAIDA") if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not compra_entrada_TF2 and not compra_entrada_TF1 and not compra_entrada_TF4 and not compra_saida_TF4 and not compra_saida_TF1 and not compra_saida_TF2 strategy.entry("Long3", strategy.long, when=compra_entrada_TF3, comment="TF3_COMPRA", alert_message="TF3_COMPRA") strategy.exit("Long SL/TP", from_entry="Long3", loss=long_stoploss_percentage, profit=long_takeprofit_percentage, comment="TF3_LOSS OR GAINS", alert_message="TF3_LOSS OR GAINS") strategy.close("Long3", when=compra_saida_TF3, comment="TF3_SAIDA", alert_message="TF3_SAIDA") if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not compra_entrada_TF2 and not compra_entrada_TF1 and not compra_entrada_TF3 and not compra_saida_TF3 and not compra_saida_TF1 and not compra_saida_TF2 strategy.entry("Long4", strategy.long, when=compra_entrada_TF4, comment="TF4_COMPRA", alert_message="TF4_COMPRA") strategy.exit("Long SL/TP", from_entry="Long4", loss=long_stoploss_percentage, profit=long_takeprofit_percentage, comment="TF4_LOSS OR GAINS", alert_message="TF4_LOSS OR GAINS") strategy.close("Long4", when=compra_saida_TF4, comment="TF4_SAIDA", alert_message="TF4_SAIDA") // Short Strategy if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not venda_entrada_TF2 and not venda_entrada_TF3 and not venda_entrada_TF4 and not venda_saida_TF4 and not venda_saida_TF3 and not venda_saida_TF2 strategy.entry("Short1", strategy.short, when = venda_entrada_TF1, comment="TF1_VENDA", alert_message="TF1_VENDA") strategy.exit("Short SL/TP", from_entry="Short1", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, comment="TF1_LOSS OR GAINS", alert_message="TF1_LOSS OR GAINS") strategy.close("Short1", when=venda_saida_TF1, comment="TF1_SAIDA", alert_message="TF1_SAIDA") if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not venda_entrada_TF1 and not venda_entrada_TF3 and not venda_entrada_TF4 and not venda_saida_TF4 and not venda_saida_TF3 and not venda_saida_TF1 strategy.entry("Short2", strategy.short, when = venda_entrada_TF2, comment="TF2_VENDA", alert_message="TF2_VENDA") strategy.exit("Short SL/TP", from_entry="Short2", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, comment="TF2_LOSS OR GAINS", alert_message="TF2_LOSS OR GAINS") strategy.close("Short2", when=venda_saida_TF2, comment="TF2_SAIDA", alert_message="TF2_SAIDA") if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not venda_entrada_TF2 and not venda_entrada_TF1 and not venda_entrada_TF4 and not venda_saida_TF4 and not venda_saida_TF1 and not venda_saida_TF2 strategy.entry("Short3", strategy.short, when = venda_entrada_TF3, comment="TF3_VENDA", alert_message="TF3_VENDA") strategy.exit("Short SL/TP", from_entry="Short3", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, comment="TF3_LOSS OR GAINS", alert_message="TF3_LOSS OR GAINS") strategy.close("Short3", when=venda_saida_TF3, comment="TF3_SAIDA", alert_message="TF3_SAIDA") if numerodebar_ONOFF or okToTradeInSession and desativacao_geral_das_compras_vendas and not venda_entrada_TF2 and not venda_entrada_TF1 and not venda_entrada_TF3 and not venda_saida_TF3 and not venda_saida_TF1 and not venda_saida_TF2 strategy.entry("Short4", strategy.short, when = venda_entrada_TF4, comment="TF4_VENDA", alert_message="TF4_VENDA") strategy.exit("Short SL/TP", from_entry="Short4", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, comment="TF4_LOSS OR GAINS", alert_message="TF4_LOSS OR GAINS") strategy.close("Short4", when=venda_saida_TF4, comment="TF4_SAIDA", alert_message="TF4_SAIDA") /// // // Flatten strategy when max losing streak is reached close_strat = not okToTradeInSession // or longTF1 or longTF2 or shortTF1 or shortTF2 if (close_strat) // close all existing orders strategy.close_all()