Maurizio-Ciullo

Indicatore Break Even Con Buffer

Dec 13th, 2025
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3.                                                                                 // Indicatore Break Even Con Buffer //
  4.                                     // * Quando in posizione, ad un certo prezzo di guadagno si innesca il break even con un buffer sopra entry price, il tutto ottimizzabile da input * //
  5.  
  6.  
  7. // ==========================================================================================================================================================================================//                            
  8. //                                                                              ESEMPIO STRATEGIA SOLO LONG CON BREAKEVEN + BUFFER                             
  9. // ==========================================================================================================================================================================================//
  10.  
  11. // ==========================================================================================================================================================================================//
  12. // INPUT E VARS BREAK EVEN CON BUFFER LONG
  13. // ==========================================================================================================================================================================================//
  14. Inputs:
  15. BPV(50),                    //  Big Point Value Dello Strumento. Es: Soia @S 50$. Per Crypto 1$
  16. breakEvenPriceLong(1000),   // Movimento In $ Per Innesco
  17. profitBufferLong(800);      // Buffer Chiusura Posizione Sopra EntryPrice    
  18.  
  19. Vars:
  20. bufferPointsLong(0),
  21. MaxPriceDuringTrade(0);
  22.  
  23. // Conversione in punti
  24. Once bufferPointsLong = profitBufferLong / BPV;
  25.  
  26. // ==========================================================================================================================================================================================//                            
  27. //                                                                              INIZIO INCOLLA LA TUA STRATEGIA                            
  28. // ==========================================================================================================================================================================================//                                                                                    
  29.                                                            
  30. // Apertura long
  31. If DayOfMonth(Date) = 1 and MarketPosition = 0 Then
  32.     Buy ("LongStart") next bar at market;
  33.  
  34. // Chiusura forzata
  35. If MarketPosition = 1 and DayOfMonth(Date) = 7 Then
  36.     Sell ("LongExit") next bar at market;
  37.    
  38. // ==========================================================================================================================================================================================//                            
  39. //                                                                              FINE INCOLLA LA TUA STRATEGIA                              
  40. // ==========================================================================================================================================================================================//    
  41.  
  42. // BREAKEVEN + BUFFER
  43. If MarketPosition = 1 and DayOfMonth(Date) <> 7 Then Begin
  44.  
  45.     If BarsSinceEntry = 0 Then
  46.         MaxPriceDuringTrade = EntryPrice;
  47.  
  48.     If High > MaxPriceDuringTrade Then
  49.         MaxPriceDuringTrade = High;
  50.  
  51.     If (MaxPriceDuringTrade - EntryPrice) * BPV >= breakEvenPriceLong Then
  52.         Sell ("BEPlusStopLong") next bar
  53.         at EntryPrice + bufferPointsLong stop;
  54.  
  55. End;
  56.  
  57. // Reset
  58. If MarketPosition = 0 Then
  59.     MaxPriceDuringTrade = 0;    
  60.  
  61.  
  62. // ==========================================================================================================================================================================================//                            
  63. //                                                                              ESEMPIO STRATEGIA SOLO SHORT CON BREAKEVEN + BUFFER                                
  64. // ==========================================================================================================================================================================================//                                                                                    
  65.  
  66. // ==========================================================================================================================================================================================//
  67. // INPUT E VARS BREAK EVEN CON BUFFER SHORT
  68. // ==========================================================================================================================================================================================//
  69. {Inputs:
  70. BPV(50),                   // Big Point Value dello strumento (es: Soia @S = 50$, Crypto = 1$)
  71. breakEvenPriceShort(1000), // Movimento in $ per innesco BE
  72. profitBufferShort(800);    // Buffer chiusura posizione sotto EntryPrice
  73.  
  74. Vars:
  75. bufferPointsShort(0),
  76. MinPriceDuringTrade(0);
  77.  
  78. // Conversione in punti
  79. Once bufferPointsShort = profitBufferShort / BPV;
  80.  
  81. // ==========================================================================================================================================================================================//                            
  82. //                                                                              INIZIO INCOLLA LA TUA STRATEGIA                            
  83. // ==========================================================================================================================================================================================//
  84. // Apertura posizione short il 1° giorno del mese
  85. If DayOfMonth(Date) = 1 and MarketPosition = 0 Then
  86.     SellShort ("ShortStart") next bar at market;
  87.  
  88. // Chiusura short il 7 del mese
  89. If MarketPosition = -1 and DayOfMonth(Date) = 7 Then
  90.     BuyToCover ("ShortExit") next bar at market;
  91.    
  92. // ==========================================================================================================================================================================================//                            
  93. //                                                                              FINE INCOLLA LA TUA STRATEGIA                              
  94. // ==========================================================================================================================================================================================//
  95.  
  96. // ============================================================
  97. // BREAKEVEN + BUFFER SHORT
  98. // ============================================================
  99. If MarketPosition = -1 and DayOfMonth(Date) <> 7 Then Begin
  100.  
  101.     // Inizio trade: registra minimo intratrade
  102.     If BarsSinceEntry = 0 Then
  103.         MinPriceDuringTrade = EntryPrice;
  104.  
  105.     // Aggiorna minimo intratrade
  106.     If Low < MinPriceDuringTrade Then
  107.         MinPriceDuringTrade = Low;
  108.  
  109.     // Attiva breakeven + buffer se profitto raggiunto
  110.     If (EntryPrice - MinPriceDuringTrade) * BPV >= breakEvenPriceShort Then
  111.         BuyToCover ("BEPlusStopShort") next bar
  112.         at EntryPrice - bufferPointsShort stop;
  113.  
  114. End;
  115.  
  116. // ============================================================
  117. // RESET VARIABILI ALLA CHIUSURA DEL TRADE
  118. // ============================================================
  119. If MarketPosition = 0 Then
  120.     MinPriceDuringTrade = 0;     }
  121.  
  122.  
Advertisement
Add Comment
Please, Sign In to add comment