Advertisement
Maurizio-Ciullo

Bot Over-The-Clouds ETH/USDT.P BYBIT 4H LONG E SHORT

Jun 8th, 2023 (edited)
1,526
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.                             // Bot Over-The-Clouds ETH/USDT.P BYBIT 4H LONG E SHORT //
  3.                               // Versione con uscita chiusuare sotto la baseline //
  4.  
  5. // Il trading system completo - Over The Clouds ETH/USDT.P BYBIT 4H LONG E SHORT (Trend Following)
  6. // (Sviluppo Dati Exchange = BINANCE + BYBIT) (BINANCE Dal=18/08/2017 Al 21/10/2020) (BYBIT Dal=21/10/2020 Al 20/05/2023)
  7. // (Exchange= BYBIT) (Sottostante ETH-USDT.P) (Timeframe= 4H) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=NO) (Esclusione Mesi=NO)
  8. // (Take Profit Long/Short Market = NO) (Take Profit Limit Long/Short= NO)
  9. // (Stop Loss Limit Long= NO) (Stop Loss Limit Short= NO) (Stop Loss Market Long/Short= SI) (Trailing Stop Market=SI) (Stop Emergenza= NO)
  10. // (Rischio Operazione 2% Perdita Media Calcolato Sul Ticker: ETHUSDT BINANCE SPOT) (Max Drawdown Permesso 10,03% Calcolato Sul Ticker: ETHUSDT.P BYBIT CHE E' IL PEGGIORE DELLE ENTRIES MODE)
  11. // (ATTENZIONE !!! NON USO PIU' IL RISCHIO OPERAZIONE SOPRA DEL 2% MA LA LASCIO SEMPRE LIVE E QUANDO ARRIVA AL 15% DI MAX DD AGGIUSTATO CON IL PROGRAMMA MONTECARLO PYTHON LA CESTINO
  12. // (In Sample Dal=18/08/17 Al 12/07/22) (Out Of Sample Dal=12/07/22 Al 20/05/23)
  13. // (Money Management = 25% Del Capitale Tradestation)  
  14. // (Money Management = 17% Del Capitale Tradingview) Preso Dal 15% Media Max Drawdown 2°nda Deviazione Standard Simulazione Montecarlo Python
  15. // (Progettatta Il=07/07/23)
  16.  
  17. // Caricamento Dati Bybit Su Tradestation: Exchange Time, Regular Session, 7x7 23:00 23:00, Session Hour.
  18.  
  19.                                                     // ATTENZIONE //
  20. // Quando si mette la strategia live, ricordarsi di impostare 1 solo input "quello che vogliamo utilizzare come normal/ more_aggressive/less_aggressive entries" su true e
  21. // impostare gli altri su false. Commentare anche i BUY COMMAND che non utilizziamo.
  22.  
  23.  
  24. // Auentare il Max Bars Back A 75 Su Tradestation Altrimenti Non Funziona E Cliccare Su Enable Strategy Altrimenti Non Parte
  25.  
  26. // Qui a differenza di tradingview non ho creato lo swith mode per gli ingressi cambiando periodi atr e mopltiplicatore atr, farlo a mano dagli input.
  27.  
  28.  
  29. ////////// Start detecting Ichimoku Cloud //////////                                                                                                  
  30. Inputs: Standard(26), Turning(9), Delayed(52), Uscita(0), mystop(0), myprofit(0);
  31. Variables:StdLine(0), TurnLine(0), Span1(0), Span2(0);
  32. StdLine = (Highest(High, Standard) + Lowest(Low, Standard)) / 2; // "BASE LINE"
  33. TurnLine = (Highest(High, Turning) + Lowest(Low, Turning)) / 2;  // "CONVERSION LINE"
  34. Span1 = (StdLine + TurnLine) / 2;                                // "SPAN A No 25 Offset"
  35. Span2 = (Highest(High, Delayed) + Lowest(Low, Delayed)) / 2;     // "SPAN B No 25 Offset"
  36.  
  37. // Span1 e Span2 non hanno l'offset di 25 candele fa, per ulteriori verifiche vedi Study Ichimoku oppure fare il print qui su Strategy.
  38.  
  39. // Print Debug Ichimoku
  40. {Once Clearprintlog;
  41. print(Getstrategyname, ", ", Symbol, ", ", Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), ", ", Close, ", ", StdLine, ", ", TurnLine, ", ", Span1, ", ",Span2 , ", ",);
  42. print(StdLine);
  43. print(TurnLine);
  44. print(Span1);
  45. print(Span2);}
  46. ////////// End detecting Ichimoku Cloud //////////
  47.                                                
  48.                                                
  49. ////////// Start Detection ATR (Average True Range Long E Short) //////////
  50. // Valori migliori e pi  stabili boom bar long I migliori sono scritti per prima: //7-.1.2//12-1.2 //11-1.2
  51. // La 7-1.2entra pi  facilmente ed entra pi  in basso solo che se il periodo non   buono prende pi  stop
  52. // La 11-1.2 entra meno, operazione leggermente minore ma se il periodo   peggiore prende meno stop
  53. // Preferisco la 7-1.2 Pi  aggressiva e la 11-1.2 pi  stabile
  54. input:
  55.     input_atr_period_long(7),
  56.     input_atr_period_short(33),
  57.     input_atr_Mult_long(1.2),
  58.     input_atr_Mult_short(1.2),
  59.     input_ema_long(84),
  60.     input_ema_short(83),
  61.     InitialCapital(100000),
  62.     percent_risk(100),
  63.     only_long(false),
  64.     only_short(false);
  65.    
  66.    
  67.    
  68. Vars:
  69.      valore_atr_long(0),
  70.      valore_atr_short(0),
  71.      boom_bar_long(false),
  72.      boom_bar_short(false),
  73.      ema_long(0),
  74.      ema_short(0),
  75.      entrata_long(false),
  76.      entrata_short(false),
  77.      uscita_long(false),
  78.      uscita_short(false),
  79.      nr_share(0),
  80.      risk(0);
  81.      
  82.  
  83. ////////// Start Detecting ATR (Average True Range Long E Short) //////////
  84. valore_atr_long      =   AvgTrueRange(input_atr_period_long);
  85. valore_atr_short     =   AvgTrueRange(input_atr_period_short);
  86. ////////// End Detecting ATR (Average True Range Long E Short) //////////
  87.  
  88.  
  89. ////////// Start Detecting Boom Bar Long //////////
  90. boom_bar_long = Absvalue(open - close) > valore_atr_long * input_atr_Mult_long;
  91. If boom_bar_long Then
  92. // Plotshape Boom_Bar_Long
  93. Begin
  94.     Value1 = Text_new(D, T, L, "*");
  95.     Text_setcolor(Value1, Yellow);
  96.     Text_setstyle(Value1, 2, 0);
  97. End;
  98. ////////// End Detecting Boom Bar Long //////////
  99.  
  100.  
  101. ////////// Start Detecting Boom Bar Short //////////
  102. boom_bar_short = Absvalue(open - close) > valore_atr_short * input_atr_Mult_short;
  103. If boom_bar_short Then
  104. // Plotshape Boom_Bar_Short
  105. Begin
  106.     Value2 = Text_new(D, T, L, "*");
  107.     Text_setcolor(Value1, Yellow);
  108.     Text_setstyle(Value1, 2, 0);
  109. End;
  110. ////////// End Detecting Boom Bar Short //////////
  111.  
  112.  
  113. ////////// Start Detecting Media EMA Long //////////
  114. ema_long = XAverage(close, input_ema_long);
  115. ////////// End Detecting Media EMA Long //////////
  116.  
  117.  
  118. ////////// Start Detecting Media EMA Short //////////
  119. ema_short = XAverage(close, input_ema_short);
  120. ////////// End Detecting Media EMA Short //////////
  121.  
  122.  
  123.  
  124.  ////////// Start Money Managment //////////
  125. risk = percent_risk/100;
  126. nr_share = floor((InitialCapital + NetProfit) * risk) / close;
  127.  ////////// End Money Managment //////////
  128.  
  129.  
  130. ////////// Start Condizioni Entrata E Uscita Long E Short //////////
  131. entrata_long = close > StdLine and TurnLine > StdLine and close > Span2  and close > ema_long  and boom_bar_long and not only_short;
  132. entrata_short = close < StdLine and TurnLine  < StdLine and close < Span2  and close < ema_short and boom_bar_short and not only_long;
  133.  
  134. uscita_long = close < StdLine;
  135. uscita_short = close > StdLine;
  136. ////////// End Condizioni Entrata E Uscita Long E Short //////////
  137.  
  138.  
  139. ////////// Start Entrata E Uscita Long //////////
  140. if marketposition = 0 and entrata_long Then
  141.    Begin;
  142.       Buy("Long") nr_share contracts Next Bar at market;  
  143.    End;
  144.    
  145. if marketposition = 1 and uscita_long Then
  146.     Begin;
  147.         Sell("Exit Market Long") from entry("Long") Next Bar at market;    
  148.     End;
  149. ////////// End Entrata E Uscita Long //////////
  150.  
  151.  
  152.  
  153. ////////// Start Entrata E Uscita Short //////////
  154. if marketposition = 0 and entrata_short Then
  155.    Begin;
  156.       Sellshort("Short") nr_share contracts Next Bar at market;  
  157.    End;
  158.    
  159. if marketposition = -1 and uscita_short Then
  160.     Begin;
  161.         Buytocover("Exit Market Short") from entry("Short") Next Bar at market;    
  162.     End;
  163. ////////// End Entrata E Uscita Short //////////
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement