Advertisement
Maurizio-Ciullo

Plot Indicatore Test Equity Control Drawdown

Dec 20th, 2023
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // **************************************************************************************************************************
  2. //                                                                Plot Indicatore Test Equity Control Drawdown
  3.                                              // Su questo study bisogna caricare i dati Equity Compresi di Capitale Iniziale Su Data 2 //
  4. // **************************************************************************************************************************  
  5.  
  6. // **************************************************************************************************************************
  7. //                                                          2 Metodi EQC:
  8. // 1) Start sopra equityControlPercent "relative rawdown percent", stop sotto equityControlPercent "relative rawdown percent"
  9. // 2) Start sopra equityControlPercent "relative rawdown percent" ma con una nuova rottura dell'equity , stop sotto equityControlPercent "relative rawdown percent"
  10. // **************************************************************************************************************************
  11.  
  12. // **************************************************************************************************************************
  13. //     Il plotshape Indica se la soglia di drawdown di input è stata superata o meno con x verde e rossa.
  14. //     Per il metodo di ingresso 1) il plotshape coincide con gli ingressi.
  15. //     Per il metodo di ingresso 2) L' EquityBroken deve risultare a 0 e il plotshape non ha niente a che vedere con gli ingressi.
  16. // **************************************************************************************************************************  
  17.  
  18.  
  19.  Input:
  20.  equityControlPercent(7);
  21.  
  22.  Vars:
  23.     FirstBar(0), // Variabile per salvare l'indice della prima barra // da cancelare
  24.     balance(0),
  25.     highestRelativeEquity(0),
  26.     relativeDrawdownMonetary(0),
  27.     lowestRelativeEquity(0),
  28.     relativeDrawdownPercent(0),
  29.     tradingAllowed(false),
  30.     tradingNotAllowed(false);
  31.      
  32. // **************************************************************************************************************************
  33. // Inizio a utilizzare una percentuale del massimo drawdown relativo per stoppare l'operatività e ritorna ad operare quando è al di sopra della stessa percentuale BUONO FUNZIONA !!!
  34. // **************************************************************************************************************************            
  35. // Balance
  36. balance = (close Of Data2);
  37.  
  38. // Highest Relative Equity
  39. highestRelativeEquity = MaxList(balance, highestRelativeEquity);
  40.  
  41. // LowestRelativeEquity E RelativeDrawdownMonetary E RelativeDrawdownPercent
  42. if balance <= highestRelativeEquity then
  43.     lowestRelativeEquity = minlist(highestRelativeEquity, balance);
  44.     relativeDrawdownMonetary = (highestRelativeEquity - balance);
  45.     relativeDrawdownPercent = (relativeDrawdownMonetary / highestRelativeEquity) * 100;
  46.    
  47. // **************************************************************************************************************************
  48. // Clear the print log when the strategy first applyed or refreshed and print values on the log window
  49. // **************************************************************************************************************************
  50. Once Clearprintlog;
  51. print(Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), ", ", " HighestRelativeEQ= " ,highestRelativeEquity, ", ", " LowestRelativeEQ= " ,lowestRelativeEquity, ", ", " RelativeDrawdownMonetary= ", relativeDrawdownMonetary, ", ", " RelativeDrawdownPercent= ", relativeDrawdownPercent , " %", ", ", " BarNum= ", BarNumber);
  52.  
  53. // **************************************************************************************************************************
  54. // Inizio Provo Start Stop Equity Trading Con una percentuale del massimo drawdown relativo Solo Per Prova
  55. // **************************************************************************************************************************
  56. // Condizioni Segnale Start/Stop
  57. If relativeDrawdownPercent >= 0 and relativeDrawdownPercent <= equityControlPercent Then
  58.     tradingAllowed = true
  59. Else Begin
  60.     tradingAllowed = false;
  61. End;
  62.    
  63. if tradingAllowed = true Then
  64.     plot1(tradingAllowed, "Trading Allowed Relative DD %", Green)
  65. Else
  66.     plot1(tradingAllowed, "Trading Allowed Relative DD %", Red);
  67.  
  68.    
  69. // **************************************************************************************************************************
  70. // Plot su strategy 1mo plot Start
  71. // **************************************************************************************************************************
  72. If relativeDrawdownPercent >= 0 and relativeDrawdownPercent <= equityControlPercent then//and mp[0] <> mp[1] and mp[0] <> 0 Then
  73. Begin
  74.     Value1 = Text_new(D, T, L, "*");
  75.     Text_setcolor(Value1, Green);
  76.     Text_setstyle(Value1, 2, 0);
  77. End;
  78.  
  79. // **************************************************************************************************************************
  80. // Plot su strategy 2ndo plot End
  81. // **************************************************************************************************************************
  82. If relativeDrawdownPercent > equityControlPercent then //and mp[0] <> mp[1] and mp[0] <> 0 Then // and relativeDrawdownPercent <= 7
  83. Begin
  84.     Value2 = Text_new(D, T, L, "*");
  85.     Text_setcolor(Value2, Red);
  86.     Text_setstyle(Value2, 2, 0);
  87. End;
  88.  
  89. plot2(BarNumber, "BarNumber"); 
  90. //plot4(Currentbar, "CurrentBar");
  91.  
  92. plot3(relativeDrawdownPercent, "Relative Drawdown Percent", Yellow);
  93.  
  94. {var: MP(0);
  95. MP = I_Marketposition;
  96. plot4(MP);}
  97.  
  98. // **************************************************************************************************************************
  99. // Equity Control. Stoppa l'operatività ad una percentuale input derivanta dal massimo drawdown relativo della strategia originale caricata in data2 "Balance Con Initial Capital di tutte le candele" EQC_Method = 2
  100. // La strategia Riparte quando rompiamo un nuovo massimo dell'equity e non abbiamo raggiunto l'input del massimo drawdown ammesso ES: Stop >= 7% Max DD; Restart New Highest Equity High and < 7% Max DD;
  101. // **************************************************************************************************************************  
  102. vars:
  103. EquityBroken(0);  // When we have a new Equity High and Relative Drawdown is Less then equityControlPercent the value is set to 0 else 1. "Start Straidng Broke Equity Allowed"
  104.  
  105. If relativeDrawdownPercent > equityControlPercent then
  106.     EquityBroken = EquityBroken +1
  107. else if
  108.     relativeDrawdownPercent = 0 then
  109.     EquityBroken = 0;
  110.    
  111. plot5(EquityBroken, "Equity Broken")
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement