Advertisement
Maurizio-Ciullo

Bot Weekly-Mean-Trend ETH/USDT.P BYBIT 4H LONG E SHORT

Mar 4th, 2023 (edited)
870
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                                                     // Bot Weekly-Mean-Trend ETH/USDT.P BYBIT 4H LONG E SHORT //
  2.  
  3. // © Maurizio-Ciullo
  4.  
  5. // No Repainting: https://www.youtube.com/watch?v=-ZvGC0wUNAI IN QUESTA STRATEGIA E' STATA USATA LA TECNICA NO REPAINTING
  6. // A differenza di quella originale ho cambiato le Medie da SMA a EMA perchè performano meglio
  7.  
  8. // SU TRADINGVIEW ORARIO BORSA GMT
  9. // BARSBACK: 50
  10.  
  11. // Il trading system completo - Weekly Mean Trend ETH/USDT.P BYBIT 4H LONG E SHORT (Strategia Breakout)
  12. // (Sviluppo Dati Exchange = FTX)
  13. // (Exchange= BYBIT) (Sottostante ETH-USDT.P) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= NO) (Esclusione Ore=NO) (Esclusione Giorni=NO) (Esclusione Mesi=NO)
  14. // (Take Profit Long/Short Market = NO) (Take Profit Limit Long/Short= NO)
  15. // (Stop Loss Limit Long= NO) (Stop Loss Limit Short= NO) (Stop Loss Market Long/Short= SI) (Trailing Stop=SI) (Stop Emergenza= NO)
  16. // (Rischio Operazione 2% Perdita Media) (Max Drawdown Permesso 10,94%)
  17. // (ATTENZIONE !!! NON USO PIU' IL RISCHIO OPERAZIONE SOPRA DEL 2% MA LA LASCIO SEMPRE LIVE E QUANDO ARRIVA AL 15% DI MAX DD AGGIUSTATO CON IL PROGRAMMA MONTECARLO PYTHON LA CESTINO
  18. // (In Sample Dal=18/08/17 Al 30/11/21) (Out Of Sample Dal=30/11/21 Al 31/01/22)
  19. // (Money Management = 25% Del Capitale Tradestation)  
  20. // (Money Management = 21% Del Capitale Tradingview) Preso Dal 15% Media Max Drawdown 2°nda Deviazione Standard Simulazione Montecarlo Python
  21. // (Progettatta Il=31/01/22)
  22.  
  23. // ATTENZIONE SONO STATI GENERATI NUOVO REPORT RECENTI IN DATA 01/06/2025 MA QUESTI REPORT SONO STATI GENERATI SUL SEGUENTE DATAFEED DATO CHE FTX E' FALLITO:
  24. // DATI NUOVI REPORT GENERATI NELLE CARTELLE DI SVILUPPO:
  25. // IL DATAFEED COMPLETO = (18/08/2017 26/05/2025)                                              
  26. // NUOVI DATI DI REPORT DATAFEED ETH/USDT BINANCE + ETH/USDT.P BYBIT 4H  STORICO INIZIALE BINANCE PER POI PROSEGUIRE CON BYBIT                                                                                                                     
  27. // (Sviluppo Dati Exchange = BINANCE + BYBIT) (BINANCE Dal=18/08/2017 Al 21/10/2020) (BYBIT Dal=21/10/2020 Al 26/05/2025)
  28.  
  29.  
  30. //@version=5
  31. strategy(title='Bot Weekly-Mean-Trend ETH/USDT.P BYBIT 4H LONG E SHORT', overlay=true,
  32.      pyramiding=0,
  33.      initial_capital=1000,
  34.      commission_type=strategy.commission.percent,
  35.      commission_value=0.1,
  36.      slippage=3,
  37.      default_qty_type=strategy.percent_of_equity,
  38.      default_qty_value=21)
  39.  
  40.  
  41. // >>>>>>>>>>>>>> Start Detecting Inputs <<<<<<<<<<<<<<<<<
  42.  
  43. swt = input(true, title='Show This Weeks OHLC?')
  44. input_media_W_high = input.int(title='media_W_high', defval=10, minval=1, maxval=500, group='Medie_Settimanali')
  45. input_media_W_low = input.int(title='media_W_low', defval=19, minval=1, maxval=500, group='Medie_Settimanali')
  46. input_media_W_high_smoothed = input.int(title='media_W_high_smoothed', defval=38, minval=1, maxval=500, group='Medie_Settimanali_Smoothed')
  47. input_media_W_low_smoothed = input.int(title='media_W_low_smoothed', defval=38, minval=1, maxval=500, group='Medie_Settimanali_Smoothed')
  48. onlyLong = input.bool(title='Solo long trade', defval=false, inline='1', group='Direzione')
  49. onlyShort = input.bool(title='Solo short trade', defval=false, inline='1', group='Direzione')
  50. in_atr_period_long = input.int(title='Periodicità ATR long', minval=5, maxval=500, defval=14, step=1)
  51. in_atr_period_short = input.int(title='Periodicità ATR short', minval=5, maxval=500, defval=9, step=1)
  52. in_atr_mult_long = input.float(title='atr_Mult_long', minval=0.1, maxval=5, defval=0.75, step=0.5)
  53. in_atr_mult_short = input.float(title='atr_Mult_short', minval=0.1, maxval=5, defval=1, step=0.5)
  54. dmi_min_diff_input_long = input.float(title='Distanza min dim_long', minval=-100, maxval=1000000, defval=18, step=0.1)
  55. dmi_min_diff_input_short = input.float(title='Distanza min dim_short', minval=-100, maxval=1000000, defval=25, step=0.1)
  56.  
  57. // >>>>>>>>>>>>>> End Detecting Inputs <<<<<<<<<<<<<<<<<
  58.  
  59.  
  60. // >>>>>>>>>>>>>> Start Detecting Calcolo del range del backtest <<<<<<<<<<<<<<<<<
  61.  
  62. startDate = input.int(title='Start Date', defval=17, minval=1, maxval=31, group='Periodo')
  63. startMonth = input.int(title='Start Month', defval=08, minval=1, maxval=12, group='Periodo')
  64. startYear = input.int(title='Start Year', defval=2000, minval=1800, maxval=2100, group='Periodo')
  65.  
  66. endDate = input.int(title='End Date', defval=01, minval=1, maxval=31, group='Periodo')
  67. endMonth = input.int(title='End Month', defval=01, minval=1, maxval=12, group='Periodo')
  68. endYear = input.int(title='End Year', defval=2121, minval=1800, maxval=2150, group='Periodo')
  69.  
  70. inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)
  71.  
  72. // >>>>>>>>>>>>>> End Detecting Calcolo del range del backtest <<<<<<<<<<<<<<<<<
  73.  
  74.  
  75. // >>>>>>>>>>>>>> Start Detecting Hour Range Trading <<<<<<<<<<<<<<<<<
  76.  
  77. // hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
  78. // hourRangeTrading = time(timeframe.period, hourTrading)
  79.  
  80. // >>>>>>>>>>>>>> EndDetecting Hour Range Trading <<<<<<<<<<<<<<<<<
  81.  
  82.  
  83. // >>>>>>>>>>>>>> Start Detecting Weekly Highs/Lows <<<<<<<<<<<<<<<<<
  84.  
  85. // wtdo = request.security(syminfo.tickerid, 'W', open) //[barstate.isconfirmed ? 0:1]
  86. // wpdo = request.security(syminfo.tickerid, 'W', open[1])
  87. // wpc = request.security(syminfo.tickerid, 'W', close)
  88. // wpdc = request.security(syminfo.tickerid, 'W', close[1])
  89. // wph = request.security(syminfo.tickerid, 'W', high[barstate.isconfirmed ? 0:1]) // NO REPAINTING [barstate.isconfirmed ? 0:1]
  90. // wpdh = request.security(syminfo.tickerid, 'W', high[1])
  91. // wpl = request.security(syminfo.tickerid, 'W', low[barstate.isconfirmed ? 0:1])  // NO REPAINTING [barstate.isconfirmed ? 0:1]
  92. // wpdl = request.security(syminfo.tickerid, 'W', low[1])
  93.  
  94. // Weekly Plots
  95. // plot(swt and wtdo ? wtdo : na, title="Weekly Open", style=plot.style_circles, linewidth=1, color=color.silver)
  96. // plot(swt and wpc ? wpc : na, title="Weekly Close", style=plot.style_circles, linewidth=1, color=color.fuchsia)
  97. // plot(swt and wph ? wph : na, title="Weekly High", style=plot.style_circles, linewidth=1, color=color.green)
  98. // plot(swt and wpl ? wpl : na, title="Weekly Low", style=plot.style_circles, linewidth=1, color=color.red)
  99.  
  100. // >>>>>>>>>>>>>> End Detecting Weekly Highs/Lows <<<<<<<<<<<<<<<<<
  101.  
  102. // >>>>>>>>>>>>>> Start Detecting Weekly Highs/Lows Allineated With Tradestation <<<<<<<<<<<<<<<<<
  103.  
  104. // Variabili persistenti
  105. var float MinimoCorrente = na  
  106. var float MinimoSettPrec = na
  107. var float MassimoCorrente = na  
  108. var float MassimoSettPrec = na
  109. var int GiornoPrecedente = na
  110.  
  111. // Prendi il valore LOW in modo sicuro (anti-repainting)
  112. low_val = low[barstate.isconfirmed ? 0 : 1]
  113. high_val = high[barstate.isconfirmed ? 0 : 1]
  114.  
  115. // Giorno dell’anno
  116. data_attuale = (dayofweek(time))
  117.  
  118. // Se è domenica e nuova giornata → nuova settimana
  119. if dayofweek == dayofweek.sunday and GiornoPrecedente != data_attuale
  120.     MinimoSettPrec := MinimoCorrente   // salvo il minimo della settimana appena chiusa (da domenica precedente a sabato)
  121.     MinimoCorrente := low_val         // resetto il minimo per la nuova settimana (che inizia di domenica)
  122.     MassimoSettPrec := MassimoCorrente
  123.     MassimoCorrente := high_val
  124. else
  125.     MinimoCorrente := math.min(nz(MinimoCorrente, low_val), low_val)  // Durante tutti i giorni della settimana (escluso il primo giorno della nuova settimana),
  126.                                                                       // aggiorno MinimoCorrente con il minimo tra il minimo finora registrato e il low del giorno corrente,
  127.                                                                       // così da memorizzare il minimo assoluto di tutta la settimana in corso.
  128.     MassimoCorrente := math.max(nz(MassimoCorrente, high_val), high_val)
  129.  
  130. // Aggiorna giorno precedente
  131. GiornoPrecedente := data_attuale
  132.  
  133. // Ritardo di 5 barre
  134. LowSettPrecSpostato = MinimoSettPrec[5]
  135. HighSettPrecSpostato = MassimoSettPrec[5]
  136.  
  137. wpl = LowSettPrecSpostato
  138. wph = HighSettPrecSpostato
  139.  
  140. // >>>>>>>>>>>>>> End Detecting Weekly Highs/Lows Allineated With Tradestation <<<<<<<<<<<<<<<<<
  141.  
  142.  
  143. // >>>>>>>>>>>>>> Start Detecting Variables <<<<<<<<<<<<<<<<<
  144.  
  145. media_high = ta.ema(wph, input_media_W_high)
  146. plot(close > media_high ? media_high : close < media_high ? media_high : na, color=close > media_high ? color.green : close < media_high ? color.gray :na, linewidth=1, title='media_high', style=plot.style_cross)
  147. media_low = ta.ema(wpl, input_media_W_low)
  148. plot(close < media_low ? media_low : close > media_low ? media_low : na, color=close < media_low ? color.red : close > media_low ? color.gray :na, linewidth=1, title='media_low', style=plot.style_cross)
  149.  
  150. media_high_smoothed = ta.ema(wph, input_media_W_high_smoothed)
  151. plot(media_high_smoothed, color=color.new(color.green, 0), linewidth=1, title='media_high_smoothed')
  152. media_low_smoothed = ta.ema(wpl, input_media_W_low_smoothed)
  153. plot(media_low_smoothed, color=color.new(color.red, 0), linewidth=1, title='media_low_smoothed')
  154.  
  155. // >>>>>>>>>>>>>> End Detecting Variables <<<<<<<<<<<<<<<<<
  156.  
  157.  
  158. // >>>>>>>>>>>>>> Start Detecting Atr Long E Short <<<<<<<<<<<<<<<<<
  159. // Per il calcolo dell'indicatore è stato richiamato l'indicatore originale e l'indicatore di 1na barra fa per non avere repainting usando l'operatore ternario
  160.  
  161. valore_atr_long_origin =  ta.atr(in_atr_period_long)
  162. valore_atr_long1 = valore_atr_long_origin[1]
  163. valore_atr_long =  barstate.isconfirmed ? valore_atr_long_origin : valore_atr_long1   // NO REPAINTING
  164.  
  165. atr_per_mult_long = valore_atr_long * in_atr_mult_long
  166. plot(atr_per_mult_long, title='atr_mult_long')
  167.  
  168.  
  169. valore_atr_short_origin = ta.atr(in_atr_period_short)
  170. valore_atr_short1 = valore_atr_short_origin[1]
  171. valore_atr_short =  barstate.isconfirmed ? valore_atr_short_origin : valore_atr_short1 // NO REPAINTING
  172.  
  173. atr_per_mult_short = valore_atr_short * in_atr_mult_short
  174. plot(atr_per_mult_short, title='atr_mult_short')
  175.  
  176. // >>>>>>>>>>>>>> End Detecting Atr Long E Short <<<<<<<<<<<<<<<<<
  177.  
  178.  
  179. // >>>>>>>>>>>>>> Start Detecting DMI <<<<<<<<<<<<<<<<<
  180.  
  181. // Filtro voglio che sia true se il +DI è sopra sia il -DI ed anche dell'ADX //21,3587
  182. // Per il calcolo dell'indicatore è stato richiamato l'indicatore originale e l'indicatore di 1na barra fa per non avere repainting usando l'operatore ternario
  183.  
  184. //[di_pos, di_neg, adx] = ta.dmi(14, 14)
  185. [di_pos_origin, di_neg_origin, adx] = ta.dmi(14, 14)
  186.  
  187. di_pos1 = di_pos_origin[1]
  188. di_neg1 = di_neg_origin[1]
  189.  
  190. di_pos = barstate.isconfirmed ? di_pos_origin : di_pos1
  191. di_neg = barstate.isconfirmed ? di_neg_origin : di_neg1
  192.  
  193.  
  194. //dmi_total_green_cross = di_pos > di_neg and di_pos > adx? true : false
  195. //dmi_total_green_cross = (di_pos - di_neg) > dma_min_diff_input ? true : false
  196. //dmi_total_green_cross = (di_neg - di_pos) > dmi_min_diff_input ? true : false
  197. //dmi_total_green_cross_short = (di_neg > adx + dmi_min_diff_input_short)  ? true : false
  198. //dmi_total_green_cross_long = (di_pos > adx + dmi_min_diff_input_long)  ? true : false
  199. //dmi_total_green_cross = (di_pos - di_neg) < dmi_min_diff_input  ? true : false
  200.  
  201. //plot(dmi_total_green_cross ? 1 : 0, title="dmi_total_green_cross")
  202.  
  203. // >>>>>>>>>>>>>> End Detecting DMI <<<<<<<<<<<<<<<<<
  204.  
  205.  
  206. // >>>>>>>>>>>>>> Start Plot Ingresso In Posizione <<<<<<<<<<<<<<<<<
  207.  
  208. 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
  209. 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
  210.  
  211. // >>>>>>>>>>>>>> End Plot Ingresso In Posizione <<<<<<<<<<<<<<<<<
  212.  
  213.  
  214. // >>>>>>>>>>>>>> Start Detecting No Trading Allowed <<<<<<<<<<<<<<<<<
  215.  
  216. // Plot No Trading Allowed giorni da 1 a 7 1 è domenica. Mesi da 1 a 12 1 è Gennaio.
  217.  
  218. //giorni_esclusi = dayofweek(time)
  219. //plotshape(giorni_esclusi[1] == 2 ? giorni_esclusi : na, color=color.green, title="giorni_esclusi")
  220. //mesi_esclusi = month(time)
  221. //plotshape(mesi_esclusi[1] == 9 ? mesi_esclusi : na, color=color.yellow, title="mesi_esclusi")
  222.  
  223. // >>>>>>>>>>>>>> Start Detecting No Trading Allowed <<<<<<<<<<<<<<<<<
  224.  
  225.  
  226. // >>>>>>>>>>>>>> Start Entry/Exit Conditions <<<<<<<<<<<<<<<<<
  227.  
  228. // Condizione Entry Long: Crossover chiusura media e media maggiore altra media
  229. condEntryLong = ta.crossover(close, media_high) and math.abs(open - close) > valore_atr_long * in_atr_mult_long and close > open and di_pos > dmi_min_diff_input_long and not onlyShort and inDateRange
  230. // Condizione Exit Long: Crossunder chiusura media
  231. condExitLong = ta.crossunder(close, media_high)
  232.  
  233. // Condizione Entry Short: Crossounder chiusura media e media minore altra media
  234. condEntryShort = ta.crossunder(close, media_low) and math.abs(open - close) > valore_atr_short * in_atr_mult_short and close < open and di_neg > dmi_min_diff_input_short and not onlyLong and inDateRange
  235. // Condizione Exit Short: Crossover chiusura media
  236. condExitShort = ta.crossover(close, media_low)
  237.  
  238. // >>>>>>>>>>>>>> End Entry/Exit Conditions <<<<<<<<<<<<<<<<<
  239.  
  240.  
  241. // >>>>>>>>>>>>>> Start Buy/Sell/Close Command <<<<<<<<<<<<<<<<<
  242.                
  243. buy_command = '{"BUY COMMAND"}'
  244. sell_command = '{"SELL COMMAND"}'
  245. close_command = '{"CLOSE COMMAND"}'  
  246. // cancel_command = '{"CANCEL COMMAND"}'
  247.  
  248. // >>>>>>>>>>>>>> End Buy/Sell/Close Command <<<<<<<<<<<<<<<<<
  249.  
  250. // // ============== Email Protection ===============
  251.  
  252. // 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
  253.  
  254. // Documentazione: https://www.tv-hub.org/Home/Documentation#email-signals
  255. // 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.
  256. // Email Protection da aggiungere a tutte le stringhe se utilizzata l'email protection "alertTimestamp":"{{ticker}}-{{time}}"
  257. // 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}}}'
  258. // 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
  259.  
  260.  
  261. // >>>>>>>>>>>>>> Start Execute Long And Short Open/Close Positions <<<<<<<<<<<<<<<<<
  262.  
  263. if condEntryLong
  264.     strategy.entry('long', strategy.long, alert_message = "Open Long Position", comment = buy_command)
  265.  
  266. if condExitLong
  267.     strategy.close(id='long', alert_message = "Close Long Position", comment = close_command)
  268.  
  269. if condEntryShort
  270.     strategy.entry('short', strategy.short, alert_message = "Open Short position", comment = sell_command)
  271.  
  272. if condExitShort
  273.     strategy.close(id='short', alert_message = "Close Short Position", comment = close_command)
  274.  
  275. // >>>>>>>>>>>>>> End Execute Long And Short Open/Close Positions <<<<<<<<<<<<<<<<<
  276.  
  277. // Nome Alert: Weekly-Mean-Trend ETH/USDT.P BYBIT 4H
  278. // Commento Alert: {{strategy.order.comment}}
  279. // Webhook Classico Più Sicuro Ma Più Lento: https://alerts.tv-hub.org  
  280. // Webhook Nuovo Meno Sicuro Ma Più Veloce: https://alerts.tv-hub.org/api/ExecuteTradeSignalClassic
  281.  
  282.  
  283. // ----------------- Inizio Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
  284.  
  285. // new_month = month(time) != month(time[1])
  286. // new_year  = year(time)  != year(time[1])
  287.  
  288. // eq = strategy.equity
  289.  
  290. // bar_pnl = eq / eq[1] - 1
  291.  
  292. // cur_month_pnl = 0.0
  293. // cur_year_pnl  = 0.0
  294.  
  295. // // Current Monthly P&L
  296. // cur_month_pnl := new_month ? 0.0 :
  297. //                  (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1
  298.  
  299. // // Current Yearly P&L
  300. // cur_year_pnl := new_year ? 0.0 :
  301. //                  (1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1  
  302.  
  303. // // Arrays to store Yearly and Monthly P&Ls
  304. // var month_pnl  = array.new_float(0)
  305. // var month_time = array.new_int(0)
  306.  
  307. // var year_pnl  = array.new_float(0)
  308. // var year_time = array.new_int(0)
  309.  
  310. // last_computed = false
  311.  
  312. // if (not na(cur_month_pnl[1]) and (new_month or barstate.islast))
  313. //     if (last_computed[1])
  314. //         array.pop(month_pnl)
  315. //         array.pop(month_time)
  316.  
  317. //     array.push(month_pnl , cur_month_pnl[1])
  318. //     array.push(month_time, time[1])
  319.  
  320. // if (not na(cur_year_pnl[1]) and (new_year or barstate.islast))
  321. //     if (last_computed[1])
  322. //         array.pop(year_pnl)
  323. //         array.pop(year_time)
  324.  
  325. //     array.push(year_pnl , cur_year_pnl[1])
  326. //     array.push(year_time, time[1])
  327.  
  328. // last_computed := barstate.islast ? true : nz(last_computed[1])
  329.  
  330. // // Monthly P&L Table    
  331. // var monthly_table = table(na)
  332. // prec      = input(2, title = "Return Precision")
  333.  
  334. // if (barstate.islast)
  335. //     monthly_table := table.new(position.bottom_right, columns = 14, rows = array.size(year_pnl) + 1, bgcolor=#0F0F0F,border_width=1,border_color=#000000)
  336.  
  337. //     table.cell(monthly_table, 0,  0, "",     text_color=#D3D3D3, bgcolor=#0F0F0F)
  338. //     table.cell(monthly_table, 1,  0, "Jan",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  339. //     table.cell(monthly_table, 2,  0, "Feb",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  340. //     table.cell(monthly_table, 3,  0, "Mar",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  341. //     table.cell(monthly_table, 4,  0, "Apr",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  342. //     table.cell(monthly_table, 5,  0, "May",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  343. //     table.cell(monthly_table, 6,  0, "Jun",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  344. //     table.cell(monthly_table, 7,  0, "Jul",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  345. //     table.cell(monthly_table, 8,  0, "Aug",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  346. //     table.cell(monthly_table, 9,  0, "Sep",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  347. //     table.cell(monthly_table, 10, 0, "Oct",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  348. //     table.cell(monthly_table, 11, 0, "Nov",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  349. //     table.cell(monthly_table, 12, 0, "Dec",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  350. //     table.cell(monthly_table, 13, 0, "Year", text_color=#D3D3D3, bgcolor=#0F0F0F)
  351.  
  352.  
  353. //     for yi = 0 to array.size(year_pnl) - 1
  354. //         table.cell(monthly_table, 0,  yi + 1, str.tostring(year(array.get(year_time, yi))), text_color=#D3D3D3, bgcolor=#0F0F0F)
  355.  
  356. //         y_color = array.get(year_pnl, yi) > 0 ? color.lime : color.red
  357. //         table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor = y_color)
  358.  
  359. //     for mi = 0 to array.size(month_time) - 1
  360. //         m_row   = year(array.get(month_time, mi))  - year(array.get(year_time, 0)) + 1
  361. //         m_col   = month(array.get(month_time, mi))
  362. //         m_color = array.get(month_pnl, mi) > 0 ? color.lime : color.red
  363.  
  364. //         table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor = m_color)
  365.  
  366. // ----------------- Fine Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
  367.  
  368.  
  369.  
  370.  
  371.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement