Advertisement
Maurizio-Ciullo

Bot Over The Clouds ETH/USDT.P BYBIT 4H LONG E SHORT

Jun 8th, 2023 (edited)
1,758
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. // © Maurizio-Ciullo
  3.  
  4.                                     // Versione con uscita chiusuara sotto la baseline //
  5.  
  6. // Il trading system completo - Over The Clouds ETH/USDT.P BYBIT 4H LONG E SHORT (Trend Following)
  7. // (Sviluppo Dati Exchange = BINANCE + BYBIT) (BINANCE Dal=18/08/2017 Al 21/10/2020) (BYBIT Dal=21/10/2020 Al 20/05/2023)
  8. // (Exchange= BYBIT) (Sottostante ETH-USDT.P) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=NO) (Esclusione Mesi=NO)
  9. // (Take Profit Long/Short Market = NO) (Take Profit Limit Long/Short= NO)
  10. // (Stop Loss Limit Long= NO) (Stop Loss Limit Short= NO) (Stop Loss Market Long/Short= SI) (Trailing Stop Market=SI) (Stop Emergenza= NO)
  11. // (Rischio Operazione 2% Perdita Media Calcolato Sul Ticker: ETHUSDT BINANCE SPOT) (Max Drawdown Permesso 10,03% Calcolato Sul Ticker: ETHUSDT.P BYBIT CHE E' IL PEGGIORE DELLE ENTRIES MODE)
  12. // (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
  13. // (In Sample Dal=18/08/17 Al 12/07/22) (Out Of Sample Dal=12/07/22 Al 20/05/23)
  14. // (Money Management = 25% Del Capitale Tradestation)  
  15. // (Money Management = 17% Del Capitale Tradingview) Preso Dal 15% Media Max Drawdown 2°nda Deviazione Standard Simulazione Montecarlo Python
  16. // (Progettatta Il=07/07/23)
  17.  
  18.  
  19. // Caricamento Dati Bybit Su Tradestation: Exchange Time, Regular Session, 7x7 23:00 23:00, Session Hour.
  20. // Auentare il Max Bars Back A 75 Su Tradestation Altrimenti Non Funziona E Cliccare Su Enable Strategy Altrimenti Non Parte
  21.  
  22.                                                     // ATTENZIONE //
  23. // Quando si mette la strategia live, ricordarsi di impostare 1 solo input "quello che vogliamo utilizzare come normal/ more_aggressive/less_aggressive entries" su true e
  24. // impostare gli altri su false. Commentare anche i BUY COMMAND che non utilizziamo.
  25.  
  26. //@version=5
  27. strategy(title='Bot Over-The-Clouds ETH/USDT.P BYBIT 4H LONG E SHORT', overlay=true,
  28.          //max_bars_back=5000, // Serve Per Caricare Più Storico Per Il Trailing Stop
  29.          pyramiding=0,
  30.          initial_capital=500,
  31.          commission_type=strategy.commission.percent,
  32.          commission_value=0.1,
  33.          slippage=3,
  34.          default_qty_type=strategy.percent_of_equity,
  35.          precision=2,
  36.          default_qty_value=17)
  37.  
  38.  
  39. // Inputs
  40. onlyLong = input.bool(title='Solo long', defval=false, inline='1', group='Direction')
  41. onlyShort = input.bool(title='Solo short', defval=false, inline='1', group='Direction')
  42. in_normal = input.bool(title="normal entry mode", defval=true, tooltip = "Entry Conditions Choice", inline='1', group='Aggresivity Entries Noraml')
  43. in_more_aggressive = input.bool(title="more aggressive entry mode", defval=false, tooltip = "Entry Conditions Choice", inline='1', group='Aggresivity Entries Aggresive')
  44. in_less_aggressive = input.bool(title="less aggressive entry mode", defval=false, tooltip = "Entry Conditions Choicee", inline='1', group='Aggresivity Entries Less Aggressive')
  45. in_ema_long = input.int(title='in_ema_long', defval=84, minval=0, maxval=300, step=1, inline='1', group='Ema Lenght')
  46. in_ema_short = input.int(title='in_ema_short', defval=83, minval=0, maxval=300, step=1, inline='1', group='Ema Lenght')
  47.  
  48.  
  49. // Calcolo del range del backtest
  50. startDate = input.int(title='Start Date', defval=17, minval=1, maxval=31, group='Time Window')
  51. startMonth = input.int(title='Start Month', defval=08, minval=1, maxval=12, group='Time Window')
  52. startYear = input.int(title='Start Year', defval=2000, minval=1800, maxval=2100, group='Time Window')
  53.  
  54. endDate = input.int(title='End Date', defval=01, minval=1, maxval=31, group='Time Window')
  55. endMonth = input.int(title='End Month', defval=01, minval=1, maxval=12, group='Time Window')
  56. endYear = input.int(title='End Year', defval=2121, minval=1800, maxval=2150, group='Time Window')
  57.  
  58.  
  59. inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0)
  60.  
  61.  
  62. // Start Hour Range Trading Non Attivo /////////////////////
  63. //hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
  64. //hourRangeTrading = time(timeframe.period, hourTrading)
  65.  
  66.  
  67. // Start Detecting Ichimoku Cloud //
  68. conversionPeriods = input.int(9, minval=1, title="Conversion Line Periods", group='Ichomoku'),
  69. basePeriods = input.int(26, minval=1, title="Base Line Periods", group='Ichomoku')
  70. laggingSpan2Periods = input.int(52, minval=1, title="Lagging Span 2 Periods", group='Ichomoku'),
  71. displacement = input.int(26, minval=1, title="Displacement", group='Ichomoku')
  72.  
  73. donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
  74.  
  75. conversionLine = donchian(conversionPeriods)
  76. baseLine = donchian(basePeriods)
  77. spanA = math.avg(conversionLine, baseLine)
  78. spanB = donchian(laggingSpan2Periods)
  79. StdLine = (ta.highest(high, 52) + ta.lowest(low, 52)) / 2
  80. plot(conversionLine, title="Conversion Line", color=#0496ff)
  81. plot(baseLine, color=#991515, title="Base Line")
  82. plot(close, title="Lagging Span", offset = -displacement + 1, color=#459915)
  83.  
  84. p1 = plot(spanA, offset = displacement - 1, color=color.green,
  85.  title="Plot Span A")
  86. p2 = plot(spanB, offset = displacement - 1, color=color.red,
  87.  title="Plot Span B")
  88. fill(p1, p2, color = spanA > spanB ? color.green : color.red)
  89. // plot(spanA[25], title="Span A", color=color.orange)
  90. // plot(spanB[25],  title="Span B",color=color.yellow)
  91. // plot(spanA, title="Span A No 25 Offset", color=color.rgb(218, 16, 253))
  92. // plot(spanB, title="Span B No 25 Offset", color=color.rgb(218, 16, 253))
  93. // End Detecting Ichimoku Cloud //
  94.  
  95.  
  96. // Start Detecting ATR Long Normal //
  97. in_length_atr_long_normal = input.int(title="Atr Length_long_normal", defval=11, minval=0, group='Atr Long Normal')
  98. in_smoothing_atr_long_normal = input.string(title="Smoothing_atr_long_normal", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group='Atr Long Normal')
  99. ma_function_long(source, in_length_atr_long_normal) =>
  100.     switch in_smoothing_atr_long_normal
  101.         "RMA" => ta.rma(source, in_length_atr_long_normal)
  102.         "SMA" => ta.sma(source, in_length_atr_long_normal)
  103.         "EMA" => ta.ema(source, in_length_atr_long_normal)
  104.         => ta.wma(source, in_length_atr_long_normal)
  105. plot(ma_function_long(ta.tr(true), in_length_atr_long_normal), title = "ATR_long_normal", color=color.new(#ca5555, 0))
  106. // End Detecting ATR Long Normal //
  107.  
  108. // Start Detecting ATR Long More Aggressive //
  109. in_length_atr_long_more_aggressive = input.int(title="Atr Length_long_more_aggressive", defval=7, minval=0, group='Atr Long More Aggresive')
  110. in_smoothing_atr_long_more_aggressive = input.string(title="Smoothing_atr_long_more_aggressive", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group='Atr Long More Aggresive')
  111. ma_function_long_more_aggressive(source, in_length_atr_long_more_aggressive) =>
  112.     switch in_smoothing_atr_long_more_aggressive
  113.         "RMA" => ta.rma(source, in_length_atr_long_more_aggressive)
  114.         "SMA" => ta.sma(source, in_length_atr_long_more_aggressive)
  115.         "EMA" => ta.ema(source, in_length_atr_long_more_aggressive)
  116.         => ta.wma(source, in_length_atr_long_more_aggressive)
  117. plot(ma_function_long_more_aggressive(ta.tr(true), in_length_atr_long_more_aggressive), title = "ATR_long_more_aggressive", color=color.new(#ff4646, 0))
  118. // End Detecting ATR Long More Aggressive //
  119.  
  120. // Start Detecting ATR Long Less Aggressive //
  121. in_length_atr_long_less_aggressive = input.int(title="Atr Length_long_less_aggressive", defval=12, minval=0, group='Atr Long Less Aggresive')
  122. in_smoothing_atr_long_less_aggressive = input.string(title="Smoothing_atr_long_less_aggressive", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group='Atr Long Less Aggresive')
  123. ma_function_long_less_aggressive(source, in_length_atr_long_less_aggressive) =>
  124.     switch in_smoothing_atr_long_less_aggressive
  125.         "RMA" => ta.rma(source, in_length_atr_long_less_aggressive)
  126.         "SMA" => ta.sma(source, in_length_atr_long_less_aggressive)
  127.         "EMA" => ta.ema(source, in_length_atr_long_less_aggressive)
  128.         => ta.wma(source, in_length_atr_long_less_aggressive)
  129. plot(ma_function_long_less_aggressive(ta.tr(true), in_length_atr_long_less_aggressive), title = "ATR_long_less__aggressive", color=color.new(#ff4646, 0))
  130. // End Detecting ATR Long Less Aggressive //
  131.  
  132.  
  133. // Start Detecting ATR Short //
  134. in_length_atr_short = input.int(title="Atr Length_short", defval=11, minval=0, group='Atr Short')
  135. in_smoothing_atr_short = input.string(title="Smoothing_atr_short", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group='Atr Short')
  136. ma_function_short(source, in_length_atr_short) =>
  137.     switch in_smoothing_atr_short
  138.         "RMA" => ta.rma(source, in_length_atr_short)
  139.         "SMA" => ta.sma(source, in_length_atr_short)
  140.         "EMA" => ta.ema(source, in_length_atr_short)
  141.         => ta.wma(source, in_length_atr_short)
  142. plot(ma_function_short(ta.tr(true), in_length_atr_short), title = "ATR_short", color=color.new(#B71C1C, 0))
  143. // End Detecting ATR Short //
  144.  
  145.  
  146. // Start Detecting Boom Bar Long (Normal-Aggressive-Less_aggressive//
  147. atr_long_normal = ma_function_long(ta.tr(true), in_length_atr_long_normal)
  148. atr_long_more_aggressive = ma_function_long_more_aggressive(ta.tr(true), in_length_atr_long_more_aggressive)
  149. atr_long_less_aggressive = ma_function_long_less_aggressive(ta.tr(true), in_length_atr_long_less_aggressive)
  150. in_atr_Mult_long_normal = input.float(title='atr_Mult_long_normal', minval=0, maxval=5, defval=1.2, step=0.1, group='Atr Long Normal')
  151. in_atr_Mult_long_more_aggressive = input.float(title='atr_Mult_long_more_aggressive', minval=0, maxval=5, defval=1.2, step=0.1, group='Atr Long More Aggresive')
  152. in_atr_Mult_long_less_aggressive = input.float(title='atr_Mult_long_less_aggressive', minval=0, maxval=5, defval=1.2, step=0.1, group='Atr Long Less Aggresive')
  153. boom_bar_long_normal = math.abs(open - close) > atr_long_normal * in_atr_Mult_long_normal
  154. boom_bar_long_more_aggressive = math.abs(open - close) > atr_long_more_aggressive * in_atr_Mult_long_more_aggressive
  155. boom_bar_long_less_aggressive = math.abs(open - close) > atr_long_less_aggressive * in_atr_Mult_long_less_aggressive
  156. // End Detecting Boom Bar Long //
  157.  
  158.  
  159. // Start Detecting Boom Bar Short //
  160. atr_short = ma_function_short(ta.tr(true), in_length_atr_short)
  161. in_atr_Mult_short = input.float(title='atr_Mult_short', minval=0, maxval=5, defval=1.2, step=0.1, group='Atr Short')
  162. boom_bar_short = math.abs(open - close) > atr_short * in_atr_Mult_short
  163. // End Detecting Boom Bar Short //
  164.  
  165. barcolor(boom_bar_long_normal and in_normal and not in_more_aggressive and not in_less_aggressive ? color.lime : boom_bar_short and in_normal and not in_more_aggressive and not in_less_aggressive ? color.lime : na)
  166. barcolor(boom_bar_long_more_aggressive and in_more_aggressive and not in_normal and not in_less_aggressive ? color.lime : boom_bar_short and in_more_aggressive and not in_normal and not in_less_aggressive ? color.lime : na)
  167. barcolor(boom_bar_long_less_aggressive and in_less_aggressive and not in_normal and not in_more_aggressive ? color.lime : boom_bar_short and in_less_aggressive and not in_normal and not in_more_aggressive ? color.lime : na)
  168.  
  169.  
  170. // Start Detecting Ema Long And Short //
  171. ema_long = ta.ema(close, in_ema_long)
  172. plot(ema_long, title="ema_long", color=color.green, linewidth = 2)
  173.  
  174. ema_short = ta.ema(close, in_ema_short)
  175. plot(ema_short, title="ema_short", color=color.red, linewidth = 2)
  176. // End Detecting Ema Long And Short //
  177.  
  178.  
  179. 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
  180. //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")
  181. //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")
  182.  
  183. 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 //color.new(color.red, 99): na)
  184.  
  185.  
  186. // Plot No Trading Allowed giorni da 1 a 7 1 è domenica. Mesi da 1 a 12 1 è Gennaio. //
  187.  
  188. // giorni_esclusi = dayofweek(time)
  189. // plotshape(giorni_esclusi[1] == 2 ? giorni_esclusi : na, color=color.green, title="giorni_esclusi")
  190. // mesi_esclusi = month(time)
  191. // plotshape(mesi_esclusi[1] == 9 ? mesi_esclusi : na, color=color.yellow, title="mesi_esclusi")
  192.  
  193.  
  194. // Stringhe esecuzione ordini 3rze parti TV-HUB.ORG
  195. buy_command = 'BUY COMMAND'
  196. sell_command = 'SELL COMMAND'
  197. close_command = 'CLOSE COMMAND'
  198. //cancel_command = 'CANCEL COMMAND'
  199.  
  200.  
  201. // // ============== Email Protection ===============
  202.  
  203. // 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
  204.  
  205. // Documentazione: https://www.tv-hub.org/Home/Documentation#email-signals
  206. // 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.
  207. // Email Protection da aggiungere a tutte le stringhe se utilizzata l'email protection "alertTimestamp":"{{ticker}}-{{time}}"
  208. // 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}}}'
  209. // 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
  210.  
  211.  
  212. // Start Entry Conditions Long And Short //
  213. entry_long = close > baseLine and conversionLine>baseLine and close>spanB  and close > ema_long  and boom_bar_long_normal and inDateRange and not onlyShort and in_normal and not in_more_aggressive and not in_less_aggressive
  214. entry_long_more_aggressive = close > baseLine and conversionLine>baseLine and close>spanB  and close > ema_long  and boom_bar_long_more_aggressive and inDateRange and not onlyShort and in_more_aggressive and not in_normal and not in_less_aggressive
  215. entry_long_less_aggressive = close > baseLine and conversionLine>baseLine and close>spanB  and close > ema_long  and boom_bar_long_less_aggressive and inDateRange and not onlyShort and in_less_aggressive and not in_normal and not in_more_aggressive
  216. entry_short = close < baseLine and conversionLine<baseLine and close<spanB  and close < ema_short and boom_bar_short and inDateRange and not onlyLong and ((in_normal and not in_more_aggressive and not in_less_aggressive) or (in_more_aggressive and not in_normal and not in_less_aggressive) or (in_less_aggressive and not in_normal and not in_more_aggressive))
  217. //  End Entry Conditions Long And Short //
  218.  
  219.  
  220. // Start Exit Conditions Long And Short //
  221. exit_long = close < baseLine
  222. exit_short = close > baseLine
  223. // End Exit Conditions Long And Short //
  224.  
  225. plot(strategy.opentrades)
  226.  
  227.  
  228. // Entry Exit Long / Short
  229. if entry_long // and strategy.opentrades == 0
  230.     strategy.entry('long', strategy.long, alert_message = "Open Long Position", comment = buy_command)
  231. if entry_long_more_aggressive
  232.     strategy.entry('long', strategy.long, alert_message = "Open Long Position More Aggressive")//, comment = buy_command)
  233. if entry_long_less_aggressive
  234.     strategy.entry('long', strategy.long, alert_message = "Open Long Position Less Aggressive")//, comment = buy_command)
  235. if exit_long
  236.     strategy.close(id='long', alert_message = "Close Long Position", comment = close_command)
  237.  
  238. if entry_short // and strategy.opentrades == 0
  239.     strategy.entry('short', strategy.short, alert_message = "Open Short Position", comment = sell_command)
  240. if exit_short
  241.     strategy.close(id='short', alert_message = "Close Short Position", comment = close_command)
  242.  
  243.  
  244. // Nome Alert: Over-The-Clouds ETH/USDT.P BYBIT 4H
  245. // Commento Alert: {{strategy.order.comment}}
  246. // Webhook Classico Più Sicuro Ma Più Lento: https://alerts.tv-hub.org  
  247. // Webhook Nuovo Meno Sicuro Ma Più Veloce: https://alerts.tv-hub.org/api/ExecuteTradeSignalClassic
  248.  
  249.  
  250. // ------- Inizio Calcolatore Size Posizioni Aperte E Size Posizioni Residue E Segna Con Una Croce Se Abbiamo Realizzato Un Profitto ------- //
  251.                                    // Il Segno Croce Profitto Realizzato Non Funziona Sullo Swing Posizione //
  252.  
  253. // bought = strategy.position_size[0]> strategy.position_size[1]
  254. // Close_TP = false    
  255. // Close_TP := strategy.position_size[1] - strategy.position_size[0] and strategy.position_size[1] != 0 and strategy.position_size[0] != 0
  256.    
  257. // plotshape(Close_TP,title="Close_TP", style=shape.xcross, color=color.blue, size =size.small, editable = true)
  258. // plot(strategy.position_size[1],"Position Old")
  259. // plot(strategy.position_size,"Position")
  260.  
  261. // ------- Fine Calcolatore Size Posizioni Aperte E Size Posizioni Residue E Segna Con Una Croce Se Abbiamo Realizzato Un Profitto ------- //
  262.  
  263.  
  264. // ----------------- Inizio Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
  265.  
  266. // new_month = month(time) != month(time[1])
  267. // new_year  = year(time)  != year(time[1])
  268.  
  269. // eq = strategy.equity
  270.  
  271. // bar_pnl = eq / eq[1] - 1
  272.  
  273. // cur_month_pnl = 0.0
  274. // cur_year_pnl  = 0.0
  275.  
  276. // // Current Monthly P&L
  277. // cur_month_pnl := new_month ? 0.0 :
  278. //                  (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1
  279.  
  280. // // Current Yearly P&L
  281. // cur_year_pnl := new_year ? 0.0 :
  282. //                  (1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1  
  283.  
  284. // // Arrays to store Yearly and Monthly P&Ls
  285. // var month_pnl  = array.new_float(0)
  286. // var month_time = array.new_int(0)
  287.  
  288. // var year_pnl  = array.new_float(0)
  289. // var year_time = array.new_int(0)
  290.  
  291. // last_computed = false
  292.  
  293. // if (not na(cur_month_pnl[1]) and (new_month or barstate.islast))
  294. //     if (last_computed[1])
  295. //         array.pop(month_pnl)
  296. //         array.pop(month_time)
  297.  
  298. //     array.push(month_pnl , cur_month_pnl[1])
  299. //     array.push(month_time, time[1])
  300.  
  301. // if (not na(cur_year_pnl[1]) and (new_year or barstate.islast))
  302. //     if (last_computed[1])
  303. //         array.pop(year_pnl)
  304. //         array.pop(year_time)
  305.  
  306. //     array.push(year_pnl , cur_year_pnl[1])
  307. //     array.push(year_time, time[1])
  308.  
  309. // last_computed := barstate.islast ? true : nz(last_computed[1])
  310.  
  311. // // Monthly P&L Table    
  312. // var monthly_table = table(na)
  313. // prec      = input(2, title = "Return Precision")
  314.  
  315. // if (barstate.islast)
  316. //     monthly_table := table.new(position.bottom_right, columns = 14, rows = array.size(year_pnl) + 1, bgcolor=#0F0F0F,border_width=1,border_color=#000000)
  317.  
  318. //     table.cell(monthly_table, 0,  0, "",     text_color=#D3D3D3, bgcolor=#0F0F0F)
  319. //     table.cell(monthly_table, 1,  0, "Jan",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  320. //     table.cell(monthly_table, 2,  0, "Feb",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  321. //     table.cell(monthly_table, 3,  0, "Mar",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  322. //     table.cell(monthly_table, 4,  0, "Apr",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  323. //     table.cell(monthly_table, 5,  0, "May",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  324. //     table.cell(monthly_table, 6,  0, "Jun",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  325. //     table.cell(monthly_table, 7,  0, "Jul",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  326. //     table.cell(monthly_table, 8,  0, "Aug",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  327. //     table.cell(monthly_table, 9,  0, "Sep",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  328. //     table.cell(monthly_table, 10, 0, "Oct",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  329. //     table.cell(monthly_table, 11, 0, "Nov",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  330. //     table.cell(monthly_table, 12, 0, "Dec",  text_color=#D3D3D3, bgcolor=#0F0F0F)
  331. //     table.cell(monthly_table, 13, 0, "Year", text_color=#D3D3D3, bgcolor=#0F0F0F)
  332.  
  333.  
  334. //     for yi = 0 to array.size(year_pnl) - 1
  335. //         table.cell(monthly_table, 0,  yi + 1, str.tostring(year(array.get(year_time, yi))), text_color=#D3D3D3, bgcolor=#0F0F0F)
  336.  
  337. //         y_color = array.get(year_pnl, yi) > 0 ? color.lime : color.red
  338. //         table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor = y_color)
  339.  
  340. //     for mi = 0 to array.size(month_time) - 1
  341. //         m_row   = year(array.get(month_time, mi))  - year(array.get(year_time, 0)) + 1
  342. //         m_col   = month(array.get(month_time, mi))
  343. //         m_color = array.get(month_pnl, mi) > 0 ? color.lime : color.red
  344.  
  345. //         table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor = m_color)
  346.  
  347. // ----------------- Fine Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement