Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // ©tumiza999
- // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
- // Startegia di Tumiza999 Gruppo PineCoders Telegram //
- //Strategy che prende in considerazione il canale creato dalla candela della prima ora inizio sessione giornaliera, quindi High Open e Low.
- //Strategy Entry sono 3 High - Open - Low
- //Strategy Mode sono 3
- //Classica: SL - TP
- //CrossEMA: SL su ema TP da impostzione
- //Trailing-Stop: no comment
- //Tips:
- //Gap se vuoi anticipare o posticipare entry
- // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
- //@version=5
- strategy("Bot 1H FIRSTBAR V.2.01", overlay=true, pyramiding = 1, slippage = 1,
- initial_capital=10000,
- default_qty_type=strategy.percent_of_equity, default_qty_value=10,
- commission_type=strategy.commission.percent, commission_value=0.0750, use_bar_magnifier = false)
- // -----------------------------------------------------------------------------
- // Trigger Point
- // -----------------------------------------------------------------------------
- open_1H = request.security(syminfo.tickerid, "60", open)
- high_1H = request.security(syminfo.tickerid, "60", high)
- low_1H= request.security(syminfo.tickerid, "60", low)
- SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) =>
- insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
- var float sessionHighPrice = na
- if insideSession and not insideSession[1]
- sessionHighPrice := high
- else if insideSession
- sessionHighPrice := high_1H
- sessionHighPrice
- SessionLow(sessionTime, sessionTimeZone=syminfo.timezone) =>
- insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
- var float sessionLowPrice = na
- if insideSession and not insideSession[1]
- sessionLowPrice := low
- else if insideSession
- sessionLowPrice := low_1H
- sessionLowPrice
- SessionOpen(sessionTime, sessionTimeZone=syminfo.timezone) =>
- insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
- var float sessionOpenPrice = na
- if insideSession and not insideSession[1]
- sessionOpenPrice := open
- else if insideSession
- sessionOpenPrice := open_1H
- sessionOpenPrice
- InSession(sessionTimes, sessionTimeZone=syminfo.timezone) =>
- not na(time(timeframe.period, sessionTimes, sessionTimeZone))
- session = input.session("0000-0100", title="Data Session")
- timeZone = input.string("GMT", title="Time Zone")
- sessHigh = SessionHigh(session, timeZone)
- sessLow= SessionLow(session, timeZone)
- sessOpen= SessionOpen(session, timeZone)
- plot(sessHigh, color=color.rgb(92, 217, 255), title="Session High")
- plot(sessOpen, color=color.rgb(255, 244, 92), title="Session Open")
- plot(sessLow, color=color.rgb(255, 117, 244), title="Session Low")
- bgcolor(InSession(session, timeZone) ? color.new(#00ffdd, 95) : na)
- if ta.crossover(close,sessHigh)
- alert(message = "High First Hour Crossover", freq = alert.freq_once_per_bar)
- if ta.crossunder(close, sessOpen)
- alert(message = "Open First Hour Crossunder", freq = alert.freq_once_per_bar)
- if ta.crossunder(close,sessLow)
- alert(message = "Low First Hour Crossunder", freq = alert.freq_once_per_bar)
- if ta.crossover(close, sessLow)
- alert(message = "Low First Hour Crossover", freq = alert.freq_once_per_bar)
- plotshape(ta.crossover(close, sessHigh), "CrossOvHIGH", shape.triangleup, location = location.belowbar, color=color.yellow)
- plotshape(ta.crossover(close, sessOpen), "CrossOvOPEN",shape.triangleup, location = location.belowbar, color= color.red)
- plotshape(ta.crossover(close, sessLow), "CrossoOvLOW",shape.triangleup, location = location.belowbar, color = color.green)
- //plotshape(ta.crossunder(close, sessHigh), "CrossovHigh",shape.triangleup, location = location.belowbar)
- //plotshape(ta.crossunder(close, sessHigh), "CrossovHigh",shape.triangleup, location = location.belowbar)
- //plotshape(ta.crossunder(close, sessHigh), "CrossovHigh",shape.triangleup, location = location.belowbar)
- //---Entry Exit Close
- //Entry = input.float(str.tostring(sessHigh), "Engage Price", options = [sessLow, sessOpen, sessHigh])
- //---INPUT DATA STOP-LOSS TAKE PROFIT
- strategy_on = input.bool(false, "Strategy On")
- strategy_engage = input.string("sessHigh", "Strategy Type", options = ["sessHigh","sessOpen", "sessLow"])
- Gap = input.float(1,"Gap%", step=0.5, tooltip="Gap di entrata su entry_price -n anticipa entrata, con +n posticipa entrata", group = "Entry")
- //Gap2 = (Entry * Gap)/100
- sl = input.float(3, "Stop-loss", step= 0.5, group = "Entry")
- tp = input.float(9, "Take-profit", step= 0.5, group = "Entry")
- //entry_source = input.string(sessHigh, "Entry Engage", options = [sessHigh, sessLow,sessOpen])
- stop_loss_price = strategy.position_avg_price * (1-sl/100)
- take_price = strategy.position_avg_price * (1+tp/100)
- //---INPUT DATA TRAILING STOP
- sl_trl = input.float(2, "Trailing-stop", step = 0.5, tooltip = "Attiva trailing stop dopo che ha raggiunto...",group = "Trailing Stop Settings")//group = "Trailing Stop Settings")
- Atrl= input.float(1, "Offset Trailing", step=0.5,tooltip = "Distanza dal prezzo", group = "Trailing Stop Settings")
- stop_trl_price_cond = sl_trl * high/syminfo.mintick/100
- stop_trl_price_offset_cond = Atrl * high/syminfo.mintick/100
- stop_tick = sl * high/syminfo.mintick/100
- profit_tick = tp * high/syminfo.mintick/100
- //var Pair_BotD= syminfo.currency + syminfo.basecurrency
- //mess_buy_discord = !buy + rre
- //mess_sell = !sell +
- //3comma-3commass alert
- //var Pair_3c = syminfo.currency + "_" + syminfo.basecurrency
- //mess_buy_3c = '{ "message_type": "bot", "bot_id": 10913385, "email_token": "b0792bf7-9ddc-4a83-85f5-b71478070846", "delay_seconds": 0, "pair": "'+ Pair_3c +'"}'
- //mess_sell_3c = '{ "action": "close_at_market_price", "message_type": "bot", "bot_id": 10913385, "email_token": "b0792bf7-9ddc-4a83-85f5-b71478070846","delay_seconds": 6,"pair": "'+ Pair_3c +'"}'
- var Pair_BotD= syminfo.basecurrency+syminfo.currency
- //mess_buy ="!market_p "+str.tostring(tp)+" "+str.tostring(sl)+" "+syminfo.basecurrency+syminfo.currency
- mess_buy_h= "!stop_limit_p "+str.tostring(sessHigh)+" "+str.tostring(tp)+" "+str.tostring(sl)+" "+Pair_BotD
- mess_buy_o= "!stop_limit_p "+str.tostring(sessOpen)+" "+str.tostring(tp)+" "+str.tostring(sl)+" "+Pair_BotD
- mess_buy_l= "!stop_limit_p "+str.tostring(sessLow)+" "+str.tostring(tp)+" "+str.tostring(sl)+" "+Pair_BotD
- //mess_sell = !sell + syminfo.basecurrency+syminfo.currency
- // -----------------------------------------------------------------------------
- // ENTRY - EXIT - CLOSE - CONDITION
- // -----------------------------------------------------------------------------
- //Filter and condition
- //INPUT FILTER
- Filter_Atr_bool = input.bool(false, "Volatility Filter", group = "Filter Settings")
- Filter_atr_low = input.int(2, "Atr Low Lenght", minval = 1, step = 1, group = "Filter Settings")
- Filter_atr_high = input.int(14, "Atr High Lenght", minval = 1, step = 1, group = "Filter Settings")
- //Filter_emaD = input.bool(false, "Ema Daily Filter", group = "Filter Settings")
- //Filter_Btc = input.bool(false, "BTC Trend Filter", group = "Filter Settings")
- //Filter_Fomocandle= input.bool(false, "Fomo Daily Filter", group = "Filter Settings")
- //----CONDITION ENGAGE
- Filter_Atr = ta.atr(Filter_atr_low) <= ta.atr(Filter_atr_high)
- //cond_long= ta.crossover(close, ta.ema(close, 60)) // and ta.crossover(close, ta.ema(close, 223))
- //cond_long2= ta.crossover((request.security("BINANCE:BTCUSDT", "60", close)), ta.ema(request.security("BINANCE:BTCUSDT","60",close), 10))
- //cond_long = request.security(syminfo.tickerid,"D",high[1]-low[1]) >= request.security(syminfo.tickerid,"D",high[2]-low[2])
- //When_entry = hour > 01
- //cond_BTC = ta.crossover(request.security('BINANCE:BTCUSDT', "60", close), ta.ema(request.security('BINANCE:BTCUSDT', "60", close), 60))
- cond_long = request.security(syminfo.tickerid,"D",high[1]-low[1]) <= request.security(syminfo.tickerid,"D",high[2]-low[2])
- //cond_long = close >= ta.ema(request.security(syminfo.tickerid, "60", close), 10)
- //cond_long = true
- price =request.security(syminfo.tickerid, "10", close)
- //------IF STRATEGY ENTRY CLOSE TRAILING
- //activation strategy settings
- ts_n = input.bool(true, "Trailing-stop", tooltip = "Attiva o disattiva trailing-stop", group = "Trailing Stop Settings")
- close_ema = input.bool(false, "Close EMA", tooltip = "Attiva o disattiva chiusura su EMA", group = "Trailing Stop Settings")
- len1 = input.int(10, "EMA length", step=1, group = "Trailing Stop Settings")
- ma1 = ta.ema(request.security(syminfo.tickerid, "60", close), len1)
- plot(ma1, title='EMA', color=color.new(color.yellow, 0))
- //---Entry engage
- entry_h = sessHigh + (sessHigh * Gap)/100
- entry_o = sessOpen + (sessOpen * Gap)/100
- entry_l = sessLow + (sessLow * Gap)/100
- //--------Strategy On
- if strategy_on == true and strategy_engage == "sessHigh"
- if ta.crossover(price, sessLow) and cond_long and Filter_Atr or ta.crossover(price, sessOpen) and cond_long and Filter_Atr
- strategy.entry("Entry", strategy.long, stop = entry_h) // alert_message = mess_buy_h)
- //fomo candle
- if ts_n == true and close_ema == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.exit("Entry", loss= stop_tick, stop= stop_loss_price, trail_points = stop_trl_price_cond, trail_offset = stop_trl_price_offset_cond, comment_loss="Stop-Loss!!",comment_profit ="CASH!!", comment_trailing = "TRL-Stop!!") //alert_profit= mess_sell_3c, alert_loss = mess_sell_3c, alert_trailing = mess_sell_3c)
- else if ts_n == false and close_ema == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.exit("Entry", loss= stop_tick, stop=stop_loss_price, limit= take_price, comment_loss= "Stop-loss!!!", comment_profit = "CASH!!") //alert_profit= mess_sell_3c, alert_loss = mess_sell_3c, alert_trailing = mess_sell_3c)
- if close_ema == true and ta.crossunder(open,ma1) and ts_n == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.close("Entry", comment = "Close EMA ") //alert_message = mess_sell_3c)
- if strategy_on == true and strategy_engage == "sessOpen"
- if ta.crossover(price, sessLow) and cond_long and Filter_Atr or ta.crossover(price, sessOpen) and cond_long and Filter_Atr
- strategy.entry("Entry Open", strategy.long, stop = entry_o) // alert_message = mess_buy_3c)
- //fomo candle
- if ts_n == true and close_ema == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.exit("Entry Open", loss= stop_tick, stop= stop_loss_price, trail_points = stop_trl_price_cond, trail_offset = stop_trl_price_offset_cond, comment_loss="Stop-Loss!!",comment_profit ="CASH!!", comment_trailing = "TRL-Stop!!") //alert_profit= mess_sell_3c, alert_loss = mess_sell_3c, alert_trailing = mess_sell_3c)
- else if ts_n == false and close_ema == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.exit("Entry Open", loss= stop_tick, stop=stop_loss_price, limit= take_price, comment_loss= "Stop-loss!!!", comment_profit = "CASH!!") //alert_profit= mess_sell_3c, alert_loss = mess_sell_3c, alert_trailing = mess_sell_3c)
- if close_ema == true and ta.crossunder(open,ma1) and ts_n == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.close("Entry Open", comment = "Close EMA ") //alert_message = mess_sell_3c)
- if strategy_on == true and strategy_engage == "sessLow"
- if ta.crossover(price, sessLow) and cond_long and Filter_Atr or ta.crossover(price, sessOpen) and cond_long and Filter_Atr
- strategy.entry("Entry Low", strategy.long, stop = entry_l)
- //fomo candle
- if ts_n == true and close_ema == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.exit("Entry Low", loss= stop_tick, stop= stop_loss_price, trail_points = stop_trl_price_cond, trail_offset = stop_trl_price_offset_cond, comment_loss="Stop-Loss!!",comment_profit ="CASH!!", comment_trailing = "TRL-Stop!!") //alert_profit= mess_sell_3c, alert_loss = mess_sell_3c, alert_trailing = mess_sell_3c)
- else if ts_n == false and close_ema == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.exit("Entry Low", loss= stop_tick, stop=stop_loss_price, limit= take_price, comment_loss= "Stop-loss!!!", comment_profit = "CASH!!")
- if close_ema == true and ta.crossunder(open,ma1) and ts_n == false
- //alert(mess_sell_3c, alert.freq_once_per_bar)
- strategy.close("Entry Low", comment = "Close EMA ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement