Advertisement
Maurizio-Ciullo

Bot Get-Back-Limit 1.6 LEO/PERP FTX 45M LONG E SHORT

Oct 27th, 2022
1,874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                                            // Bot Get-Back-Market 1.6 LEO/PERP FTX 45M LONG E SHORT //
  2.  
  3.  
  4. ////////////////////////////////////////////      CREATO 1 TRADING SYSTEM CON TRE VERSIONI. ////////////////////////////////////////////
  5. //////////////////////////////////   2° VERSIONE 1.6 MARKET: CON MYEXITCOUNTBAR / TAKE PROFIT / INGRESO MARKET   //////////////////////////////////
  6.  
  7. // Il trading system completo - Get-Back-Market 1.6 Ver-5 (Strategia Reversal/Swing)
  8. // (Exchange= FTX) (Sottostante LEO-PERP) (Timeframe= 45M) (Direzione= LONG E SHORT) (Swing Posizione= SI) (Esclusione Ore=NO) (Esclusione Giorni=NO') (Esclusione Mesi=NO)
  9. // (Take Profit Long/Short Market = NO) (Take Profit Limit Long/Short= 9%) (Stop Loss Limit Long/Short= -12% Tradingview-Hub)
  10. // (Stop Loss Market Long/Short= NO) (Trailing Stop=NO) (Stop Emergenza= NO) (Uscita Numero Candele Market Long/Short= SI)
  11. // (Ingressi Market = SI)
  12. // (Rischio Operazione 11.92% Drawdown Massimo)
  13. // (In Sample Dal=19/02/21 Al 12/04/22) (Out Of Sample Dal=12/04/22 Al 25/08/22)
  14. // (Progettatta Il=25/08/22)
  15.  
  16. // Nota su tradestation caricare sessione 23:00 23:00 tutti e 7 i giorni, solo che mi da un problema e non mi fa caricare l'ultima sessione.
  17. // Per questo motivo invece di usare: highd0 = HighSession(0,0); stò usando: (HighD(0)); Sostituendo le sessioni con i giorni temporali.
  18. // Per FTX Su Tradestation: Exchange Time, Regular Session, 7x7 23:00 23:00, Session Hour.
  19.  
  20.  
  21.  
  22.  
  23. Input: InitialCapital(100000);
  24. Input: percent_risk(25); // LASCIARLO A 25 ALTRIMENTI NON CALCOLA BENE TAKE PROFIT E STOP LOSS
  25. input: Lenght(20), NumDevs(2); // Lenght(20), NumDevs(2) = "Per Bande Di Bollinger"
  26. input: input_stop_loss(12),  input_target(0);      // !!! QUESTI NON SONO USATI MA GLI INPUT USATI SI TROVANO IN BASSO !!!
  27. Input: MyStartTimeL(0), MyEndTimeL(23); // Duration(48) = Ingresso consentito tot barre dopo MyStartTime "durata numero di barre"
  28. Input: MyStartTimeS(0), MyEndTimeS(0);
  29. Input: MyPtnLY(12), MyPtnSY(4), MyPtnLN(27), MyPtnSN(6);
  30. Input: MyExitCountBarL(76), MyExitCountBarS(53); // Aggiunto
  31.  
  32.  
  33. Variable:
  34. UpperBand(0), LowerBand(0), stop_loss(0), take_profit(0), risk(0), nr_share(0), mycount(0);
  35.    
  36. UpperBand = BollingerBand(Close, Lenght, NumDevs);
  37. LowerBand = BollingerBand(Close, Lenght, -NumDevs);
  38.  
  39.  
  40.  //Money menagment
  41. risk = percent_risk/100;
  42. nr_share = floor((InitialCapital + NetProfit) * risk) / close;
  43. stop_loss=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss);
  44. take_profit=((((InitialCapital + NetProfit) * risk)/100) * input_target);
  45.  
  46. // Test Motore Strategia Grezza Long E Short Insieme
  47. {If Close Cross Under UpperBand then Sellshort("Short") nr_share contracts Next Bar At Market;
  48. If Close Cross Over LowerBand  then Buy("Long") nr_share contracts Next Bar At Market;}
  49.  
  50.  
  51.  
  52.  
  53.  
  54. //////////////          //////////////          //////////////
  55.  
  56. // Test Motore Strategia Grezza Long E Short Separati
  57. If Time = 0 then mycount = 0 else mycount = mycount + 1;
  58.  
  59. {If testphase = 1 then begin  // Solo Long
  60.     if mycounter = mycount then buy next bar at market;
  61.     if marketposition = 1 then sell next bar at market;
  62. end;
  63.  
  64. If testphase = 2 then begin // Solo Short
  65.     if mycounter = mycount then sellshort next bar at market;
  66.     if marketposition = -1 then buytocover next bar at market;
  67. end;}
  68. //////////////          //////////////          //////////////}
  69.  
  70. // Ingressi separati con fasce orarie long e short separate che si incrociano "Entra solo long in fascia oraria A Entra solo short in fascia oraria B".
  71. {if mycount >= MyStartTimeL and mycount <= MyEndTimeL then Begin
  72.     if Close Cross Over LowerBand  then Buy("Long") nr_share contracts Next Bar At Market;
  73. end;
  74.  
  75. if mycount >= MyStartTimeS and mycount <= MyEndTimeS then begin
  76.     if Close Cross Under UpperBand then Sellshort("Short") nr_share contracts Next Bar At Market;
  77. end;
  78.  
  79. Setstopcontract;
  80. if input_stop_loss > 0 then begin;
  81.     Setstopposition;
  82.     SetStopLoss(stop_loss);
  83. end;}
  84.  
  85. //////////////          //////////////          //////////////
  86.  
  87. // Ingressi uniti con fasce orarie long e short insieme che si incrociano con prova exit in canlde counter in aggiunta a stop speculari e reversal position
  88. // e ptn fissati
  89. Var:
  90. MyEntryCountBar(0); // Aggiunto
  91. If Barssinceentry = 0 then MyEntryCountBar = 1 else  MyEntryCountBar = MyEntryCountBar + 1; // Aggiunto
  92.  
  93. //Stop uniti
  94. if mycount >= MyStartTimeL and mycount <= MyEndTimeL then Begin;
  95.     if Close Cross Over LowerBand and PtnBaseSA(MyPtnLY) = True and (PtnBaseSA(MyPtnLN) = False) then Buy("Long") nr_share contracts Next Bar At Market;
  96.     if Close Cross Under UpperBand and PtnBaseSA(MyPtnSY) = True and (PtnBaseSA(MyPtnSN) = False) then Sellshort("Short") nr_share contracts Next Bar At Market;
  97.     if Marketposition >0 and MyExitCountBarL >0 and  MyEntryCountBar > MyExitCountBarL then Sell("Exit Bar Long") from entry("Long") Next Bar at Market; // Aggiunto
  98.     if Marketposition <0 and MyExitCountBarS >0 and  MyEntryCountBar > MyExitCountBarS then Buytocover("Exit Bar Short") from entry("Short") Next Bar At Market; // Aggiunto
  99. end;
  100.  
  101.  
  102. //Stop Uniti Buono Originale PER AVERE LO STOP LOSS PRECISO BISOGNA METTERE A 25 IL RISK ALTRIMENTI NON FUNZIONA QUANDO SI OTTIMIZZA METTERLO A 25%
  103.  
  104.                                             // Stop loss speculare long e short insieme
  105. {Setstopcontract;
  106. if input_stop_loss > 0 then begin;
  107.     Setstopposition;
  108. SetStopLoss(stop_loss);  
  109. if input_target > 0 then begin;
  110.     Setstopposition;
  111.     Setprofittarget(take_profit);
  112. end;
  113. end;}
  114.  
  115.  
  116. {Setstopcontract; NON BUONO
  117. if input_target > 0 then begin;
  118.     Setstopposition;
  119.     Setprofittarget(take_profit);  
  120. end;}
  121.  
  122.  
  123.                                             // Stop loss separati long e short FUNZIONA
  124. input: input_stop_loss_long(12),  input_target_long(9);
  125. input: input_stop_loss_short(12),  input_target_short(9);
  126.  
  127. var:stop_loss_long(0), stop_loss_short(0), take_profit_long(0), take_profit_short(0);
  128.  
  129.  
  130. stop_loss_long=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss_long);
  131. take_profit_long=((((InitialCapital + NetProfit) * risk)/100) * input_target_long);
  132. stop_loss_short=((((InitialCapital + NetProfit) * risk)/100) * input_stop_loss_short);
  133. take_profit_short=((((InitialCapital + NetProfit) * risk)/100) * input_target_short);
  134.  
  135.  
  136. Setstopcontract;
  137. if input_stop_loss_long > 0 and marketposition = 1 then begin;
  138.     Setstopposition;
  139.     SetStopLoss(stop_loss_long);  
  140. if input_target_long > 0 and marketposition = 1 then begin;
  141.     Setstopposition;
  142.     Setprofittarget(take_profit_long);
  143. end;
  144. end;
  145.    
  146.    
  147. if input_stop_loss_short > 0 and marketposition = -1 then begin;
  148.     Setstopposition;
  149.     SetStopLoss(stop_loss_short);
  150. if input_target_short > 0 and marketposition = -1 then begin;
  151.     Setstopposition;
  152.     Setprofittarget(take_profit_short);
  153. end;
  154. end;
  155.  
  156.  
  157.  
  158. //////////////          //////////////          //////////////
  159.  
  160. // Ingressi separati con fasce orarie long e short separate che si incrociano ma con l'aggiunta dei pattern. Vedi altri input sotto
  161.  
  162. {Input: MyStartTimeS(1), MyEndTimeS(10);
  163. Input: MyPtnLY(41), MyPtnSY(20), MyPtnLN(36), MyPtnSN(42);
  164. input: input_stop_loss(8);
  165.  
  166. if mycount >= MyStartTimeL and mycount <= MyEndTimeL then Begin
  167.     if Close Cross Over LowerBand and PtnBaseSA(MyPtnLY) = True and (PtnBaseSA(MyPtnLN) = False) then Buy("Long") nr_share contracts Next Bar At Market;
  168. end;
  169.  
  170. if mycount >= MyStartTimeS and mycount <= MyEndTimeS then begin
  171.     if Close Cross Under UpperBand and PtnBaseSA(MyPtnLY) = True and (PtnBaseSA(MyPtnLN) = False) then Sellshort("Short") nr_share contracts Next Bar At Market;
  172. end;
  173.  
  174. Setstopcontract;
  175. if input_stop_loss > 0 then begin;
  176.     Setstopposition;
  177.     SetStopLoss(stop_loss);
  178. end;}
  179.  
  180. //////////////          //////////////          //////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement