Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Indicatore-Base-Men-Reverting-Trend-Following-Unger //
- // Solitamente il test dovrebbe essere fatto su timeframe giornaliero per leggere la natura del sottostante.
- // Cambiando timeframe il test verrà eseguito sul timeframe scelto tranne per il Daily Mean Reverting Cross che rimane agganciato al timeframe daily.
- // Questo test potrebbe essere confrontato con 2 indicatori:
- // Da notare che su pinescript nell'intraday timeframes il Mean Reverting Cross ritorna valori diversi se confrontato con l'intraday session data di tradestation.
- // 1) Augmented Dickey–Fuller (ADF) mean reversion test
- // 2) Hurst Exponent - Detrended Fluctuation Analysis", "BA🐷HE (DFA)
- //inputs
- inputs:
- on_off_trend_activate (true),
- in_solo_long_trend (false),
- in_solo_short_trend (false),
- on_off_reverse_activate (false),
- in_solo_long_reverse (false),
- in_solo_short_reverse (false),
- on_off_reverse_cross_activate (false),
- in_solo_long_reverse_cross (false),
- in_solo_short_reverse_cross (false);
- // Inizio Test Daily Trend Following //
- // Long e short Trend
- if in_solo_long_trend = false and in_solo_short_trend = false and on_off_trend_activate then begin
- Buy ("En Long Trend") Next Bar high stop;
- Sellshort ("En Short Trend") Next Bar low stop;
- end;
- // Solo Long Trend
- if in_solo_long_trend = true and in_solo_short_trend = false and on_off_trend_activate then begin
- Buy("Ent Solo Long Trend") Next Bar high stop;
- Sell("Ex Solo Long Trend") Next Bar low stop;
- end;
- // Solo Short Trend
- if in_solo_short_trend = true and in_solo_long_trend = false and on_off_trend_activate then begin
- Sellshort("En Solo Short Trend") Next Bar low stop;
- Buytocover("Ex Solo Short Trend")Next Bar high stop;
- end;
- // Fine Test Daily Trend Following //
- // Inizio Test Daily Mean Reverting //
- // Long e short Reverse
- if in_solo_long_reverse = false and in_solo_short_reverse = false and on_off_reverse_activate then begin
- Buy("En Long Rev") Next Bar low limit;
- Sellshort("Ex Short Rev") Next Bar high limit;
- end;
- // Solo Long Reverse
- if in_solo_long_reverse = true and in_solo_short_reverse = false and on_off_reverse_activate then begin
- Buy("En Solo Long Rev") Next Bar low limit;
- Sell("Ex Solo Long Rev") Next Bar high limit;
- end;
- // Solo Short Reverse
- if in_solo_short_reverse = true and in_solo_long_reverse = false and on_off_reverse_activate then begin
- Sellshort("En Solo Short Rev") Next Bar high limit;
- Buytocover("Ex Solo Short Rev") Next Bar low limit;
- end;
- // Fine Test Daily Mean Reverting //}
- // Inizio Test Daily Mean Reverting Cross//
- // Long Short Reverse Cross
- if in_solo_long_reverse_cross = false and in_solo_short_reverse_cross = false and on_off_reverse_cross_activate then begin
- if Close Cross Over LowSession(1,1) then Buy Next bar at market;
- if Close Cross Below HighSession(1,1) then Sellshort Next bar at market;
- end;
- // Solo Long Reverse Cross
- if in_solo_long_reverse_cross = true and in_solo_short_reverse_cross = false and on_off_reverse_cross_activate then begin
- if Close Cross Over LowSession(1,1) then Buy("En Solo Long Rev Cr") Next bar at market;
- if Close Cross Below HighSession(1,1) then Sell("Ex Solo Long Rev Cr") Next Bar high stop;
- end;
- // Solo Short Reverse Cross
- if in_solo_short_reverse_cross = true and in_solo_long_reverse_cross = false and on_off_reverse_cross_activate then begin
- if Close Cross Below HighSession(1,1) then Sellshort("En Solo Short Rev Cr") Next bar at market;
- if Close Cross Over LowSession(1,1) then Buytocover("Ex Solo Short Rev Cr") Next bar low stop;
- end;
- // Fine Test Daily Mean Reverting Cross//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement