Advertisement
Maurizio-Ciullo

Indicatore-Base-Men-Reverting-Trend-Following-Unger

Aug 11th, 2022 (edited)
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.                                     // Indicatore-Base-Men-Reverting-Trend-Following-Unger //
  3.                        
  4.  
  5. // Solitamente il test dovrebbe essere fatto su timeframe giornaliero per leggere la natura del sottostante.
  6. // Cambiando timeframe il test verrà eseguito sul timeframe scelto tranne per il Daily Mean Reverting Cross che rimane agganciato al timeframe daily.
  7. // Questo test potrebbe essere confrontato con 2 indicatori:
  8. // Da notare che su pinescript nell'intraday timeframes il Mean Reverting Cross ritorna valori diversi se confrontato con l'intraday session data di tradestation.
  9. // 1) Augmented Dickey–Fuller (ADF) mean reversion test
  10. // 2) Hurst Exponent - Detrended Fluctuation Analysis", "BA🐷HE (DFA)
  11.  
  12.  
  13. //inputs
  14. inputs:
  15.         on_off_trend_activate (true),
  16.     in_solo_long_trend (false),
  17.     in_solo_short_trend (false),
  18.  
  19.     on_off_reverse_activate (false),
  20.     in_solo_long_reverse (false),
  21.     in_solo_short_reverse (false),
  22.    
  23.     on_off_reverse_cross_activate (false),
  24.     in_solo_long_reverse_cross (false),
  25.     in_solo_short_reverse_cross (false);
  26.  
  27.  
  28.        
  29.                                               // Inizio Test Daily Trend Following //
  30.  
  31. // Long e short Trend
  32. if in_solo_long_trend = false and  in_solo_short_trend = false and on_off_trend_activate then begin
  33.     Buy ("En Long Trend") Next Bar high stop;
  34.     Sellshort ("En Short Trend") Next Bar low stop;
  35. end;
  36.  
  37.  
  38. // Solo Long Trend  
  39. if in_solo_long_trend = true and in_solo_short_trend = false and on_off_trend_activate then begin
  40.     Buy("Ent Solo Long Trend") Next Bar high stop;
  41.     Sell("Ex Solo Long Trend") Next Bar low stop;
  42. end;
  43.  
  44.  
  45. // Solo Short Trend  
  46. if in_solo_short_trend = true and in_solo_long_trend = false and on_off_trend_activate then begin
  47.     Sellshort("En Solo Short Trend") Next Bar low stop;
  48.     Buytocover("Ex Solo Short Trend")Next Bar high stop;
  49. end;
  50.  
  51.  
  52.                                                 // Fine Test Daily Trend Following //
  53.  
  54.  
  55.                                                // Inizio Test Daily Mean Reverting //
  56.  
  57. // Long e short Reverse
  58. if in_solo_long_reverse = false and  in_solo_short_reverse = false and on_off_reverse_activate then begin
  59.     Buy("En Long Rev") Next Bar low limit;
  60.     Sellshort("Ex Short Rev") Next Bar high limit;
  61. end;
  62.  
  63.  
  64. // Solo Long Reverse  
  65. if in_solo_long_reverse = true and in_solo_short_reverse = false and on_off_reverse_activate then begin
  66.     Buy("En Solo Long Rev") Next Bar low limit;
  67.     Sell("Ex Solo Long Rev") Next Bar high limit;
  68. end;
  69.  
  70.  
  71. // Solo Short Reverse
  72. if in_solo_short_reverse = true and in_solo_long_reverse = false and on_off_reverse_activate then begin
  73.     Sellshort("En Solo Short Rev") Next Bar high limit;
  74.     Buytocover("Ex Solo Short Rev") Next Bar low limit;
  75. end;
  76.    
  77.                                                 // Fine Test Daily Mean Reverting //}
  78.                                                
  79.                                                
  80.                                                 // Inizio Test Daily Mean Reverting Cross//
  81.  
  82. // Long Short Reverse Cross
  83. if in_solo_long_reverse_cross = false and in_solo_short_reverse_cross = false and on_off_reverse_cross_activate then begin
  84.     if Close Cross Over LowSession(1,1) then Buy Next bar at market;
  85.     if Close Cross Below HighSession(1,1) then Sellshort Next bar at market;
  86. end;
  87.  
  88.  
  89. // Solo Long Reverse Cross
  90. if in_solo_long_reverse_cross = true and in_solo_short_reverse_cross = false and on_off_reverse_cross_activate then begin
  91.     if Close Cross Over LowSession(1,1) then Buy("En Solo Long Rev Cr") Next bar at market;
  92.     if Close Cross Below HighSession(1,1) then Sell("Ex Solo Long Rev Cr") Next Bar high stop;
  93. end;
  94.        
  95.  
  96. // Solo Short Reverse Cross
  97. if in_solo_short_reverse_cross = true and in_solo_long_reverse_cross = false and on_off_reverse_cross_activate then begin
  98.     if Close Cross Below HighSession(1,1) then Sellshort("En Solo Short Rev Cr") Next bar at market;
  99.     if Close Cross Over LowSession(1,1) then Buytocover("Ex Solo Short Rev Cr") Next bar low stop;
  100. end;
  101.    
  102.    
  103.                                                 // Fine Test Daily Mean Reverting Cross//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement