Advertisement
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
- //@version=4
- //Strategia di prova n°1
- //11 Come creare intervalli di tempo personalizzati
- //Strategia Daily Chiliz/USDT Incrocio Sma8 con Sma12
- //Scheletro
- strategy(title="Strategia_Maurizio_Ciullo1",
- shorttitle="S_M_C_1",
- overlay=true,
- pyramiding=0,
- default_qty_type=strategy.percent_of_equity,
- default_qty_value=5,
- initial_capital=1000,
- //currency=currency.USD,
- commission_type=strategy.commission.cash_per_order,
- commission_value=0.1,
- slippage=2
- )
- // STEP 1 DATARANGE:
- // Make input options that configure backtest date range
- startDate = input(title="Start Date", type=input.integer,
- defval=16, minval=1, maxval=31)
- startMonth = input(title="Start Month", type=input.integer,
- defval=7, minval=1, maxval=12)
- startYear = input(title="Start Year", type=input.integer,
- defval=2017, minval=1800, maxval=2100)
- endDate = input(title="End Date", type=input.integer,
- defval=16, minval=1, maxval=31)
- endMonth = input(title="End Month", type=input.integer,
- defval=12, minval=1, maxval=12)
- endYear = input(title="End Year", type=input.integer,
- defval=2018, minval=1800, maxval=2100)
- // STEP 2 DATARANGE:
- // Look if the close time of the current bar
- // falls inside the date range
- inDateRange = (time >= timestamp(syminfo.timezone, startYear,
- startMonth, startDate, 0, 0)) and
- (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
- //Parametri Indicatori Ed Oscillatori
- Media_Mobile_Esponenziale_Veloce=ema(close, 8)
- Media_Mobile_Esponenziale_Lenta=ema(close,12)
- //Le faccio visualizzare sul grafico alla chiusura che ho definito con i clori che ho definito
- plot(Media_Mobile_Esponenziale_Veloce, color=color.orange)
- plot(Media_Mobile_Esponenziale_Lenta, color=color.blue)
- //Condizioni parametri di entrata
- Cond_Entry_Long=crossover(Media_Mobile_Esponenziale_Veloce, Media_Mobile_Esponenziale_Lenta)
- //Condizioni parametri di uscita
- Cond_Exit_Long=crossunder(Media_Mobile_Esponenziale_Veloce, Media_Mobile_Esponenziale_Lenta)
- // STEP 3 DATARANGE E ENTRY EXIT:
- // Submit entry orders, but only when bar is inside date range
- if (inDateRange and Cond_Entry_Long)
- strategy.entry("ID 1 Ingresso Long", true, when=Cond_Entry_Long)
- if (inDateRange and Cond_Exit_Long)
- strategy.close("ID 1 Ingresso Long", when=Cond_Exit_Long)
- // STEP 4 DATARANGE:
- // Exit open market position when date range ends
- if (not inDateRange)
- strategy.close_all()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement