Advertisement
Maurizio-Ciullo

Study Break in New Ver-5 ETH/PERP FTX 4H LONG E SHORT

Jan 13th, 2022 (edited)
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2.  
  3. //Il trading system completo - Study Break in New Ver-5 (Strategia Breakout) - parte 2
  4. // (Exchange= FTX) (Sottostante ETH-PERP) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=LUNEDI') (Esclusione Mesi=SETTEMBRE)
  5. // (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)
  6. //@version=5
  7. indicator(title='Study Break in New Ver-5 ETH/PERP FTX 4H LONG E SHORT', overlay=false)
  8.  
  9.  
  10.  
  11. //input SL e TP Long e Short
  12. input_stop_loss_long = input.float(title='stop_loss_long', defval=11, minval=0, maxval=100, step=0.1, group='Stop')
  13. input_take_profit_long = input.float(title='take_profit_long', defval=20, minval=0, maxval=100, step=0.1, group='Stop')
  14. input_stop_loss_short = input.float(title='stop_loss_short', defval=11, minval=0, maxval=100, step=0.1, group='Stop')
  15. input_take_profit_short = input.float(title='take_profit_short', defval=20, minval=0, maxval=100, step=0.1, group='Stop')
  16. input_lunghezza_ema = input.int(title='lunghezza ema', defval=125, minval=0, maxval=300, step=5)
  17.  
  18. riskPerTrade = input.float(title='Risk Per Trade %', minval=0.1, maxval=100, defval=27.5, step=0.5)
  19.  
  20.  
  21. length = input.int(title="Length", defval=10, minval=1)
  22. smoothing = input.string(title="Smoothing", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"])
  23. ma_function(source, length) =>
  24.     switch smoothing
  25.         "RMA" => ta.rma(source, length)
  26.         "SMA" => ta.sma(source, length)
  27.         "EMA" => ta.ema(source, length)
  28.         => ta.wma(source, length)
  29. //plot(ma_function(ta.tr(true), length), title = "ATR", color=color.new(#B71C1C, 0))
  30.  
  31.  
  32. in_atr_Mult = input.float(title='atr_Mult', minval=1, maxval=5, defval=1, step=0.5)
  33. //in_tpPips = input(title="TP", type=input.integer, defval=40)
  34. //in_slPips = input(title="SL", type=input.integer, defval=30)
  35.  
  36. //Input solo long o solo short
  37. in_solo_long = input.bool(title='Solo long', defval=false, inline='1', group='Direzione')
  38. in_solo_short = input.bool(title='Solo short', defval=false, inline='1', group='Direzione')
  39.  
  40. atr = ma_function(ta.tr(true), length)
  41. media = ta.ema(close, input_lunghezza_ema)
  42.  
  43. //plot(media, title = "media", color=color.blue)
  44.  
  45. hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
  46.  
  47. rangeTrading = time(timeframe.period, hourTrading)
  48.  
  49.  
  50. // giorni da 1 a 7 1 รจ domenica
  51.  
  52. //Condizione Long
  53. 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
  54.  
  55. //Condizione Short
  56. 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
  57.  
  58.  
  59. //definizione variabili posizioni aperte
  60.  
  61. IsLongOpen = false
  62. IsLongOpen := condEntryLong[1] ? true : condEntryShort[1] ? false : IsLongOpen[1]
  63.  
  64. IsShortOpen = false
  65. IsShortOpen := condEntryShort[1] ? true : condEntryLong[1] ? false : IsShortOpen[1]
  66.  
  67. IsFlat = true
  68. IsFlat := not IsLongOpen and not IsShortOpen
  69.  
  70. //conversione bool -> float, per debug
  71.  
  72. IsLongOpenFloat = if IsLongOpen == true
  73.     1
  74. else
  75.     0
  76.  
  77. IsShortOpenFloat = if IsShortOpen == true
  78.     1
  79. else
  80.     0
  81.  
  82. IsFlatFloat = if IsFlat == true
  83.     1
  84. else
  85.     0
  86.  
  87. //plot posizioni aperte, per debug
  88.  
  89. //plot (IsLongOpenFloat)
  90. //plot (IsShortOpenFloat,color=color.yellow)
  91. //plot (IsFlatFloat,color=color.red)
  92.  
  93. //variabili apertura e chiusura posizione
  94.  
  95. OpenLong = condEntryLong  //and not IsLongOpen
  96. //CloseLong = condExitLong and IsLongOpen and not condEntryShort
  97.  
  98. OpenShort = condEntryShort  //and not IsShortOpen
  99. //CloseShort = condExitShort and IsShortOpen and not condEntryLong
  100.  
  101. //conversione bool -> float, per debug
  102.  
  103. OpenShortFloat = if OpenShort == true
  104.     1
  105. else
  106.     0
  107.  
  108. //CloseShortFloat = if CloseShort == true
  109. //    1
  110. //else
  111. //    0
  112.  
  113. OpenLongFloat = if OpenLong == true
  114.     1
  115. else
  116.     0
  117.  
  118. //CloseLongFloat = if CloseLong == true
  119. //    1
  120. //else
  121. //    0
  122.  
  123. //plot aperture ordini, per debug
  124.  
  125. plot(OpenShortFloat, color=color.new(color.red, 0))
  126. //plot(CloseShortFloat, color=color.new(color.yellow, 0))
  127. plot(OpenLongFloat, color=color.new(color.blue, 0))
  128. //plot(CloseLongFloat, color=color.new(color.white, 0))
  129.  
  130. //alert
  131.  
  132.  
  133. // Plot entry ed exit degli allert
  134. //plotshape(series=OpenLong, text="entry_long", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
  135. //plotshape(series=CloseLong, text="close_long", style=shape.triangleup, location=location.belowbar, color=color.olive, size=size.small)
  136. //plotshape(series=OpenShort, text="entry_short", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
  137. //plotshape(series=CloseShort, text="close_short", style=shape.triangledown, location=location.abovebar, color=color.purple, size=size.small)
  138.  
  139. alertcondition(OpenLong, title='Open Long')
  140. //alertcondition(CloseLong, title='Close Long')
  141. alertcondition(OpenShort, title='Open Short')
  142. //alertcondition(CloseShort, title='Close Short')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement