// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LEOVEN //@version=5 strategy(title = "LEOVEN", overlay = true, default_qty_value = 100, initial_capital=100000,default_qty_type=strategy.percent_of_equity, pyramiding=4, process_orders_on_close=true) enable_special = input(false, title='Enable Special Strategy (Braid+TrendBars+ADX)', tooltip='This Overrides ALL other conditions') use_ma = input(false, title='Use MA Condition') bars_ma = input(5, title="Max Bars since MA") entry_sw = input.string("Option 1", title="Entry Type", options=['Option 1', 'Option 2', 'Option 3']) length2 = input(3, title="Entry Option2 Looback") // MA RIBBON ribbon_grp = "MA's Settings" ma(source, length, type) => type == "SMA" ? ta.sma(source, length) : type == "EMA" ? ta.ema(source, length) : type == "SMMA (RMA)" ? ta.rma(source, length) : type == "WMA" ? ta.wma(source, length) : type == "VWMA" ? ta.vwma(source, length) : na ma1_type = input.string("EMA" , "MA 1" , inline="MA #1", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group=ribbon_grp) ma1_source = input.source(close , "" , inline="MA #1", group=ribbon_grp) ma1_length = input.int (1632 , "" , inline="MA #1", minval=1, group=ribbon_grp) ma1 = ma(ma1_source, ma1_length, ma1_type) plot(ma1, color = color.red, title="MA №1") ma2_type = input.string("SMA" , "MA 2" , inline="MA #2", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group=ribbon_grp) ma2_source = input.source(close , "" , inline="MA #2", group=ribbon_grp) ma2_length = input.int (408 , "" , inline="MA #2", minval=1, group=ribbon_grp) ma2 = ma(ma2_source, ma2_length, ma2_type) plot(ma2, color = color.orange, title="MA №2") ma3_type = input.string("SMA" , "MA 3" , inline="MA #3", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group=ribbon_grp) ma3_source = input.source(close , "" , inline="MA #3", group=ribbon_grp) ma3_length = input.int (34 , "" , inline="MA #3", minval=1, group=ribbon_grp) ma3 = ma(ma3_source, ma3_length, ma3_type) plot(ma3, color = color.green, title="MA №3") // ————— QQE use_qqe = input(false, title="ENTRY: Use QQE", group='QQE Signals Filter') bars_qqe = input(5, title="Max Bars since QQE", group='QQE Signals Filter') RSI_Period = input(14, title='RSI Length', group='QQE Signals Filter') SF = input(5, title='RSI Smoothing', group='QQE Signals Filter') QQE = input(4.238, title='Fast QQE Factor', group='QQE Signals Filter') // QQE qqe_signals(RSI_Period, SF, QQE) => src = close Wilders_Period = RSI_Period * 2 - 1 Rsi = ta.rsi(src, RSI_Period) RsiMa = ta.ema(Rsi, SF) AtrRsi = math.abs(RsiMa[1] - RsiMa) MaAtrRsi = ta.ema(AtrRsi, Wilders_Period) dar = ta.ema(MaAtrRsi, Wilders_Period) * QQE longband = 0.0 shortband = 0.0 trend = 0 DeltaFastAtrRsi = dar RSIndex = RsiMa newshortband = RSIndex + DeltaFastAtrRsi newlongband = RSIndex - DeltaFastAtrRsi longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? math.max(longband[1], newlongband) : newlongband shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? math.min(shortband[1], newshortband) : newshortband cross_1 = ta.cross(longband[1], RSIndex) trend := ta.cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1) FastAtrRsiTL = trend == 1 ? longband : shortband // Find all the QQE Crosses QQExlong = 0 QQExlong := nz(QQExlong[1]) QQExshort = 0 QQExshort := nz(QQExshort[1]) QQExlong := FastAtrRsiTL < RSIndex ? QQExlong + 1 : 0 QQExshort := FastAtrRsiTL > RSIndex ? QQExshort + 1 : 0 //Conditions qqeLong = QQExlong == 1 ? FastAtrRsiTL[1] - 50 : na qqeShort = QQExshort == 1 ? FastAtrRsiTL[1] - 50 : na [qqeLong, qqeShort] [qqeLong, qqeShort] = qqe_signals(RSI_Period, SF, QQE) // TRENDBARS bars_trendbar = input(10, title="Max Bars since TRENDBARS", group='EMA TRENDBARS') use_trendbar_en = input(true, title="ENTRY: Use EMA TrendBars", group='EMA TRENDBARS') use_trendbar_ex = input(false, title="EXIT: Use EMA TrendBars" , group='EMA TRENDBARS') ema1 = input.int(508, minval=1, maxval=30000, title="EMA UpTrend (TrendBars)", group='EMA TRENDBARS') usedEma = ta.ema(close, ema1) trendbar = hlc3 >= usedEma ? 1 : -1 trendbar_long = use_trendbar_en ? trendbar== 1 : true trendbar_short = use_trendbar_en ? trendbar==-1 : true macd_tt_l = '1) MACD cross DOWN Signal (Under 0)' + '\n' + '2) MACD cross DOWN Signal' + '\n' + '3) MACD cross DOWN 0' + '\n' + '4) Signal cross DOWN 0' + '\n' + '5) MACD cross UP 0' + '\n' + '6) Signal cross UP 0' macd_tt_s = '1) MACD cross UP Signal (Above 0)' + '\n' + '2) MACD cross UP Signal' + '\n' + '3) MACD cross UP 0' + '\n' + '4) Signal cross UP 0' + '\n' + '5) MACD cross DOWN 0' + '\n' + '6) Signal cross DOWN 0' // MACD bars_macd = input(149, title="Max Bars since MACD", group='MACD') use_macd_en = input(true, title="ENTRY: Use MACD Contitions", group='MACD') use_macd_ex = input(false, title="EXIT: Use MACD Contitions", group='MACD') macd_entry_sw_long = input.int(1, title='LONG: MACD Condition', minval=1, maxval=4, group='MACD') macd_entry_sw_short = input.int(1, title='SHORT: MACD Condition', minval=1, maxval=4, group='MACD') macd_entry_sw_shortx = input.int(3, title='LONG EXIT: MACD Condition', minval=1, maxval=6, group='MACD', tooltip=macd_tt_l) macd_entry_sw_longx = input.int(4, title='SHORT EXIT: MACD Condition', minval=1, maxval=6, group='MACD', tooltip=macd_tt_s) fast_length = input(title="Fast Length", defval=190, group='MACD') slow_length = input(title="Slow Length", defval=388, group='MACD') src = input(title="Source", defval=close, group='MACD') signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 100, defval = 50, group='MACD') sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"], group='MACD') sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"], group='MACD') fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) hist = macd - signal macd_long1 = ta.crossover(macd, signal) and macd<0 macd_long2 = ta.crossover(macd, signal) macd_long3 = ta.crossover(macd, 0) macd_long4 = ta.crossover(signal, 0) macd_short1 = ta.crossunder(macd, signal) and macd>0 macd_short2 = ta.crossunder(macd, signal) macd_short3 = ta.crossunder(macd, 0) macd_short4 = ta.crossunder(signal, 0) macd_long = use_macd_en ? (macd_entry_sw_long ==1? macd_long1 : macd_entry_sw_long==2? macd_long2 : macd_entry_sw_long==3? macd_long3 : macd_entry_sw_long==4? macd_long4 : true) : true macd_short = use_macd_en ? (macd_entry_sw_short==1? macd_short1 : macd_entry_sw_short==2? macd_short2 : macd_entry_sw_short==3? macd_short3 : macd_entry_sw_short==4? macd_short4 : true) : true macd_x_long = use_macd_ex ? (macd_entry_sw_shortx==1? macd_short1 : macd_entry_sw_shortx==2? macd_short2 : macd_entry_sw_shortx==3? macd_short3 : macd_entry_sw_shortx==4? macd_short4 : macd_entry_sw_shortx==5? macd_long3 : macd_entry_sw_shortx==6? macd_long4 : false) : false macd_x_short = use_macd_ex ? (macd_entry_sw_longx ==1? macd_long1 : macd_entry_sw_longx ==2? macd_long2 : macd_entry_sw_longx ==3? macd_long3 : macd_entry_sw_longx ==4? macd_long4 : macd_entry_sw_longx ==5? macd_short3 : macd_entry_sw_longx ==6? macd_short4 : false) : false // Braid Filter bars_braid = input(11, title="Max Bars since BraidFilter", group='Braid Filter') use_braid = input(true, title="ENTRY: Use Braid Filter", group='Braid Filter') maType = input.string('EMA', 'MA Type', options=['EMA', 'DEMA', 'TEMA', 'WMA', 'VWMA', 'SMA', 'SMMA', 'HMA', 'LSMA', 'Kijun', 'McGinley', 'RMA'], group='Braid Filter') Period1 = input(1, 'Period 1', group='Braid Filter') Period2 = input(7, 'Period 2', group='Braid Filter') Period3 = input(14, 'Period 3', group='Braid Filter') PipsMinSepPercent = input(40, group='Braid Filter') //-- Moving Average mabr(type, src, len) => float result = 0 if type == 'SMA' // Simple result := ta.sma(src, len) result if type == 'EMA' // Exponential result := ta.ema(src, len) result if type == 'DEMA' // Double Exponential e = ta.ema(src, len) result := 2 * e - ta.ema(e, len) result if type == 'TEMA' // Triple Exponential e = ta.ema(src, len) result := 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len) result if type == 'WMA' // Weighted result := ta.wma(src, len) result if type == 'VWMA' // Volume Weighted result := ta.vwma(src, len) result if type == 'SMMA' // Smoothed w = ta.wma(src, len) result := na(w[1]) ? ta.sma(src, len) : (w[1] * (len - 1) + src) / len result if type == 'RMA' result := ta.rma(src, len) result if type == 'HMA' // Hull result := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))) result if type == 'LSMA' // Least Squares result := ta.linreg(src, len, 0) result if type == 'Kijun' //Kijun-sen kijun = math.avg(ta.lowest(len), ta.highest(len)) result := kijun result if type == 'McGinley' mg = 0.0 mg := na(mg[1]) ? ta.ema(src, len) : mg[1] + (src - mg[1]) / (len * math.pow(src / mg[1], 4)) result := mg result result //-- Braid Filter ma01 = mabr(maType, close, Period1) ma02 = mabr(maType, open, Period2) ma03 = mabr(maType, close, Period3) max = math.max(math.max(ma01, ma02), ma03) min = math.min(math.min(ma01, ma02), ma03) dif = max - min filter = ta.atr(14) * PipsMinSepPercent / 100 braid_long = use_braid ? ma01 > ma02 and dif > filter : true braid_short= use_braid ? ma02 > ma01 and dif > filter : true // ————— ADX use_adx = input(false, title="Use ADX Filter", group='ADX') adxFunction()=> th = input.float(20.0, title="ADX Threshold", group='ADX') lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50, group='ADX') len = input.int(14, minval=1, title="DI Length", group='ADX') up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) trur = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(plusDM, len) / trur) minus = fixnan(100 * ta.rma(minusDM, len) / trur) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig) adx_trade = adx>=th and adx>adx[1] adx_trade adx_cond = adxFunction() adx_cond2 = use_adx? adx_cond : true check_bars(x, y, bars) => c1 = x and ta.barssince(y)<=bars c2 = y and ta.barssince(x)<=bars c_f = c1 or c2 r = c_f and not c_f[1] r // CHECK ALL CONDITIONS FROM PREV X BARS check_all_prev(formula, length) => check = true for i=0 to length check := check and formula[i] check cond_change(x) => x and not x[1] // Entry Conditions long1 = ta.crossover (ma2, ma1) short1= ta.crossunder(ma2, ma1) setup_long2 = 0 setup_short2 = 0 setup_long2 := ta.crossover (ma3, ma2) and ma2>ma1? 1 : check_all_prev(close>ma3, length2) and setup_long2 [1]==1? 0 : setup_long2 [1] setup_short2 := ta.crossunder(ma3, ma2) and ma2ma3, length2) and setup_long2 [1]==1 short2= check_all_prev(closema1 and ma3>ma2 short3 = (ta.crossunder(ma3, ma2) or ta.crossunder(ma3, ma1)) and ma3>ma1 and ma3>ma2 pre_long = use_ma ? (entry_sw=='Option 1' ? long1 : entry_sw=='Option 2' ? long2 : long3 ) : true pre_short = use_ma ? (entry_sw=='Option 1' ? short1 : entry_sw=='Option 2' ? short2 : short3) : true fqqeLong = use_qqe ? qqeLong : true fqqeShort = use_qqe ? qqeShort : true ch_long = cond_change(pre_long ) or cond_change(fqqeLong ) or cond_change(macd_long ) or cond_change(trendbar_long ) or cond_change(braid_long ) ch_short = cond_change(pre_short) or cond_change(fqqeShort) or cond_change(macd_short) or cond_change(trendbar_short) or cond_change(braid_short) long0 = ch_long and ta.barssince(pre_long )<=bars_ma and ta.barssince(fqqeLong )<=bars_qqe and ta.barssince(macd_long )<=bars_macd and ta.barssince(trendbar_long )<=bars_trendbar and ta.barssince(braid_long )<=bars_braid and adx_cond2 short0 = ch_short and ta.barssince(pre_short)<=bars_ma and ta.barssince(fqqeShort)<=bars_qqe and ta.barssince(macd_short)<=bars_macd and ta.barssince(trendbar_short)<=bars_trendbar and ta.barssince(braid_short)<=bars_braid and adx_cond2 normal_long = long0 and not long0 [1] normal_short = short0 and not short0[1] // SPECIAL ENTRIES long_special_cond = enable_special and adx_cond and trendbar_long and braid_long short_special_cond = enable_special and adx_cond and trendbar_short and braid_short long_special_reset = 0 short_special_reset= 0 long_special_reset := trendbar_long and not trendbar_long [1]? 0 : long_special_cond and ((trendbar_long and not trendbar_long [1]) or long_special_reset [1]==0)? 1 : long_special_reset [1] short_special_reset:= trendbar_short and not trendbar_short [1]? 0 : short_special_cond and ((trendbar_short and not trendbar_short [1]) or short_special_reset[1]==0)? 1 : short_special_reset[1] long_special = long_special_cond and ((trendbar_long and not trendbar_long [1]) or long_special_reset [1]==0) short_special= short_special_cond and ((trendbar_short and not trendbar_short [1]) or short_special_reset[1]==0) long = enable_special ? long_special : normal_long short = enable_special ? short_special : normal_short // Position Management Tools pos = 0.0 pos:= long? 1 : short? -1 : pos[1] longCond = long and (pos[1]!= 1 or na(pos[1])) shortCond = short and (pos[1]!=-1 or na(pos[1])) // EXIT FUNCTIONS // use_sl_hhll = input(false, title="Use SL HH/LL") sl_hhll = input(6, title="SL HH/LL Length") long_entry = ta.valuewhen(longCond , close, 0) short_entry = ta.valuewhen(shortCond, close, 0) sl_long_hhll = ta.valuewhen(longCond , ta.lowest (sl_hhll), 0) sl_short_hhll = ta.valuewhen(shortCond, ta.highest(sl_hhll), 0) use_sl_atr = input(true, title="Use SL ATR") sl_atr = input.float(2.9, title="Stop Loss ATR", minval=0) atr = ta.atr(14) sl_long_atr = ta.valuewhen(longCond , close -atr * sl_atr, 0) sl_short_atr = ta.valuewhen(shortCond, close +atr * sl_atr, 0) use_sl_psar = input(false, title="Use SL PSAR") start = input(0.02) increment = input(0.02) maximum = input(0.2, "Max Value") psar = ta.sar(start, increment, maximum) sl_long_psar = ta.valuewhen(longCond , psar, 0) sl_short_psar = ta.valuewhen(shortCond, psar, 0) sl_long = math.max( (use_sl_hhll? sl_long_hhll : 0 ), math.max((use_sl_atr? sl_long_atr : 0 ), (use_sl_psar? sl_long_psar : 0 ))) sl_short = math.min( (use_sl_hhll? sl_short_hhll : 99999), math.min((use_sl_atr? sl_short_atr : 99999), (use_sl_psar? sl_short_psar : 99999))) use_rr = input(true, title="Use RR TP", group='Exit 1') tp = input.float(20, title="Take Profit R:R", minval=0, step=0.1, group='Exit 1') tp_long = ta.valuewhen(longCond , close+math.abs(close-sl_long )*tp, 0) tp_short = ta.valuewhen(shortCond, close-math.abs(close-sl_short)*tp, 0) // ————— Break Even be1 = input.float(2.8, title="BreakEven Trigger R:R", minval=0, step=0.1, group='Break Even') be2 = input.float(-0.8, title="BreakEven Set at R:R" , minval=-1, step=0.1, group='Break Even') be1_long = ta.valuewhen(longCond , close+math.abs(close-sl_long )*be1, 0) be2_long = ta.valuewhen(longCond , close+math.abs(close-sl_long )*be2, 0) be1_short = ta.valuewhen(shortCond, close-math.abs(close-sl_short)*be1, 0) be2_short = ta.valuewhen(shortCond, close-math.abs(close-sl_short)*be2, 0) inprofit_long = 0 inprofit_short = 0 inprofit_long := pos==0 or longCond ? 0 : high>be1_long [1]? 1 : inprofit_long [1] inprofit_short := pos==0 or shortCond? 0 : low ma2, ma2_exit_lb) and pos[1]==-1 and use_ma2_exit if (long_exit1 and not shortCond) or (short_exit1 and not longCond) pos:=0 // EXIT 2 use_ma12_exit = input(false, title="Use MA1-2 Exit", group='Exit 3') long_exit2 = ta.crossover (ma1, ma2) and pos[1]== 1 and use_ma12_exit short_exit2 = ta.crossunder(ma1, ma2) and pos[1]==-1 and use_ma12_exit if (long_exit2 and not shortCond) or (short_exit2 and not longCond) pos:=0 // EXIT4 use_qqe_exit = input(false, title="Use QQE Exit", group='Exit 4') long_exit4 = qqeShort and pos[1]== 1 and use_qqe_exit short_exit4 = qqeLong and pos[1]==-1 and use_qqe_exit if (long_exit4 and not shortCond) or (short_exit4 and not longCond) pos:=0 // EXIT5-6 long_exit5 = macd_x_long and pos[1]== 1 and use_macd_ex short_exit5 = macd_x_short and pos[1]==-1 and use_macd_ex long_exit6 = trendbar==-1 and pos[1]== 1 and use_trendbar_ex short_exit6 = trendbar== 1 and pos[1]==-1 and use_trendbar_ex if (long_exit5 and not shortCond) or (short_exit5 and not longCond) pos:=0 if (long_exit6 and not shortCond) or (short_exit6 and not longCond) pos:=0 // Position Adjustment long_sl = low sl_short[1] and pos[1]==-1 final_long_tp = high>tp_long[1] and pos[1]== 1 and use_rr final_short_tp = low i_startTime) and (time < i_endTime) equity = strategy.initial_capital + strategy.netprofit if equity>0 and timeCond if longCond or re_longCond strategy.entry("long" , strategy.long ) if shortCond or re_shortCond strategy.entry("short", strategy.short) strategy.exit("SL/TP", from_entry = "long" , stop=sl_long , limit=use_rr?tp_long :na) strategy.exit("SL/TP", from_entry = "short", stop=sl_short, limit=use_rr?tp_short:na) strategy.close("long" , when=long_exit1 and timeCond, comment="MA2 Exit") strategy.close("short", when=short_exit1 and timeCond, comment="MA2 Exit") strategy.close("long" , when=long_exit2 and timeCond, comment="MA1-2 Exit") strategy.close("short", when=short_exit2 and timeCond, comment="MA1-2 Exit") strategy.close("long" , when=long_exit4 and timeCond, comment="QQE Exit") strategy.close("short", when=short_exit4 and timeCond, comment="QQE Exit") strategy.close("long" , when=long_exit5 and timeCond, comment="MACD Exit") strategy.close("short", when=short_exit5 and timeCond, comment="MACD Exit") strategy.close("long" , when=long_exit6 and timeCond, comment="TrendBar Exit") strategy.close("short", when=short_exit6 and timeCond, comment="TrendBar Exit") long_exit = long_exit1 or long_exit2 or long_exit4 or long_exit5 or long_exit6 short_exit= short_exit1 or short_exit2 or short_exit4 or short_exit5 or short_exit6 alert_sw = input.string("PINECONNECTOR", title="ALERT TYPE", options=["PINECONNECTOR", "CUSTOM"]) longCond_txt = input("", title='Alert Msg: LONG Entry', group='Alert Message', inline='longCond_txt ') shortCond_txt = input("", title='Alert Msg: SHORT Entry', group='Alert Message', inline='shortCond_txt ') long_exit_txt = input("", title='Alert Msg: LONG Exit', group='Alert Message', inline='long_ex_txt ') short_exit_txt = input("", title='Alert Msg: SHORT Exit', group='Alert Message', inline='short_ex_txt ') long_sltp_txt = input("", title='Alert Msg: LONG SL/TP', group='Alert Message', inline='long_sltp_txt ') short_sltp_txt = input("", title='Alert Msg: SHORT SL/TP', group='Alert Message', inline='short_sltp_txt ') if alert_sw == 'CUSTOM' if longCond or re_longCond alert(longCond_txt, alert.freq_once_per_bar_close) if shortCond or re_shortCond alert(shortCond_txt, alert.freq_once_per_bar_close) if long_exit alert(long_exit_txt, alert.freq_once_per_bar_close) if short_exit alert(short_exit_txt, alert.freq_once_per_bar_close) if long_sl or final_long_tp alert(long_sltp_txt, alert.freq_once_per_bar_close) if short_sl or final_short_tp alert(short_sltp_txt, alert.freq_once_per_bar_close) pc_id = input.string(title="License ID", defval="xxxxxxxxx", group='PineConnector Settings', tooltip="This is your PineConnector license ID") pc_prefix = input.string(title="MetaTrader Prefix", defval="", group='PineConnector Settings', tooltip="This is your broker's MetaTrader symbol prefix") pc_suffix = input.string(title="MetaTrader Suffix", defval="", group='PineConnector Settings', tooltip="This is your broker's MetaTrader symbol suffix") pc_risk = input.float(minval=0, maxval=100, step=1, defval=1, group='PineConnector Settings', title="Risk", tooltip="This is how much to risk per trade in Meta Trader") perc_sl = 0.0 perc_tp = 0.0 perc_sl := longCond or re_longCond? sl_long : shortCond or re_shortCond? sl_short : perc_sl[1] perc_tp := longCond or re_longCond? tp_long : shortCond or re_shortCond? tp_short : perc_tp[1] var symbol = 'NDX100' pc_entry_alert(direction) => pc_id + "," + direction + "," + symbol + "," + "sl=" + str.tostring(perc_sl, '#.##') + ",tp=" + str.tostring(perc_tp, '#.##') + ",risk=" + str.tostring(pc_risk) pc_exit_alert(direction) => pc_id + "," + direction + "," + symbol pc_newsltp_alert(direction, sln) => pc_id + "," + direction + "," + symbol + "," + "sl=" + str.tostring(sln, '#.##') if alert_sw == 'PINECONNECTOR' if longCond or re_longCond alert(pc_entry_alert('buy'), alert.freq_once_per_bar_close) if shortCond or re_shortCond alert(pc_entry_alert('sell'), alert.freq_once_per_bar_close) if long_exit alert(pc_exit_alert('closelong'), alert.freq_once_per_bar_close) if short_exit alert(pc_exit_alert('closeshort'), alert.freq_once_per_bar_close) if inprofit_long and not inprofit_long [1] and pos== 1 alert(pc_newsltp_alert("newsltplong", newsl_long), alert.freq_once_per_bar_close) if inprofit_short and not inprofit_short[1] and pos==-1 alert(pc_newsltp_alert('newsltpshort', newsl_short), alert.freq_once_per_bar_close)