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/
- //Il trading system completo - Study Break in New Ver-5 (Strategia Breakout) - parte 2
- // (Exchange= FTX) (Sottostante ETH-PERP) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=LUNEDI') (Esclusione Mesi=SETTEMBRE)
- // (Take Profit Long/Short Market = Non Definito) (Take Profit Limit Long/Short= +20% Tradingview-Hub) (Stop Loss Limit Long/Short= -11% Tradingview-Hub) (Stop Emergenza= No)
- //@version=5
- indicator(title='Study Break in New Ver-5 ETH/PERP FTX 4H LONG E SHORT', overlay=false)
- //input SL e TP Long e Short
- input_stop_loss_long = input.float(title='stop_loss_long', defval=11, minval=0, maxval=100, step=0.1, group='Stop')
- input_take_profit_long = input.float(title='take_profit_long', defval=20, minval=0, maxval=100, step=0.1, group='Stop')
- input_stop_loss_short = input.float(title='stop_loss_short', defval=11, minval=0, maxval=100, step=0.1, group='Stop')
- input_take_profit_short = input.float(title='take_profit_short', defval=20, minval=0, maxval=100, step=0.1, group='Stop')
- input_lunghezza_ema = input.int(title='lunghezza ema', defval=125, minval=0, maxval=300, step=5)
- riskPerTrade = input.float(title='Risk Per Trade %', minval=0.1, maxval=100, defval=27.5, step=0.5)
- length = input.int(title="Length", defval=10, minval=1)
- smoothing = input.string(title="Smoothing", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"])
- ma_function(source, length) =>
- switch smoothing
- "RMA" => ta.rma(source, length)
- "SMA" => ta.sma(source, length)
- "EMA" => ta.ema(source, length)
- => ta.wma(source, length)
- //plot(ma_function(ta.tr(true), length), title = "ATR", color=color.new(#B71C1C, 0))
- in_atr_Mult = input.float(title='atr_Mult', minval=1, maxval=5, defval=1, step=0.5)
- //in_tpPips = input(title="TP", type=input.integer, defval=40)
- //in_slPips = input(title="SL", type=input.integer, defval=30)
- //Input solo long o solo short
- in_solo_long = input.bool(title='Solo long', defval=false, inline='1', group='Direzione')
- in_solo_short = input.bool(title='Solo short', defval=false, inline='1', group='Direzione')
- atr = ma_function(ta.tr(true), length)
- media = ta.ema(close, input_lunghezza_ema)
- //plot(media, title = "media", color=color.blue)
- hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
- rangeTrading = time(timeframe.period, hourTrading)
- // giorni da 1 a 7 1 รจ domenica
- //Condizione Long
- condEntryLong = math.abs(open - close) > atr * in_atr_Mult and close > open and close > media and month != 9 and dayofweek != 2 and not in_solo_short
- //Condizione Short
- condEntryShort = math.abs(open - close) > atr * in_atr_Mult and close < open and close < media and month != 9 and dayofweek != 2 and not in_solo_long
- //definizione variabili posizioni aperte
- IsLongOpen = false
- IsLongOpen := condEntryLong[1] ? true : condEntryShort[1] ? false : IsLongOpen[1]
- IsShortOpen = false
- IsShortOpen := condEntryShort[1] ? true : condEntryLong[1] ? false : IsShortOpen[1]
- IsFlat = true
- IsFlat := not IsLongOpen and not IsShortOpen
- //conversione bool -> float, per debug
- IsLongOpenFloat = if IsLongOpen == true
- 1
- else
- 0
- IsShortOpenFloat = if IsShortOpen == true
- 1
- else
- 0
- IsFlatFloat = if IsFlat == true
- 1
- else
- 0
- //plot posizioni aperte, per debug
- //plot (IsLongOpenFloat)
- //plot (IsShortOpenFloat,color=color.yellow)
- //plot (IsFlatFloat,color=color.red)
- //variabili apertura e chiusura posizione
- OpenLong = condEntryLong //and not IsLongOpen
- //CloseLong = condExitLong and IsLongOpen and not condEntryShort
- OpenShort = condEntryShort //and not IsShortOpen
- //CloseShort = condExitShort and IsShortOpen and not condEntryLong
- //conversione bool -> float, per debug
- OpenShortFloat = if OpenShort == true
- 1
- else
- 0
- //CloseShortFloat = if CloseShort == true
- // 1
- //else
- // 0
- OpenLongFloat = if OpenLong == true
- 1
- else
- 0
- //CloseLongFloat = if CloseLong == true
- // 1
- //else
- // 0
- //plot aperture ordini, per debug
- plot(OpenShortFloat, color=color.new(color.red, 0))
- //plot(CloseShortFloat, color=color.new(color.yellow, 0))
- plot(OpenLongFloat, color=color.new(color.blue, 0))
- //plot(CloseLongFloat, color=color.new(color.white, 0))
- //alert
- // Plot entry ed exit degli allert
- //plotshape(series=OpenLong, text="entry_long", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
- //plotshape(series=CloseLong, text="close_long", style=shape.triangleup, location=location.belowbar, color=color.olive, size=size.small)
- //plotshape(series=OpenShort, text="entry_short", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
- //plotshape(series=CloseShort, text="close_short", style=shape.triangledown, location=location.abovebar, color=color.purple, size=size.small)
- alertcondition(OpenLong, title='Open Long')
- //alertcondition(CloseLong, title='Close Long')
- alertcondition(OpenShort, title='Open Short')
- //alertcondition(CloseShort, title='Close Short')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement