Maurizio-Ciullo

Bot Reversal-Band-Riot-P1 ETHUSDT.P BYBIT 4H LONG E SHORT

May 9th, 2025 (edited)
466
0
Never
8
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.                                                                 // Bot Reversal Band Riot Period 1 10-03-2025 ETHUSDT.P BYBIT 4H LONG E SHORT //
  3.                                                           // Datafeed Cambiato / Periodi Backtest Cambiati / Inputs Cambiati / Devizione Short Upper Aggiunto, //
  4.                                                                
  5. // RIOTTIMIZZAZIONE PERIODICA 1 DELLA ORIGINALE REVERSAL BAND      
  6. // IL DATAFEED COMPLETO = (18/08/2017 26/02/2025)                                              
  7. // NUOVI DATI DI SVILUPPO DATAFEED ETH/USDT BINANCE + ETH/USDT.P BYBIT 4H  STORICO INIZIALE BINANCE PER POI PROSEGUIRE CON BYBIT                                                                                                                       
  8. // (Sviluppo Dati Exchange = BINANCE + BYBIT) (BINANCE Dal=18/08/2017 Al 21/10/2020) (BYBIT Dal=21/10/2020 Al 26/02/2025)
  9. // SU TRADINGVIEW ORARIO BORSA GMT
  10. // BARSBACK: 50
  11.  
  12. // NUOVE DATE IN SAMPLE E OUT OF SAMPLE
  13. //Il data feed completo: 18/08/2017 19/02/20265
  14. //In Sample: Inizio 18/08/2017 Fine 26/02/2025
  15. //Out Of Sample: Inizio 26/02/2025 Fine 19/02/2026
  16.  
  17.  
  18. //Il trading system completo - Bot Reversal Band Riot Period 1 10-03-2025 ETHUSDT.P BYBIT 4H LONG E SHORT
  19. // (Exchange= BYBIT) (Sottostante ETH-USDT.P) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=NO) (Esclusione Mesi=APRILE/AGOSTO)
  20. // (Take Profit Long/Short= Market Close Sopra/Sotto Bande) (Take Profit Limit Long= +12% Tradingview-Hub) (Take Profit Limit Short= +12% Tradingview-Hub
  21. // (Stop Loss Limit Long= -7.6% Tradingview-Hub) (Stop Loss Limit Short= -7% Tradingview-Hub) (Trailing Stop=NO) (Stop Emergenza: NO)
  22. // (Max DD Concesso = 15% Media Max Drawdown 2°nda Deviazione Standard Simulazione Montecalo Python
  23. // (Money Management = 25% Del Capitale Tradestation)  
  24. // (Money Management = 20% Del Capitale Tradingview) Preso Dal 15% Media Max Drawdown 2°nda Deviazione Standard Simulazione Montecarlo Python
  25.  
  26. // (Progettatta Il=07/07/23)
  27. // (In Sample Dal=17/08/2017 26/02/2025) (Out Of Sample Dal1 26/02/2025 Al 19/02/2026)
  28. // (Progettatta Il=27/02/2026)
  29.  
  30. // ATTENZIONE, ALCUNE POSIZIONI SONO DIFFERENTI DA TRADINGVIEW PER VIA DELLE CANDELE INIZIALI CHE SONO DI BINANCE CHE POTREBBERO AVERE VALORI LEGGERENTE DIVERSI.
  31. // ATTENZIONE, ALCUNE VOLTE, MOLTO RARAMENTE LE MEDIE POTREBBERO DIFFERIRE SEMPRE PER VIDE DELLE CANDELE INIZIALI CHE SONO DI BINANCE CHE POTREBBERO AVERE VALORI LEGGERENTE DIVERSI.
  32. // ATTENZIONE, I VALORI DELL'ADX A VOLTE POSSONO ESSERE DIFFERENTI PER VIA DELLE CANDELE INIZIALI CHE SONO DI BINANCE PER POI RIASSESTARSI DI NUOVO.
  33.  
  34.  
  35. //@version=5
  36. //1. Strategia
  37. strategy(title='Bot Reversal-Band-Riot-P1 ETH/USDT.P BYBIT 4H LONG E SHORT', overlay=true,
  38.      pyramiding=0,
  39.      initial_capital=500,
  40.      commission_type=strategy.commission.percent,
  41.      commission_value=0.1,
  42.      slippage=3,
  43.      default_qty_type=strategy.percent_of_equity,
  44.      default_qty_value=20)
  45.  
  46.  
  47. // Input
  48. input_stop_loss_long = input.float(title='stop_loss_long', defval=7.6, minval=0, maxval=100, step=0.1, group='Stop&Target')
  49. input_stop_loss_short = input.float(title='stop_loss_short', defval=7, minval=0, maxval=100, step=0.1, group='Stop&Target')
  50. input_target_long = input.float(title='target_long', defval=12, minval=0, maxval=100, step=0.1, group='Stop&Target')
  51. input_target_short = input.float(title='target_short', defval=12, minval=0, maxval=100, step=0.1, group='Stop&Target')
  52. input_sma_long = input.int(title='Media BB Long', defval=30, minval=0, maxval=50, group='Bande')
  53. input_sma_short = input.int(title='Media BB Short', defval=24, minval=0, maxval=50, group='Bande')
  54. deviazione_long = input.float(title='Deviazione Long', defval=1.5, step=0.1, group='Bande')
  55. deviazione_short = input.float(title='Deviazione Short', defval=1.5, step=0.1, group='Bande')
  56. devizione_short_lower = input.float(title='Deviazione Short Lower', defval=1.81, step=0.1, group='Bande')
  57. input_ema_long = input.int(title='Media Long', defval=55, minval=0, maxval=500, group='Medie')
  58. input_ema_short = input.int(title='Media Short', defval=55, minval=0, maxval=500, group='Medie')
  59. lunghezza_adx_long = input.int(title='Lunghezza ADX Long', defval=10, group='ADX')
  60. lunghezza_adx_short = input.int(title='Lunghezza ADX Short', defval=9, group='ADX')
  61. differenziale_adx_long = input.int(title='Differenziale ADX Long', defval=35, group='ADX')
  62. differenziale_adx_short = input.int(title='Differenziale ADX Short', defval=31, group='ADX')
  63. only_Long = input.bool(title='Solo long trade', defval=false, inline='1', group='Direzione')
  64. only_Short = input.bool(title='Solo short trade', defval=false, inline='1', group='Direzione')
  65. input_risk = input.float(title='Percentuale rischio', defval=20, minval=0, maxval=100, step=0.01)
  66.  
  67.  
  68. // Calcolo del range del backtest
  69. startDate = input.int(title='Start Date', defval=17, minval=1, maxval=31, group='Periodo')
  70. startMonth = input.int(title='Start Month', defval=08, minval=1, maxval=12, group='Periodo')
  71. startYear = input.int(title='Start Year', defval=2000, minval=1800, maxval=2100, group='Periodo')
  72.  
  73. endDate = input.int(title='End Date', defval=01, minval=1, maxval=31, group='Periodo')
  74. endMonth = input.int(title='End Month', defval=01, minval=1, maxval=12, group='Periodo')
  75. endYear = input.int(title='End Year', defval=2121, minval=1800, maxval=2150, group='Periodo')
  76.  
  77.  
  78. inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)
  79.  
  80.  
  81. // Start Hour Range Trading Non Attivo /////////////////////
  82. //hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
  83. //hourRangeTrading = time(timeframe.period, hourTrading)
  84.  
  85.  
  86. //Calcolo degli indicatori
  87.  
  88. // Medie Mobili
  89. ema_long = ta.ema(close, input_ema_long)
  90. ema_short = ta.ema(close, input_ema_short)
  91. plot(ema_long, color=color.new(color.green, 0), title='Ema Long', linewidth=1)
  92. plot(ema_short, color=color.new(color.red, 0), title='Ema Short', linewidth=1)
  93.  
  94.  
  95. //  Bollinger Bands Long
  96. middle_Band_long = ta.sma(close, input_sma_long)
  97. deviazione_st_long = deviazione_long * ta.stdev(close, input_sma_long)
  98. UpperBand_long = middle_Band_long + deviazione_st_long
  99. LowerBand_long = middle_Band_long - deviazione_st_long
  100. plot(middle_Band_long, color=color.new(color.green, 0), title='B_middle_Band_Long', linewidth=2)
  101. plot(UpperBand_long, color=color.new(color.green, 0), style=plot.style_circles, linewidth=3, title='UpperBandLong')
  102. plot(LowerBand_long, color=color.new(color.green, 0), style=plot.style_circles, linewidth=3, title='LowerBandLong')
  103.  
  104.  
  105. // Bollinger Bands Short
  106. middle_Band_short = ta.sma(close, input_sma_short)
  107. deviazione_st_short = deviazione_short * ta.stdev(close, input_sma_short)
  108. deviazione_st_short_lower = devizione_short_lower * ta.stdev(close,input_sma_short)
  109. UpperBand_short = middle_Band_short + deviazione_st_short_lower
  110. LowerBand_short = middle_Band_short - deviazione_st_short
  111. plot(middle_Band_short, color=color.new(color.red, 0), title='B_middle_Band_Short', linewidth=2)
  112. plot(UpperBand_short, color=color.new(color.red, 0), style=plot.style_circles, linewidth=3, title='UpperBandShort')
  113. plot(LowerBand_short, color=color.new(color.red, 0), style=plot.style_circles, linewidth=3, title='LowerBandShort')
  114.  
  115.  
  116. // ADX Long
  117. [di_pos_long, di_neg_long, adx_long] = ta.dmi(lunghezza_adx_long, lunghezza_adx_long)
  118. plot(adx_long, color=color.new(color.blue, 0), title='adx long')
  119.  
  120. //ADX Short
  121. [di_pos_short, di_neg_short, adx_short] = ta.dmi(lunghezza_adx_short, lunghezza_adx_short)
  122. plot(adx_short, color=color.new(color.red, 0), title='adx short')
  123.  
  124.  
  125. // Money Menagment e stop loss
  126.  
  127. // size = strategy.equity * input_risk / 100
  128. // nr_contratti = size / close
  129. // stop_loss_long = math.round(size / syminfo.mintick / 100 * input_stop_loss_long) / nr_contratti
  130. // stop_loss_short = math.round(size / syminfo.mintick / 100 * input_stop_loss_short) / nr_contratti
  131. // target_long = math.round(size / syminfo.mintick / 100 * input_target_long) / nr_contratti
  132. // target_short = math.round(size / syminfo.mintick / 100 * input_target_short) / nr_contratti
  133.  
  134.  
  135. //Variabili Stop Long e Short
  136. stop_loss_long_price = strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_stop_loss_long) / 100
  137. stop_loss_long = (strategy.opentrades.entry_price(0) - stop_loss_long_price) / syminfo.mintick
  138. take_profit_long_price = (strategy.opentrades.entry_price(0) + ((strategy.opentrades.entry_price(0) * input_target_long) / 100))
  139. take_profit_long = (take_profit_long_price - strategy.opentrades.entry_price(0)) / syminfo.mintick
  140.  
  141. //plot(stop_loss_long, title = "sl_long_ticks", color=color.purple)
  142.  
  143.  
  144. stop_loss_short_price = strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_stop_loss_short) / 100
  145. stop_loss_short = (stop_loss_short_price - strategy.opentrades.entry_price(0)) / syminfo.mintick
  146. take_profit_short_price = (strategy.opentrades.entry_price(0) - ((strategy.opentrades.entry_price(0) * input_target_short) / 100))
  147. take_profit_short =(strategy.opentrades.entry_price(0) - take_profit_short_price) / syminfo.mintick
  148.  
  149. //plot(stop_loss_short, title = "sl_short_ticks", color=color.purple)
  150.  
  151.  
  152. // plot(strategy.position_size != 0 ? strategy.position_avg_price : na, color=strategy.position_size > 0 ? color.blue : strategy.position_size < 0 ? color.red : na, style=plot.style_linebr, title='entry_price')  // stampa l'entry price in rosso se short in blu se long
  153. // plot(strategy.position_size > 0 ? strategy.position_avg_price + take_profit_long * 0.01 * 10 : strategy.position_size < 0 ? strategy.position_avg_price - take_profit_short * 0.01 * 10 : na, color=color.new(color.green, 0), style=plot.style_cross, linewidth=2, title='tk_limit')
  154. // plot(strategy.position_size > 0 ? strategy.position_avg_price - stop_loss_long * 0.01 * 10 : strategy.position_size < 0 ? strategy.position_avg_price + stop_loss_short * 0.01 * 10 : na, color=color.new(color.red, 0), style=plot.style_cross, linewidth=2, title='sl_limit')
  155.  
  156.  
  157. plot(strategy.position_size != 0 ? strategy.opentrades.entry_price(0) : na , color=strategy.position_size > 0 ? color.blue : strategy.position_size < 0 ? color.red : na, style=plot.style_linebr, title="entry_price") // stampa l'entry price in rosso se short in blu se long
  158. plot(strategy.position_size > 0 ?  take_profit_long_price : strategy.position_size < 0 ? take_profit_short_price: na, color=color.green, style=plot.style_cross, linewidth=2, title="tk_limit")
  159. plot(strategy.position_size > 0 ?  stop_loss_long_price : strategy.position_size < 0 ? stop_loss_short_price: na, color=color.red, style=plot.style_cross, linewidth=2, title="sl_limit")
  160.  
  161. bgcolor(strategy.position_size > 0 ? color.green : strategy.position_size < 0 ? color.red : na, transp=90) // sfondo verde quando siamo long, sfondo rosso quando siamo short, no sfondo quando non siamo in posizione
  162.  
  163.  
  164. // >>>>>>>>>>>>>> Start Detecting No Trading Allowed <<<<<<<<<<<<<<<<<
  165.  
  166. // Plot No Trading Allowed giorni da 1 a 7 1 è Domenica. Mesi da 1 a 12 1 è Gennaio
  167.  
  168. mesi_esclusi = month(time)
  169. plotshape(mesi_esclusi[1] == 4 ? mesi_esclusi : na, color=color.new(color.yellow, 0), title='mesi_esclusi')
  170. plotshape(mesi_esclusi[1] == 8 ? mesi_esclusi : na, color=color.new(color.yellow, 0), title='mesi_esclusi')
  171.  
  172. // >>>>>>>>>>>>>> End Detecting No Trading Allowed <<<<<<<<<<<<<<<<<
  173.  
  174.  
  175. // >>>>>>>>>>>>>> Start Calcolo Drawdown Operazion Chiuse <<<<<<<<<<<<<<<<<
  176.  
  177. // Blance Closed Equity
  178. balance = strategy.initial_capital + strategy.netprofit
  179. plot(balance, title="Balance Closed Equity", display = display.data_window)
  180.  
  181. // Highest Equity Closed Equity
  182. GetEquityHigh() =>
  183.     var highestEquity = strategy.initial_capital
  184.     highestEquity := math.max(highestEquity, (strategy.initial_capital + strategy.netprofit))
  185. plot(GetEquityHigh(), "Highest Equity Closed Equity", display = display.data_window)
  186.  
  187. // Drawdown Relativo In $ (Closed Equity)
  188. relativeDrawdownMonetary = GetEquityHigh() - balance
  189. plot(relativeDrawdownMonetary, title="Drawdown Relativo $ Closed Equity", display=display.data_window)
  190.  
  191. // Drawdown Relativo In % (Closed Equity)
  192. relativeDrawdownPercent = (GetEquityHigh() != 0) ? (GetEquityHigh() - balance) / GetEquityHigh() * 100 : 0.0
  193. plot(relativeDrawdownPercent, title="Drawdown Relativo % Closed Equity", display=display.data_window)
  194.  
  195. // Max Drawdown Absolute $ Closed Equity
  196. var float maxDrawdownMonetary = 0.0
  197. MaxDrawdownAbsoluteMonetary = (GetEquityHigh() - balance)
  198. maxDrawdownMonetary := math.max(maxDrawdownMonetary, MaxDrawdownAbsoluteMonetary)
  199. plot(maxDrawdownMonetary, title="Max Drawdown $ Closed Equity", display=display.data_window)
  200.  
  201. // Max Drawdown Percentuale Closed Equity
  202. var float maxDrawdownPercent = 0.0
  203. MaxDrawdownAbsolutePercent = (GetEquityHigh() != 0) ? (GetEquityHigh() - balance) / GetEquityHigh() * 100 : 0.0
  204. maxDrawdownPercent := math.max(maxDrawdownPercent, MaxDrawdownAbsolutePercent)
  205. plot(maxDrawdownPercent, title="Max Drawdown % Closed Equity", display=display.data_window)
  206.  
  207. // Plot Linee
  208. // plot(balance, title="Balance Closed Equity", style=plot.style_line)
  209. // plot(GetEquityHigh(), title="Highest Equity Closed Equity", style=plot.style_line)
  210. // plot(relativeDrawdownMonetary, title="Drawdown Relativo $ Closed Equity", style=plot.style_line)
  211. // plot(relativeDrawdownPercent, title="Drawdown Relativo % Closed Equity", style=plot.style_line)
  212. // plot(maxDrawdownMonetary, title="Max Drawdown $ Closed Equity", style=plot.style_line)
  213. // plot(maxDrawdownPercent, title="Max Drawdown % Closed Equity", style=plot.style_line)
  214.  
  215. // >>>>>>>>>>>>>> End Calcolo Drawdown Operazion Chiuse <<<<<<<<<<<<<<<<<
  216.  
  217.  
  218. //Condizione Entry Long
  219. condEntryLong = ta.crossover(close, LowerBand_long) and close < ema_long and adx_long < differenziale_adx_long and not only_Short and inDateRange  and month != 4 and month != 8
  220.  
  221. //Condizione Uscita Long
  222. condExitLong = ta.crossover(close, UpperBand_long)
  223.  
  224.  
  225.  
  226. // Condizione Entry Short
  227. condEntryShort = ta.crossunder(close, UpperBand_short) and close > ema_short and adx_short < differenziale_adx_short and not only_Long and inDateRange  and month != 4 and month != 8
  228.  
  229. // Condizione Exit Short
  230. condExitShort = ta.crossunder(close, LowerBand_short)
  231.  
  232.                    
  233. buy_command = '{"pair":"ETHUSDT","unitsPercent":"20","unitsType":"percentBalance","exchange":"Bybit","apiKey":"ReversBandRiotP1","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","alertTimestamp":"{{ticker}}-{{time}}","isBuy":true,"isMarket":true,"stopLossPercent":"-7.6","stopLossType":"percent","leverage":"1","marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"12"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAllOrders":true}'
  234. sell_command = '{"pair":"ETHUSDT","unitsPercent":"20","unitsType":"percentBalance","exchange":"Bybit","apiKey":"ReversBandRiotP1","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","alertTimestamp":"{{ticker}}-{{time}}","isSell":true,"isMarket":true,"stopLossPercent":"-7","stopLossType":"percent","leverage":"1","marginType":"ISOLATED","targets":[{"idx":1,"amount":"100","takeProfitPercent":"12"}],"targetType":"percent","targetAmountInPercent":true,"closeCurrentPosition":true,"preventPyramiding":true,"cancelAllOrders":true}'
  235. close_command = '{"pair":"ETHUSDT","exchange":"Bybit","apiKey":"ReversBandRiotP1","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","alertTimestamp":"{{ticker}}-{{time}}","isClose":true}'
  236.  
  237. // // ============== Email Protection ===============
  238.  
  239. // L'email protection invia ordini senza webhook oppure se gli webhook sono abilitati ma per qualche motivo l'ordine non viene eseguito per errore verrà inviato un ordine di backup dopo 5 secondi da TV-Hub.org
  240.  
  241. // Documentazione: https://www.tv-hub.org/Home/Documentation#email-signals
  242. // Quando settiamo l'email di tradingview per abilitare l'email protection mettere temporaneamente la lingua in inglese su tradingview e poi riportarla in italiano altrimenti il codice di verifica su tv-hub non arriva.
  243. // Email Protection da aggiungere a tutte le stringhe se utilizzata l'email protection "alertTimestamp":"{{ticker}}-{{time}}"
  244. // Esempio Email Protection buy = '{"pair":"ETHUSDT","unitsPercent":"8.5","unitsType":"percentBalance","exchange":"Bybit","apiKey":"OverTheClouds","token":"e6d67d6e-1a5f-4e53-a9fd-6276dfa2a34b","isBuy":true,"isMarket":true,"leverage":"1","marginType":"ISOLATED","closeCurrentPosition":true,"preventPyramiding":true,"cancelAllOrders":true,"alertTimestamp":"{{ticker}}-{{time}}}'
  245. // Abilitare pulsante invia testo normale "Invia testo normale ad un indirizzo e-mail alternativo" quando si crea alert in notifiche dell'alert oltre al solito webook
  246.  
  247. //entrata e uscita Long
  248. if condEntryLong // strategy.opentrades == 0
  249.     strategy.entry('operazioneLong', strategy.long, alert_message = "Open Long Position", comment = buy_command)
  250.    
  251. if strategy.opentrades ==1
  252.     strategy.exit('SL e TP', from_entry='operazioneLong', loss=stop_loss_long, profit=take_profit_long, alert_message = "Your Long SL-TP Has Been Triggered.", comment = close_command)
  253.  
  254. if condExitLong and strategy.opentrades == 1
  255.     strategy.close(id='operazioneLong', alert_message = "Close Long Position", comment = close_command)
  256.  
  257. //entrata e uscita Short    
  258. if condEntryShort //and strategy.opentrades == 0
  259.     strategy.entry('operazioneShort', strategy.short, alert_message = "Open Short position", comment = sell_command)
  260.  
  261. if strategy.opentrades ==1
  262.     strategy.exit('SL e TP', from_entry='operazioneShort', loss=stop_loss_short, profit=take_profit_short, alert_message = "Your Short SL-TP Has Been Triggered.", comment = close_command)
  263.  
  264. if condExitShort and strategy.opentrades == 1
  265.     strategy.close(id='operazioneShort', alert_message = "Close Short Position", comment = close_command)
  266.  
  267. // Nome Alert: Reversal-Band-Riot-P1 ETH/USDT.P BYBIT 4H
  268. // Commento Alert: {{strategy.order.comment}}
  269. // Webhook Classico Più Sicuro Ma Più Lento: https://alerts.tv-hub.org  
  270. // Webhook Nuovo Meno Sicuro Ma Più Veloce: https://alerts.tv-hub.org/api/ExecuteTradeSignalClassic
  271.  
  272.  
  273. // ----------------- Inizio Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
  274.  
  275. // new_month = month(time) != month(time[1])
  276. // new_year  = year(time)  != year(time[1])
  277.  
  278. // eq = strategy.equity
  279.  
  280. // bar_pnl = eq / eq[1] - 1
  281.  
  282. // cur_month_pnl = 0.0
  283. // cur_year_pnl  = 0.0
  284.  
  285. // // Current Monthly P&L
  286. // cur_month_pnl := new_month ? 0.0 :
  287. //                  (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1
  288.  
  289. // // Current Yearly P&L
  290. // cur_year_pnl := new_year ? 0.0 :
  291. //                  (1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1  
  292.  
  293. // // Arrays to store Yearly and Monthly P&Ls
  294. // var month_pnl  = array.new_float(0)
  295. // var month_time = array.new_int(0)
  296.  
  297. // var year_pnl  = array.new_float(0)
  298. // var year_time = array.new_int(0)
  299.  
  300. // last_computed = false
  301.  
  302. // if (not na(cur_month_pnl[1]) and (new_month or barstate.islast))
  303. //     if (last_computed[1])
  304. //         array.pop(month_pnl)
  305. //         array.pop(month_time)
  306.  
  307. //     array.push(month_pnl , cur_month_pnl[1])
  308. //     array.push(month_time, time[1])
  309.  
  310. // if (not na(cur_year_pnl[1]) and (new_year or barstate.islast))
  311. //     if (last_computed[1])
  312. //         array.pop(year_pnl)
  313. //         array.pop(year_time)
  314.  
  315. //     array.push(year_pnl , cur_year_pnl[1])
  316. //     array.push(year_time, time[1])
  317.  
  318. // last_computed := barstate.islast ? true : nz(last_computed[1])
  319.  
  320. // // Monthly P&L Table    
  321. // var monthly_table = table(na)
  322. // prec      = input(2, title = "Return Precision")
  323.  
  324. // if (barstate.islast)
  325. //     monthly_table := table.new(position.bottom_right, columns = 14, rows = array.size(year_pnl) + 1, bgcolor=#0F0F0F,border_width=1,border_color=#000000)
  326.  
  327. //     table.cell(monthly_table, 0,  0, "",     text_color=#D3D3D3, bgcolor=#0F0F0F)
  328. //     table.cell(monthly_table, 1,  0, "Jan",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  329. //     table.cell(monthly_table, 2,  0, "Feb",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  330. //     table.cell(monthly_table, 3,  0, "Mar",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  331. //     table.cell(monthly_table, 4,  0, "Apr",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  332. //     table.cell(monthly_table, 5,  0, "May",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  333. //     table.cell(monthly_table, 6,  0, "Jun",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  334. //     table.cell(monthly_table, 7,  0, "Jul",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  335. //     table.cell(monthly_table, 8,  0, "Aug",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  336. //     table.cell(monthly_table, 9,  0, "Sep",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  337. //     table.cell(monthly_table, 10, 0, "Oct",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  338. //     table.cell(monthly_table, 11, 0, "Nov",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  339. //     table.cell(monthly_table, 12, 0, "Dec",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  340. //     table.cell(monthly_table, 13, 0, "Year", text_color=#D3D3D3, bgcolor=#0F0F0F)
  341.  
  342.  
  343. //     for yi = 0 to array.size(year_pnl) - 1
  344. //         table.cell(monthly_table, 0,  yi + 1, str.tostring(year(array.get(year_time, yi))), text_color=#D3D3D3, bgcolor=#0F0F0F)
  345.  
  346. //         y_color = array.get(year_pnl, yi) > 0 ? color.lime : color.red
  347. //         table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor = y_color)
  348.  
  349. //     for mi = 0 to array.size(month_time) - 1
  350. //         m_row   = year(array.get(month_time, mi))  - year(array.get(year_time, 0)) + 1
  351. //         m_col   = month(array.get(month_time, mi))
  352. //         m_color = array.get(month_pnl, mi) > 0 ? color.lime : color.red
  353.  
  354. //         table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor = m_color)
  355.  
  356. // ----------------- Fine Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
  357.  
  358.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment