Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // **************************************************************************************************************************
- // Plot Indicatore Test Equity Control Drawdown
- // Su questo study bisogna caricare i dati Equity Compresi di Capitale Iniziale Su Data 2 //
- // **************************************************************************************************************************
- // **************************************************************************************************************************
- // 2 Metodi EQC:
- // 1) Start sopra equityControlPercent "relative rawdown percent", stop sotto equityControlPercent "relative rawdown percent"
- // 2) Start sopra equityControlPercent "relative rawdown percent" ma con una nuova rottura dell'equity , stop sotto equityControlPercent "relative rawdown percent"
- // **************************************************************************************************************************
- // **************************************************************************************************************************
- // Il plotshape Indica se la soglia di drawdown di input è stata superata o meno con x verde e rossa.
- // Per il metodo di ingresso 1) il plotshape coincide con gli ingressi.
- // Per il metodo di ingresso 2) L' EquityBroken deve risultare a 0 e il plotshape non ha niente a che vedere con gli ingressi.
- // **************************************************************************************************************************
- Input:
- equityControlPercent(7);
- Vars:
- FirstBar(0), // Variabile per salvare l'indice della prima barra // da cancelare
- balance(0),
- highestRelativeEquity(0),
- relativeDrawdownMonetary(0),
- lowestRelativeEquity(0),
- relativeDrawdownPercent(0),
- tradingAllowed(false),
- tradingNotAllowed(false);
- // **************************************************************************************************************************
- // 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 !!!
- // **************************************************************************************************************************
- // Balance
- balance = (close Of Data2);
- // Highest Relative Equity
- highestRelativeEquity = MaxList(balance, highestRelativeEquity);
- // LowestRelativeEquity E RelativeDrawdownMonetary E RelativeDrawdownPercent
- if balance <= highestRelativeEquity then
- lowestRelativeEquity = minlist(highestRelativeEquity, balance);
- relativeDrawdownMonetary = (highestRelativeEquity - balance);
- relativeDrawdownPercent = (relativeDrawdownMonetary / highestRelativeEquity) * 100;
- // **************************************************************************************************************************
- // Clear the print log when the strategy first applyed or refreshed and print values on the log window
- // **************************************************************************************************************************
- Once Clearprintlog;
- print(Formatdate("dd/MM/yy", ElDateToDateTime( Date )), ", ", BarDateTime.Format( "%H%M.%S" ), ", ", " HighestRelativeEQ= " ,highestRelativeEquity, ", ", " LowestRelativeEQ= " ,lowestRelativeEquity, ", ", " RelativeDrawdownMonetary= ", relativeDrawdownMonetary, ", ", " RelativeDrawdownPercent= ", relativeDrawdownPercent , " %", ", ", " BarNum= ", BarNumber);
- // **************************************************************************************************************************
- // Inizio Provo Start Stop Equity Trading Con una percentuale del massimo drawdown relativo Solo Per Prova
- // **************************************************************************************************************************
- // Condizioni Segnale Start/Stop
- If relativeDrawdownPercent >= 0 and relativeDrawdownPercent <= equityControlPercent Then
- tradingAllowed = true
- Else Begin
- tradingAllowed = false;
- End;
- if tradingAllowed = true Then
- plot1(tradingAllowed, "Trading Allowed Relative DD %", Green)
- Else
- plot1(tradingAllowed, "Trading Allowed Relative DD %", Red);
- // **************************************************************************************************************************
- // Plot su strategy 1mo plot Start
- // **************************************************************************************************************************
- If relativeDrawdownPercent >= 0 and relativeDrawdownPercent <= equityControlPercent then//and mp[0] <> mp[1] and mp[0] <> 0 Then
- Begin
- Value1 = Text_new(D, T, L, "*");
- Text_setcolor(Value1, Green);
- Text_setstyle(Value1, 2, 0);
- End;
- // **************************************************************************************************************************
- // Plot su strategy 2ndo plot End
- // **************************************************************************************************************************
- If relativeDrawdownPercent > equityControlPercent then //and mp[0] <> mp[1] and mp[0] <> 0 Then // and relativeDrawdownPercent <= 7
- Begin
- Value2 = Text_new(D, T, L, "*");
- Text_setcolor(Value2, Red);
- Text_setstyle(Value2, 2, 0);
- End;
- plot2(BarNumber, "BarNumber");
- //plot4(Currentbar, "CurrentBar");
- plot3(relativeDrawdownPercent, "Relative Drawdown Percent", Yellow);
- {var: MP(0);
- MP = I_Marketposition;
- plot4(MP);}
- // **************************************************************************************************************************
- // 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
- // 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;
- // **************************************************************************************************************************
- vars:
- 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"
- If relativeDrawdownPercent > equityControlPercent then
- EquityBroken = EquityBroken +1
- else if
- relativeDrawdownPercent = 0 then
- EquityBroken = 0;
- plot5(EquityBroken, "Equity Broken")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement