Advertisement
Maurizio-Ciullo

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

Jun 8th, 2023 (edited)
1,369
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. // (In Sample Dal=18/08/17 Al 12/07/22) (Out Of Sample Dal=12/07/22 Al 20/05/23)
  12. // (Money Management = 23% Del Capitale Pinesctipt)
  13. // (Money Management = 25% Del Capitale Tradestation)
  14. // (Progettatta Il=07/07/23)
  15.  
  16. // Caricamento Dati Bybit Su Tradestation: Exchange Time, Regular Session, 7x7 23:00 23:00, Session Hour.
  17.  
  18.                                                     // ATTENZIONE //
  19. // 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
  20. // impostare gli altri su false. Commentare anche i BUY COMMAND che non utilizziamo.
  21.  
  22.  
  23. // Auentare il Max Bars Back A 75 Su Tradestation Altrimenti Non Funziona E Cliccare Su Enable Strategy Altrimenti Non Parte
  24.  
  25. // 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.
  26.  
  27.  
  28. ////////// Start detecting Ichimoku Cloud //////////                                                                                                  
  29. Inputs: Standard(26), Turning(9), Delayed(52), Uscita(0), mystop(0), myprofit(0);
  30. Variables:StdLine(0), TurnLine(0), Span1(0), Span2(0);
  31. StdLine = (Highest(High, Standard) + Lowest(Low, Standard)) / 2; // "BASE LINE"
  32. TurnLine = (Highest(High, Turning) + Lowest(Low, Turning)) / 2;  // "CONVERSION LINE"
  33. Span1 = (StdLine + TurnLine) / 2;                                // "SPAN A No 25 Offset"
  34. Span2 = (Highest(High, Delayed) + Lowest(Low, Delayed)) / 2;     // "SPAN B No 25 Offset"
  35.  
  36. // Span1 e Span2 non hanno l'offset di 25 candele fa, per ulteriori verifiche vedi Study Ichimoku oppure fare il print qui su Strategy.
  37.  
  38. // Print Debug Ichimoku
  39. {Once Clearprintlog;
  40. print(Getstrategyname, ", ", Symbol, ", ", Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), ", ", Close, ", ", StdLine, ", ", TurnLine, ", ", Span1, ", ",Span2 , ", ",);
  41. print(StdLine);
  42. print(TurnLine);
  43. print(Span1);
  44. print(Span2);}
  45. ////////// End detecting Ichimoku Cloud //////////
  46.                                                
  47.                                                
  48. ////////// Start Detection ATR (Average True Range Long E Short) //////////
  49. // Valori migliori e più stabili boom bar long I migliori sono scritti per prima: //7-.1.2//12-1.2 //11-1.2
  50. // La 7-1.2entra più facilmente ed entra più in basso solo che se il periodo non è buono prende più stop
  51. // La 11-1.2 entra meno, operazione leggermente minore ma se il periodo è peggiore prende meno stop
  52. // Preferisco la 7-1.2 Più aggressiva e la 11-1.2 più stabile
  53. input:
  54.     input_atr_period_long(7),
  55.     input_atr_period_short(33),
  56.     input_atr_Mult_long(1.2),
  57.     input_atr_Mult_short(1.2),
  58.     input_ema_long(84),
  59.     input_ema_short(83),
  60.     InitialCapital(100000),
  61.     percent_risk(100),
  62.     only_long(false),
  63.     only_short(false);
  64.    
  65.    
  66.    
  67. Vars:
  68.      valore_atr_long(0),
  69.      valore_atr_short(0),
  70.      boom_bar_long(false),
  71.      boom_bar_short(false),
  72.      ema_long(0),
  73.      ema_short(0),
  74.      entrata_long(false),
  75.      entrata_short(false),
  76.      uscita_long(false),
  77.      uscita_short(false),
  78.      nr_share(0),
  79.      risk(0);
  80.      
  81.  
  82. ////////// Start Detecting ATR (Average True Range Long E Short) //////////
  83. valore_atr_long      =   AvgTrueRange(input_atr_period_long);
  84. valore_atr_short     =   AvgTrueRange(input_atr_period_short);
  85. ////////// End Detecting ATR (Average True Range Long E Short) //////////
  86.  
  87.  
  88. ////////// Start Detecting Boom Bar Long //////////
  89. boom_bar_long = Absvalue(open - close) > valore_atr_long * input_atr_Mult_long;
  90. If boom_bar_long Then
  91. // Plotshape Boom_Bar_Long
  92. Begin
  93.     Value1 = Text_new(D, T, L, "*");
  94.     Text_setcolor(Value1, Yellow);
  95.     Text_setstyle(Value1, 2, 0);
  96. End;
  97. ////////// End Detecting Boom Bar Long //////////
  98.  
  99.  
  100. ////////// Start Detecting Boom Bar Short //////////
  101. boom_bar_short = Absvalue(open - close) > valore_atr_short * input_atr_Mult_short;
  102. If boom_bar_short Then
  103. // Plotshape Boom_Bar_Short
  104. Begin
  105.     Value2 = Text_new(D, T, L, "*");
  106.     Text_setcolor(Value1, Yellow);
  107.     Text_setstyle(Value1, 2, 0);
  108. End;
  109. ////////// End Detecting Boom Bar Short //////////
  110.  
  111.  
  112. ////////// Start Detecting Media EMA Long //////////
  113. ema_long = XAverage(close, input_ema_long);
  114. ////////// End Detecting Media EMA Long //////////
  115.  
  116.  
  117. ////////// Start Detecting Media EMA Short //////////
  118. ema_short = XAverage(close, input_ema_short);
  119. ////////// End Detecting Media EMA Short //////////
  120.  
  121.  
  122.  
  123.  ////////// Start Money Managment //////////
  124. risk = percent_risk/100;
  125. nr_share = floor((InitialCapital + NetProfit) * risk) / close;
  126.  ////////// End Money Managment //////////
  127.  
  128.  
  129. ////////// Start Condizioni Entrata E Uscita Long E Short //////////
  130. entrata_long = close > StdLine and TurnLine > StdLine and close > Span2  and close > ema_long  and boom_bar_long and not only_short;
  131. entrata_short = close < StdLine and TurnLine  < StdLine and close < Span2  and close < ema_short and boom_bar_short and not only_long;
  132.  
  133. uscita_long = close < StdLine;
  134. uscita_short = close > StdLine;
  135. ////////// End Condizioni Entrata E Uscita Long E Short //////////
  136.  
  137.  
  138. ////////// Start Entrata E Uscita Long //////////
  139. if marketposition = 0 and entrata_long Then
  140.    Begin;
  141.       Buy("Long") nr_share contracts Next Bar at market;  
  142.    End;
  143.    
  144. if marketposition = 1 and uscita_long Then
  145.     Begin;
  146.         Sell("Exit Market Long") from entry("Long") Next Bar at market;    
  147.     End;
  148. ////////// End Entrata E Uscita Long //////////
  149.  
  150.  
  151.  
  152. ////////// Start Entrata E Uscita Short //////////
  153. if marketposition = 0 and entrata_short Then
  154.    Begin;
  155.       Sellshort("Short") nr_share contracts Next Bar at market;  
  156.    End;
  157.    
  158. if marketposition = -1 and uscita_short Then
  159.     Begin;
  160.         Buytocover("Exit Market Short") from entry("Short") Next Bar at market;    
  161.     End;
  162. ////////// End Entrata E Uscita Short //////////
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement