Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Maurizio-Ciullo
- //Il trading system completo - Swing-Trend-Trailing (Strategia Trend Following Con Swing Di Posizione) - parte 1
- // (Exchange= FTX) (Sottostante ETH-PERP) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=NO') (Esclusione Mesi=NO)
- // (Take Profit Long/Short Market = Trailing) (Take Profit Limit Long/Short= NO) (Stop Loss Limit Long/Short= -10%) (Stop Loss Market Long/Short= SI) (Trailing Stop=SI) (Stop Emergenza= NO)
- // (Rischio Operazione 2% Perdita Media)
- // (In Sample Dal=17/08/2017 Al 17/10/2020) (Out Of Sample Dal=18/10/2020 Al 15/03/2021)
- //@version=5
- //1. Strategia
- strategy(title='Bot Swing-Trend-Trailing ETH/PERP FTX 4H LONG E SHORT', overlay=true,
- max_bars_back=5000, // Serve Per Caricare Più Storico Per Il Trailing Stop
- pyramiding=0,
- initial_capital=150,
- commission_type=strategy.commission.percent,
- commission_value=0.1, slippage=3,
- default_qty_type=strategy.percent_of_equity,
- precision=2,
- default_qty_value=25.2)
- // Input
- input_ema = input.int(title='Media Ema', defval=90, minval=0, maxval=500)
- input_apertura_minima = input.float(title='perc_apertura_minima', defval=2, group='Filtri Posizione')
- input_apertura_massima = input.float(title='perc_apertura_massima', defval=4, group='Filtri Posizione ')
- input_chiusura_minima = input.float(title='perc_chiusura_minima', defval=0, group='Filtri Posizione')
- input_trailing_stop_trigger = input.float(title='input_trailing_stop_trigger', defval=12, group='trailing ')
- input_trailing_stop_close = input.float(title='input_trailing_stop_close', defval=6, group='trailing ')
- onlyLong = input.bool(title='Solo long', defval=false, inline='1', group='Direzione')
- onlyShort = input.bool(title='Solo short', defval=false, inline='1', group='Direzione')
- input_stop_loss_long = input.float(title='stop_loss_long', defval=10, minval=0, maxval=100, step=0.1, group='Stop Loss')
- input_stop_loss_short= input.float(title='stop_loss_short', defval=10, minval=0, maxval=100, step=0.1, group='Stop Loss')
- input_risk = input.float(title='Risk Per Trade %', defval=25.2, minval=0, maxval=100, step=0.01, group='Risk Per Trade %')
- // Calcolo del range del backtest
- startDate = input.int(title="Start Date",
- defval=17, minval=1, maxval=31, group="Periodo")
- startMonth = input.int(title="Start Month",
- defval=08, minval=1, maxval=12, group="Periodo")
- startYear = input.int(title="Start Year",
- defval=2016, minval=1800, maxval=2100, group="Periodo")
- endDate = input.int(title="End Date",
- defval=01, minval=1, maxval=31, group="Periodo")
- endMonth = input.int(title="End Month",
- defval=01, minval=1, maxval=12, group="Periodo")
- endYear = input.int(title="End Year",
- defval=2121, minval=1800, maxval=2150, group="Periodo")
- inDateRange = (time >= timestamp(syminfo.timezone, startYear,
- startMonth, startDate, 0, 0)) and
- (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
- // Start Hour Range Trading Non Attivo /////////////////////
- //hourTrading = input(title='sessione valida di trading', defval='0600-2300:23456')
- //hourRangeTrading = time(timeframe.period, hourTrading)
- //Calcolo degli indicatori
- // Variabili Medie Ema
- ema = ta.ema(close, input_ema)
- ema1 = ta.ema(close[1], input_ema)
- plot(ema, color=color.new(color.green, 0), title='Media_Ema', linewidth=2)
- //Calcolo filtri apertura minima
- apertura_minima = ema / 100 * input_apertura_minima
- apertura_minima1 = ema1 / 100 * input_apertura_minima
- apertura_massima = ema / 100 * input_apertura_massima
- chiusura_minima = ema / 100 * input_chiusura_minima
- // Filtri Bande Long
- filtro_long_basso = ema + apertura_minima
- filtro_long_alto = ema + apertura_massima
- //filtro_chiusura_minima_long =(ema - chiusura_minima)
- plot_filtro_long_basso = plot(filtro_long_basso, color=color.new(color.blue, 0), title='filtro_long_basso')
- plot_filtro_long_alto = plot(filtro_long_alto, color=color.new(color.blue, 0), title='filtro_long_alto')
- fill(plot_filtro_long_basso, plot_filtro_long_alto, title='Spazio di apertura', color=color.new(color.blue, 90))
- // Filtri Bande Short
- filtro_short_basso = ema - apertura_minima
- filtro_short_alto = ema - apertura_massima
- //filtro_chiusura_minima_short =(ema + chiusura_minima)
- plot_filtro_short_basso = plot(filtro_short_basso, color=color.new(color.red, 0), title='filtro_short_basso')
- plot_filtro_short_alto = plot(filtro_short_alto, color=color.new(color.red, 0), title='filtro_short_alto')
- fill(plot_filtro_short_basso, plot_filtro_short_alto, title='Spazio di apertura', color=color.new(color.red, 90))
- //plot_filtro_chiusura_minima_long=plot(filtro_chiusura_minima_long, color=color.blue, title="filtro_chiusura_minima_long")
- //plot_filtro_chiusura_minima_short=plot(filtro_chiusura_minima_short, color=color.red, title="filtro_chiusura_minima_short")
- //fill(p5,filtro_chiusura_minima_long, title = "Spazio di chiusura long", color = color.blue)
- //fill(p6,filtro_chiusura_minima_short, title = "Spazio di chiusura short", color = color.red)
- // Stop Loss Long E Short
- stop_loss_long_price = strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_stop_loss_long) / 100
- stop_loss_long = (strategy.opentrades.entry_price(0) - stop_loss_long_price) / syminfo.mintick
- // target_long_price = (strategy.opentrades.entry_price(0) + ((strategy.opentrades.entry_price(0) * input_take_profit_long) / 100))
- // target_long = (target_long_price - strategy.opentrades.entry_price(0)) / syminfo.mintick
- //plot(SLL, title = "stop ticks", color=color.purple)
- stop_loss_short_price = strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_stop_loss_short) / 100
- stop_loss_short = (stop_loss_short_price - strategy.opentrades.entry_price(0)) / syminfo.mintick
- // target_short_price = (strategy.opentrades.entry_price(0) - ((strategy.opentrades.entry_price(0) * input_take_profit_short) / 100))
- // target_short =(strategy.opentrades.entry_price(0) - target_short_price) / syminfo.mintick
- //plot(SLS, title = "stop ticks", color=color.purple)
- // Trailing Stop Long E Short
- trailing_stop_trigger_long = strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_trailing_stop_trigger)/100
- trailing_stop_close_long = strategy.opentrades.entry_price(0) + (strategy.opentrades.entry_price(0) * input_trailing_stop_close)/100
- trailing_stop_trigger_short = strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_trailing_stop_trigger)/100
- trailing_stop_close_short = strategy.opentrades.entry_price(0) - (strategy.opentrades.entry_price(0) * input_trailing_stop_close)/100
- // Originale Usato Nel codice
- // condExitLong2 = high >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[1] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[2] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[3] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or
- // high[4] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[5] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[6] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[7] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or
- // high[8] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[9] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[10] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[11] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or
- // high[12] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[13] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[14] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or high[15] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long or
- // high[16] >= trailing_stop_trigger_long and close < trailing_stop_close_long and close[1] > trailing_stop_close_long
- // condExitLong2 = high >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long) and close[1] > trailing_stop_close_long or high[1] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[2] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[3] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or
- // high[4] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[5] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[6] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[7] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or
- // high[8] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[9] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[10] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[11] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or
- // high[12] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[13] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[14] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or high[15] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long or
- // high[16] >= trailing_stop_trigger_long and ta.crossunder(close, trailing_stop_close_long ) and close[1] > trailing_stop_close_long
- // Originale Usato Nel Codice
- // condExitShort2 = low <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[1] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[2] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[3] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or
- // low[4] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[5] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[6] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[7] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or
- // low[8] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[9] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[10] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[11] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or
- // low[12] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[13] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[14] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or low[15] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short or
- // low[16] <= trailing_stop_trigger_short and close > trailing_stop_close_short and close[1] < trailing_stop_close_short
- // condExitShort2 = low <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[1] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[2] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[3] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or
- // low[4] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[5] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[6] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[7] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or
- // low[8] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[9] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[10] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[11] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or
- // low[12] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[13] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[14] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or low[15] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short or
- // low[16] <= trailing_stop_trigger_short and ta.crossover(close, trailing_stop_close_short) and close[1] < trailing_stop_close_short
- // Plot Ingresso In Posizione
- 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
- plot(strategy.position_size > 0 ? trailing_stop_trigger_long : strategy.position_size < 0 ? trailing_stop_trigger_short: na, color=color.blue, style=plot.style_cross, linewidth=2, title="trail_trigger")
- plot(strategy.position_size > 0 ? trailing_stop_close_long : strategy.position_size < 0 ? trailing_stop_close_short: na, color=color.blue, style=plot.style_cross, linewidth=2, title="trail_close")
- 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")
- 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
- // Calcolo Uscita Trailing Stop Long E Short
- // Bar_index = bar_index
- // plot(Bar_index, title = "Bar_index")
- // entry_bar_index = strategy.opentrades.entry_bar_index(0) +1
- // plot(entry_bar_index, title = "entry_bar_index")
- range_barre_trailing = bar_index - strategy.opentrades.entry_bar_index(0) +1
- //plot(lunghezza_trailing, title = 'lunghezza')
- highesthigh = strategy.opentrades ==1 ? ta.highest(high, range_barre_trailing): na
- //plot(highesthigh)
- lowestlow = strategy.opentrades ==1 ? ta.lowest(low, range_barre_trailing): na
- //plot(lowestlow)
- // Plot No Trading Allowed giorni da 1 a 7, 1 è domenica Mesi da 1 a 12, 1 è Gennaio.
- //giorni_esclusi = dayofweek(time)
- //plotshape(giorni_esclusi[1] == 2 ? giorni_esclusi : na, color=color.green, title="giorni_esclusi")
- //mesi_esclusi = month(time)
- //plotshape(mesi_esclusi[1] == 9 ? mesi_esclusi : na, color=color.yellow, title="mesi_esclusi")
- //Condizione Entrata Long: Chiusura candela sopra media lenta con differenziale medie e media veloce maggiore media ExitLong
- condEntryLong = close > ema + apertura_minima and close < ema + apertura_massima and close > open and not onlyShort and inDateRange and (close[1] < ema1 + apertura_minima or low[1] < ema1 + apertura_minima) // and dayofweek != 7 and month !=10
- //Condizione Uscita Long: Crossunder di due medie
- condExitLong = close < ema - chiusura_minima
- // Condizione Uscita Trailing Stop Long
- condExitLong2 = (highesthigh > trailing_stop_trigger_long and close <= trailing_stop_close_long)
- //Condizione Entrata Short: Crossunder di due medie con il prezzo di chiusura che è comunque sotto una terza media con differenziale delle medie
- condEntryShort = close < ema - apertura_minima and close > ema - apertura_massima and close < open and not onlyLong and inDateRange and (close[1] > ema1 - apertura_minima or high[1] > ema1 - apertura_minima) // and dayofweek != 7 and month !=10
- //Condizione Uscita Short: Crossover di medie con il prezzo di chiusura che è comunque sopra una terza media
- condExitShort = close > ema + chiusura_minima
- // Condizione Uscita Trailing Stop Short
- condExitShort2 = (lowestlow < trailing_stop_trigger_short and close >= trailing_stop_close_short)
- barcolor(condEntryLong ? color.lime : condEntryShort ? color.purple : na)
- // Allerts
- buy_command = '{"BUY COMMAND"}'
- sell_command = '{"SELL COMMAND"}'
- close_command = '{"CLOSE COMMAND"}'
- //entrata e uscita Long
- if condEntryLong
- strategy.entry('long', strategy.long, alert_message = "Open Long Position", comment = buy_command)
- strategy.exit('stop loss long', from_entry='long', loss=stop_loss_long, alert_message = "Your Long SL Has Been Triggered.", comment = close_command)
- if condExitLong
- strategy.close(id='long', alert_message = "Close Long Position", comment = close_command)
- if strategy.opentrades ==1 and condExitLong2
- strategy.close(id='long', alert_message = "Trailing long", comment = close_command)
- //entrata e uscita Short
- if condEntryShort
- strategy.entry('short', strategy.short, alert_message = "Open Short Position", comment = sell_command)
- strategy.exit('stop loss short', from_entry='short', loss=stop_loss_short, alert_message = "Your Short SL Has Been Triggered.", comment = close_command)
- if condExitShort
- strategy.close(id='short', alert_message = "Close Short Position", comment = close_command)
- if strategy.opentrades ==1 and condExitShort2
- strategy.close(id='short', alert_message = "Trailing Short", comment = close_command)
- // Nome Alert: Swing-Trend-Trailing ETH/PERP FTX 4H
- // Commento Alert: {{strategy.order.comment}}
- // ----------------- Inizio Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
- // new_month = month(time) != month(time[1])
- // new_year = year(time) != year(time[1])
- // eq = strategy.equity
- // bar_pnl = eq / eq[1] - 1
- // cur_month_pnl = 0.0
- // cur_year_pnl = 0.0
- // // Current Monthly P&L
- // cur_month_pnl := new_month ? 0.0 :
- // (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1
- // // Current Yearly P&L
- // cur_year_pnl := new_year ? 0.0 :
- // (1 + cur_year_pnl[1]) * (1 + bar_pnl) - 1
- // // Arrays to store Yearly and Monthly P&Ls
- // var month_pnl = array.new_float(0)
- // var month_time = array.new_int(0)
- // var year_pnl = array.new_float(0)
- // var year_time = array.new_int(0)
- // last_computed = false
- // if (not na(cur_month_pnl[1]) and (new_month or barstate.islast))
- // if (last_computed[1])
- // array.pop(month_pnl)
- // array.pop(month_time)
- // array.push(month_pnl , cur_month_pnl[1])
- // array.push(month_time, time[1])
- // if (not na(cur_year_pnl[1]) and (new_year or barstate.islast))
- // if (last_computed[1])
- // array.pop(year_pnl)
- // array.pop(year_time)
- // array.push(year_pnl , cur_year_pnl[1])
- // array.push(year_time, time[1])
- // last_computed := barstate.islast ? true : nz(last_computed[1])
- // // Monthly P&L Table
- // var monthly_table = table(na)
- // prec = input(2, title = "Return Precision")
- // if (barstate.islast)
- // monthly_table := table.new(position.bottom_right, columns = 14, rows = array.size(year_pnl) + 1, bgcolor=#0F0F0F,border_width=1,border_color=#000000)
- // table.cell(monthly_table, 0, 0, "", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 1, 0, "Jan", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 2, 0, "Feb", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 3, 0, "Mar", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 4, 0, "Apr", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 5, 0, "May", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 6, 0, "Jun", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 7, 0, "Jul", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 8, 0, "Aug", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 9, 0, "Sep", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 10, 0, "Oct", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 11, 0, "Nov", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 12, 0, "Dec", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // table.cell(monthly_table, 13, 0, "Year", text_color=#D3D3D3, bgcolor=#0F0F0F)
- // for yi = 0 to array.size(year_pnl) - 1
- // table.cell(monthly_table, 0, yi + 1, str.tostring(year(array.get(year_time, yi))), text_color=#D3D3D3, bgcolor=#0F0F0F)
- // y_color = array.get(year_pnl, yi) > 0 ? color.lime : color.red
- // table.cell(monthly_table, 13, yi + 1, str.tostring(math.round(array.get(year_pnl, yi) * 100, prec)), bgcolor = y_color)
- // for mi = 0 to array.size(month_time) - 1
- // m_row = year(array.get(month_time, mi)) - year(array.get(year_time, 0)) + 1
- // m_col = month(array.get(month_time, mi))
- // m_color = array.get(month_pnl, mi) > 0 ? color.lime : color.red
- // table.cell(monthly_table, m_col, m_row, str.tostring(math.round(array.get(month_pnl, mi) * 100, prec)), bgcolor = m_color)
- // ----------------- Fine Tabella risultati mensili. Per visualizzare andare nelle impostazioni proprietà e spuntare ad ogni tick -----------------
Add Comment
Please, Sign In to add comment