Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Codice su cross del prezzo sulla media
- // Il trading system completo - Swing-Trend (Strategia Trend Following Con Swing Di Posizione) - parte 1
- // (Exchange= FTX) (Sottostante ETH-PERP) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Giorni=Sabato) (Esclusione Mesi=Ottobre)
- //Fase iniziale parametri di input
- input:
- InitialCapital(100000),
- percent_risk(25),
- input_stop_loss_percent(2.5),
- lunghezza_ema_long(45),
- lunghezza_ema_long_chiusura(35),
- lunghezza_ema_short(40),
- lunghezza_ema_short_chiusura(30),
- perc_apertura_minima_long(0),
- perc_apertura_massima_long(2),
- perc_chiusura_minima_long(1.5),
- perc_apertura_minima_short(0.75),
- perc_apertura_massima_short(2),
- perc_chiusura_minima_short(1),
- skipday(saturday),
- skipmonth1(10),
- //skipmonth2(9),
- solo_long(false),
- solo_short(false);
- Vars:
- ema_long(0),
- ema_long_chiusura(0),
- ema_short(0),
- ema_short_chiusura(0),
- apertura_minima_long(0),
- apertura_massima_long(0),
- chiusura_minima_long(0),
- apertura_minima_short(0),
- apertura_massima_short(0),
- chiusura_minima_short(0),
- stop_loss(0),
- ATR(0),
- account_equity(0),
- risk(0),
- nr_share(0),
- SharesByPercentRisk(0),
- market_price(0);
- // Calcololo degli indicatori
- ema_long = XAverage(Close, lunghezza_ema_long);
- ema_short = XAverage(Close, lunghezza_ema_short);
- ema_long_chiusura = XAverage(Close, lunghezza_ema_long_chiusura);
- ema_short_chiusura = XAverage(Close, lunghezza_ema_short_chiusura);
- // calcolo dei filtri in percentuale
- apertura_minima_long = (ema_long / 100) * perc_apertura_minima_long;
- apertura_massima_long = (ema_long / 100) * perc_apertura_massima_long;
- chiusura_minima_long = (ema_long_chiusura / 100) * perc_chiusura_minima_long;
- apertura_minima_short = (ema_short / 100) * perc_apertura_minima_short;
- apertura_massima_short = (ema_short / 100) * perc_apertura_massima_short;
- chiusura_minima_short = (ema_short_chiusura / 100) * perc_chiusura_minima_short;
- risk = percent_risk/100;
- nr_share = floor((InitialCapital + NetProfit) * risk) / close;
- stop_loss=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss_percent);
- // Entrata Long
- if close > (ema_long+apertura_minima_long) and close < (ema_long + apertura_massima_long) and close > open and not solo_short {and Dayofweek(date) <> skipday and month(date) <> skipmonth1 and Dayofmonth(date) > 5} then
- Buy("Long") nr_share contracts Next Bar at market;
- // Uscita Long
- if close < (ema_long_chiusura - chiusura_minima_long) then
- Sell("Chiusura Long") from entry("Long") Next Bar at market;
- // Entrata Short
- if close < (ema_short - apertura_minima_short) and close > (ema_short - apertura_massima_short) and close < open and not solo_long {and Dayofweek(date) <> skipday and month(date) <> skipmonth1 and Dayofmonth > 5} then
- Sellshort("Short") nr_share Contracts Next Bar at market;
- // Uscita Short
- if close > (ema_short_chiusura + chiusura_minima_short) then
- Buytocover("Chiusura Short") from entry("Short") Next Bar at market;
- Setstopposition;
- SetStopLoss(stop_loss);
Add Comment
Please, Sign In to add comment