Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Il trading system completo - Study Break-in-New Ver-4 (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=4
- study(title="Study Break-in-New Ver-4 ETH/PERP FTX 4H LONG E SHORT", overlay=false)
- //input SL e TP Long e Short
- input_stop_loss_long = input(title="stop_loss_long", type=input.float, defval=11, minval=0, maxval=100, step=0.1, group="Stop")
- input_take_profit_long = input(title="take_profit_long", type=input.float, defval=20, minval=0, maxval=100, step=0.1, group="Stop")
- input_stop_loss_short = input(title="stop_loss_short", type=input.float, defval=11, minval=0, maxval=100, step=0.1, group="Stop")
- input_take_profit_short = input(title="take_profit_short", type=input.float, defval=20, minval=0, maxval=100, step=0.1, group="Stop")
- input_lunghezza_ema = input(title="lunghezza ema", type=input.integer, defval=125, minval=0, maxval=300, step=5)
- riskPerTrade = input(title="Risk Per Trade %", type=input.float, minval=0.1, maxval=100, defval=27.5, step=0.5)
- in_atr_periodo = input(title="Periodicitร ATR", type=input.integer, minval=5, maxval=500, defval=10, step=1)
- in_atr_Mult = input(title="atr_Mult", type=input.float, 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(title="Solo long", type=input.bool, defval=false, inline="1", group="Direzione")
- in_solo_short = input(title="Solo short", type=input.bool, defval=false, inline="1", group="Direzione")
- // Calcolo del range del backtest
- startDate = input(title="Start Date", type=input.integer,
- defval=11, minval=1, maxval=31, group="Periodo")
- startMonth = input(title="Start Month", type=input.integer,
- defval=02, minval=1, maxval=12, group="Periodo")
- startYear = input(title="Start Year", type=input.integer,
- defval=2018, minval=1800, maxval=2100, group="Periodo")
- endDate = input(title="End Date", type=input.integer,
- defval=01, minval=1, maxval=31, group="Periodo")
- endMonth = input(title="End Month", type=input.integer,
- defval=01, minval=1, maxval=12, group="Periodo")
- endYear = input(title="End Year", type=input.integer,
- defval=2121, minval=1800, maxval=2100, group="Periodo")
- inDateRange = (time >= timestamp(syminfo.timezone, startYear,
- startMonth, startDate, 0, 0)) and
- (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
- atr = atr(in_atr_periodo)
- media = ema(close, input_lunghezza_ema)
- hourTrading = input(title="sessione valida di trading", type=input.string, defval="0600-2300:23456")
- rangeTrading = time(timeframe.period, hourTrading)
- // giorni da 1 a 7 1 รจ domenica
- //Condizione Long
- condEntryLong = (abs(open-close)>(atr*in_atr_Mult)) and close > open and close > media and month!=9 and dayofweek !=2 and not in_solo_short and inDateRange
- //Condizione Short
- condEntryShort = (abs(open-close)>(atr*in_atr_Mult)) and close < open and close < media and month!=9 and dayofweek !=2 and not in_solo_long and inDateRange
- //definizione variabili posizioni aperte
- IsLongOpen = false
- IsLongOpen := condEntryLong[1] ? true : false
- IsShortOpen = false
- IsShortOpen := condEntryShort[1] ? true : false
- 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.red)
- //plot (CloseShortFloat,color=color.yellow)
- plot (OpenLongFloat,color=color.blue)
- //plot (CloseLongFloat,color=color.white)
- //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