Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------*(Lezione 35 Personale Creare Dei Filtri Giornalieri E Mensili E Orari)*----------------------------------------
- 1) Creare input buleani true e false per i giorni della settimana e per i mesi dell'anno. Group crea una categoria nelle impostazioni.
- 2) Creo 2 variabili 1 long e 1 short e dentro: (trade_long_on_dow_1 and dayofweek == 1) or (trade_long_on_dow_2 and dayofweek == 2)....etc... .
- gli dico che se trade_long_on_dow_1 è true e lo è ... e anche dayofweek == 1 è true sono true tutti e 2 e quindi validi quando li seleziono.
- 3) Posso aggiungere dei filtri di sicurezza per chiudere le posizioni aperte se si trovano aperte nel mese che ho scartato.
- Le posizione aperte senza questo filtro if rimarranno aperte finchè il codice non le chiude come prestabilito, quindi potremmo trovare
- delle posizioni aperte a Maggio e chiuse A Giungo anche se Giungo lo abbiamo escluso se non usiamo il filtro if che chiude tutte le posizioni.
- 4) Inserisco la variabili con and iniziale dentro le condizioni di entrata sia long che short se previsto.
- //1)
- // Include or Exclude Days of the Week
- // Trade_long_on_dow_1 is Sunday/Domenica
- // Trade_long_on_dow_2 is Monday/Lunedì Etc...
- // If a position is opened it will be closed as srategy without excluding the month
- trade_long_on_dow_1 = input(true, group="Include/Esclude Giorni Long")
- trade_long_on_dow_2 = input(true, group="Include/Esclude Giorni Long")
- trade_long_on_dow_3 = input(true, group="Include/Esclude Giorni Long")
- trade_long_on_dow_4 = input(true, group="Include/Esclude Giorni Long")
- trade_long_on_dow_5 = input(true, group="Include/Esclude Giorni Long")
- trade_long_on_dow_6 = input(true, group="Include/Esclude Giorni Long")
- trade_long_on_dow_7 = input(true, group="Include/Esclude Giorni Long")
- trade_short_on_dow_1 = input(true, group="Include/Esclude Giorni Short")
- trade_short_on_dow_2 = input(true, group="Include/Esclude Giorni Short")
- trade_short_on_dow_3 = input(true, group="Include/Esclude Giorni Short")
- trade_short_on_dow_4 = input(true, group="Include/Esclude Giorni Short")
- trade_short_on_dow_5 = input(true, group="Include/Esclude Giorni Short")
- trade_short_on_dow_6 = input(true, group="Include/Esclude Giorni Short")
- trade_short_on_dow_7 = input(true, group="Include/Esclude Giorni Short")
- //2)
- trade_long_today = (trade_long_on_dow_1 and dayofweek == 1) or (trade_long_on_dow_2 and dayofweek == 2) or (trade_long_on_dow_3 and dayofweek == 3) or (trade_long_on_dow_4 and dayofweek == 4) or (trade_long_on_dow_5 and dayofweek == 5) or (trade_long_on_dow_6 and dayofweek == 6) or (trade_long_on_dow_7 and dayofweek == 7)
- trade_short_today = (trade_short_on_dow_1 and dayofweek == 1) or (trade_short_on_dow_2 and dayofweek == 2) or (trade_short_on_dow_3 and dayofweek == 3) or (trade_short_on_dow_4 and dayofweek == 4) or (trade_short_on_dow_5 and dayofweek == 5) or (trade_short_on_dow_6 and dayofweek == 6) or (trade_short_on_dow_7 and dayofweek == 7)
- //3)
- // Exit open market position when date range ends
- //if (not trade_long_today)
- // strategy.close_all()
- //if (not trade_short_today)
- // strategy.close_all()
- // Include or Exclude Moths of the Year
- // Trade_long_on_dow_1 is Sunday/Domenica
- // Trade_long_on_dow_2 is Monday/Lunedì Etc...
- // If a position is opened it will be closed as srategy without excluding the month
- trade_long_on_dow_month_1 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_2 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_3 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_4 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_5 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_6 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_7 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_8 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_9 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_10 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_11 = input(true, group="Include/Esclude Mesi Long")
- trade_long_on_dow_month_12 = input(true, group="Include/Esclude Mesi Long")
- trade_short_on_dow_month_1 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_2 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_3 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_4 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_5 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_6 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_7 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_8 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_9 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_10 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_11 = input(true, group="Include/Esclude Mesi Short")
- trade_short_on_dow_month_12 = input(true, group="Include/Esclude Mesi Short")
- trade_long_this_month = (trade_long_on_dow_month_1 and month == 1) or (trade_long_on_dow_month_2 and month == 2) or (trade_long_on_dow_month_3 and month == 3) or (trade_long_on_dow_month_4 and month == 4) or (trade_long_on_dow_month_5 and month == 5) or (trade_long_on_dow_month_5 and month == 5) or (trade_long_on_dow_month_6 and month == 6) or (trade_long_on_dow_month_7 and month == 7) or (trade_long_on_dow_month_8 and month == 8) or (trade_long_on_dow_month_9 and month == 9) or (trade_long_on_dow_month_10 and month == 10) or (trade_long_on_dow_month_11 and month == 11) or (trade_long_on_dow_month_12 and month == 12)
- trade_short_this_month = (trade_short_on_dow_month_1 and month == 1) or (trade_short_on_dow_month_2 and month == 2) or (trade_short_on_dow_month_3 and month == 3) or (trade_short_on_dow_month_4 and month == 4) or (trade_short_on_dow_month_5 and month == 5) or (trade_short_on_dow_month_5 and month == 5) or (trade_short_on_dow_month_6 and month == 6) or (trade_short_on_dow_month_7 and month == 7) or (trade_short_on_dow_month_8 and month == 8) or (trade_short_on_dow_month_9 and month == 9) or (trade_short_on_dow_month_10 and month == 10) or (trade_short_on_dow_month_11 and month == 11) or (trade_short_on_dow_month_12 and month == 12)
- // Exit open market position when date range ends
- //if (trade_long_this_month)
- // strategy.close_all()
- //if (trade_short_this_month)
- // strategy.close_all()
- //4)
- condEntryLong = close > maSlowLong and (maFastLong - maSlowLong) > etc..... and trade_long_today and trade_long_this_month
- -------------------------------------------------------------------------------------------------------------------------------------
- // Include or Exclude Hours of the Day
- // Include or Exclude Hours of the Day
- // Trade_long_on_dow_0 is 02:00 AM Confrontare Sempre Con Exchange
- // Trade_long_on_dow_1 is 03:00 AM Confrontare Sempre Con Exchange
- // If a position is opened it will be closed as srategy without excluding the hour
- trade_long_on_dow_0 = input(true, group="Include/Esclude Ore Long", tooltip=" Trade_long_on_dow_0 is 02:00 AM Confrontare Sempre Con Exchange")
- trade_long_on_dow_1 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_2 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_3 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_4 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_5 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_6 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_7 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_8 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_9 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_10 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_11 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_12 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_13 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_14 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_15 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_16 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_17 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_18 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_19 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_20 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_21 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_22 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_23 = input(true, group="Include/Esclude Ore Long")
- trade_long_on_dow_24 = input(true, group="Include/Esclude Ore Long")
- trade_short_on_dow_0 = input(true, group="Include/Esclude Ore Short", tooltip=" Trade_short_on_dow_0 is 02:00 AM Confrontare Sempre Con Exchange")
- trade_short_on_dow_1 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_2 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_3 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_4 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_5 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_6 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_7 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_8 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_9 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_10 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_11 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_12 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_13 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_14 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_15 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_16 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_17 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_18 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_19 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_20 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_21 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_22 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_23 = input(true, group="Include/Esclude Ore Short")
- trade_short_on_dow_24 = input(true, group="Include/Esclude Ore Short")
- trade_long_hour_today = (trade_long_on_dow_0 and hour == 0) or (trade_long_on_dow_1 and hour == 1) or (trade_long_on_dow_2 and hour == 2) or (trade_long_on_dow_3 and hour == 3) or (trade_long_on_dow_4 and hour == 4) or (trade_long_on_dow_5 and hour == 5) or (trade_long_on_dow_6 and hour == 6) or (trade_long_on_dow_7 and hour == 7) or (trade_long_on_dow_8 and hour == 8) or (trade_long_on_dow_9 and hour == 9) or (trade_long_on_dow_10 and hour == 10) or (trade_long_on_dow_11 and hour == 11) or (trade_long_on_dow_12 and hour == 12) or (trade_long_on_dow_13 and hour == 13) or (trade_long_on_dow_14 and hour == 14) or (trade_long_on_dow_15 and hour == 15) or (trade_long_on_dow_16 and hour == 16) or (trade_long_on_dow_17 and hour == 17) or (trade_long_on_dow_18 and hour == 18) or (trade_long_on_dow_19 and hour == 19) or (trade_long_on_dow_20 and hour == 20) or (trade_long_on_dow_21 and hour == 21) or (trade_long_on_dow_22 and hour == 22) or (trade_long_on_dow_23 and hour == 23) or (trade_long_on_dow_24 and hour == 24)
- trade_short_hour_today = (trade_short_on_dow_0 and hour == 0) or (trade_short_on_dow_1 and hour == 1) or (trade_short_on_dow_2 and hour == 2) or (trade_short_on_dow_3 and hour == 3) or (trade_short_on_dow_4 and hour == 4) or (trade_short_on_dow_5 and hour == 5) or (trade_short_on_dow_6 and hour == 6) or (trade_short_on_dow_7 and hour == 7) or (trade_short_on_dow_8 and hour == 8) or (trade_short_on_dow_9 and hour == 9) or (trade_short_on_dow_10 and hour == 10) or (trade_short_on_dow_11 and hour == 11) or (trade_short_on_dow_12 and hour == 12) or (trade_short_on_dow_13 and hour == 13) or (trade_short_on_dow_14 and hour == 14) or (trade_short_on_dow_15 and hour == 15) or (trade_short_on_dow_16 and hour == 16) or (trade_short_on_dow_17 and hour == 17) or (trade_short_on_dow_18 and hour == 18) or (trade_short_on_dow_19 and hour == 19) or (trade_short_on_dow_20 and hour == 20) or (trade_short_on_dow_21 and hour == 21) or (trade_short_on_dow_22 and hour == 22) or (trade_short_on_dow_23 and hour == 23) or (trade_short_on_dow_24 and hour == 24)
- // Exit open market position when date range ends
- //if (not trade_long_hour_today)
- // strategy.close_all()
- //if (not trade_short_hour_today)
- // strategy.close_all()
- cond_long = blà, blà, blà and trade_long_hour_today
- cond_short = blà, blà, blà and trade_short_hour_today
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement